public function xGetEc2MigrateDetailsAction($id, $cloudLocation)
{
$this->request->restrictAccess(Acl::RESOURCE_IMAGES_ENVIRONMENT, Acl::PERM_IMAGES_ENVIRONMENT_MANAGE);
/* @var $image Image */
$image = Image::findOne([['platform' => SERVER_PLATFORMS::EC2], ['id' => $id], ['cloudLocation' => $cloudLocation], ['envId' => $this->getEnvironmentId()]]);
if (!$image) {
throw new Exception('Image not found');
}
$this->request->checkPermissions($image, true);
if (!$this->getEnvironment()->isPlatformEnabled(SERVER_PLATFORMS::EC2)) {
throw new Exception('You can migrate image between regions only on EC2 cloud');
}
$platform = PlatformFactory::NewPlatform(SERVER_PLATFORMS::EC2);
$locationsList = $platform->getLocations($this->environment);
$availableDestinations = [];
$cloudLocation = $image->cloudLocation;
foreach ($locationsList as $location => $name) {
if ($location != $image->cloudLocation) {
$availableDestinations[] = array('cloudLocation' => $location, 'name' => $name);
} else {
$cloudLocation = $name;
}
}
$this->response->data(array('availableDestinations' => $availableDestinations, 'name' => $image->name, 'cloudLocation' => $cloudLocation));
}