Skip to content
Snippets Groups Projects
Commit 0d1176ee authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #2736821: aws_cloud - added...

Issue #2736821: aws_cloud - added ApiController::getAvailabilityZone(ConfigInterface $cloud_context)
parent 4a5c8b67
No related branches found
No related tags found
No related merge requests found
<?php
// Updated by yas 2016/09/06
// Updated by yas 2016/09/05
// Updated by yas 2016/09/04
// Updated by yas 2016/07/06
......@@ -411,7 +412,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
// $mock = new MockHandler();
// $mock = new MockHandler(array($this->getMockhandlerResult()));
$ec2_config = $config->get('aws_cloud_test_mode')
$ec2_config = $config->get('aws_cloud_test_mode') // This is boolean value - Test mode: TRUE or FALSE
// test mode
? array(
'credentials' => array(
......@@ -494,14 +495,15 @@ exit;
// $command = $ec2_client->getCommand($operation, $params);
// print "passed 3: " . var_dump($command) . "<br />";
print "passed 4: $operation<br />";
// @TODO: for debug, therefore clean up the following line later
// print "passed 4: $operation<br />";
// $result = $ec2_client->execute($command);
return $result;
}
catch (Ec2Exception $e) {
print "ApiController::execute - passed 5";
print "ApiController::execute - passed 5: $operation";
// var_dump($e);
print '<br />Response: ';
print_r($e->getResponse());
......@@ -668,7 +670,7 @@ exit;
->execute();
foreach ($entity_ids as $entity_id) {
Image::load($entity_id);
$entity = Image::load($entity_id);
$entity->delete();
}
......@@ -1476,7 +1478,7 @@ exit;
$params = array(
// The following parameters are required.
'DryRun' => $this->is_dryrun,
'ImageId' => $instance->image_id(), // e.g. ami-b9ff39d9 | ubuntu-xenial-16.04-amd64-server-20160627
'ImageId' => $instance->image_id(), // e.g.ami-8936e0e9 | ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20160830 (ami-8936e0e9)
'MaxCount' => $instance->max_count(),
'MinCount' => $instance->min_count(),
'InstanceType' => $instance->instance_type(),
......@@ -1719,4 +1721,30 @@ exit;
return $result;
}
/**
* @inheritdoc}
*/
public function getAvailabilityZones(ConfigInterface $cloud_context) {
$operation = 'DescribeAvailabilityZones';
$params = array(
'DryRun' => $this->is_dryrun,
);
$result = array();
try {
$result = $this->execute($cloud_context->id(), $operation, $params);
}
catch (Ec2Exception $e) {
}
$availability_zones = array();
foreach (array_column($result['AvailabilityZones'], 'ZoneName') as $key => $availability_zone)
$availability_zones[$availability_zone] = $availability_zone;
return $availability_zones;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment