Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
borderStyledashed
AWSCredentials credentials = null;
String endpoint = "http://<cloudstack_management_server_ipip>:7080/awsapi/awsapi>";
Protocol protocol = Protocol.HTTP;
int timeout = 600 * 1000;

// Extract AWS_ACCESS_KEY and AWS_SECRET_KEY from AwsCreadentials.properties file
try {
    credentials = new PropertiesCredentials(InlineGettingStartedCodeSampleApp.class.getResourceAsStream("AwsCredentials.properties"));
} catch (IOException e1) {
    System.out.println("Credential were not properly entered into AwsCredntials.properties.");
    System.exit(-1);
}

// Create a Client configuration object to control how the client connects to CloudStack e.g. retry counts
ClientConfiguration client = new ClientConfiguration();
client.setProtocol(protocol);
client.setSocketTimeout(timeout);

// Create a Amazon EC2Client object to call any EC2 API
ec2 = new AmazonEC2Client(credentials, client);
ec2.setEndpoint(endpoint);

// Use the Amazon client object to make the api call DecsribeImages
DescribeImagesRequest imagesRequest = new DescribeImagesRequest();
DescribeImagesResult imagesResult = ec2.describeImages(imagesRequest);
System.out.println("DescribeImages: " + imagesResult);

...

Code Block
borderStyledashed
<?php

error_reporting(-1);
header("Content-type: text/html; charset=utf-8");
require_once '../sdk.class.php';

$ec2 = new AmazonEC2();
$ec2->set_hostname('http://< cloudstack_management_server_ip >:7080/awsapi/');
$ec2->disable_ssl();
$ec2->set_max_retries(0);

$response  = $ec2->describe_images();
echo "\nDescribeImages \n";
print_r($response->body);

?>

...