本文整理汇总了PHP中Scalr_Environment::setPlatformConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Environment::setPlatformConfig方法的具体用法?PHP Scalr_Environment::setPlatformConfig怎么用?PHP Scalr_Environment::setPlatformConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Environment
的用法示例。
在下文中一共展示了Scalr_Environment::setPlatformConfig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setConfigVariable
/**
* Sets the values for the specified platform properties
*
* @deprecated by cloud credentials
* @param array $pars Associative array of the keys -> value
* @param \Scalr_Environment $env The environment object
* @param string $encrypted optional This parameter is already ignored
* @param string $cloudLocation The cloud location
*/
public function setConfigVariable($pars, \Scalr_Environment $env, $encrypted = true, $cloudLocation = '')
{
$config = array();
foreach ($pars as $key => $v) {
$index = $this->platform ? "{$this->platform}.{$key}" : $key;
$config[$index] = $v;
}
$env->setPlatformConfig($config, $encrypted, $cloudLocation);
}
示例2: xSaveRackspaceAction
public function xSaveRackspaceAction()
{
$pars = array();
$locations = array('rs-ORD1', 'rs-LONx');
$enabled = false;
/* @var $currentCloudCredentials Entity\CloudCredentials[] */
$currentCloudCredentials = $this->env->cloudCredentialsList(array_map(function ($location) {
return "{$location}." . SERVER_PLATFORMS::RACKSPACE;
}, $locations));
foreach ($currentCloudCredentials as $cloudCredential) {
if ($cloudCredential->isEnabled()) {
$enabled = true;
break;
}
}
if (!$enabled) {
throw new Scalr_Exception_Core('Rackspace cloud has been deprecated. Please use Rackspace Open Cloud instead.');
} else {
$enabled = false;
}
foreach ($locations as $location) {
if ($this->getParam("rackspace_is_enabled_{$location}")) {
$enabled = true;
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_USERNAME] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_USERNAME, 'string', "Username required", $location . SERVER_PLATFORMS::RACKSPACE);
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_API_KEY] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_API_KEY, 'string', "API Key required", $location . SERVER_PLATFORMS::RACKSPACE);
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_IS_MANAGED] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_IS_MANAGED, 'bool', "", $location . SERVER_PLATFORMS::RACKSPACE);
} else {
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_USERNAME] = false;
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_API_KEY] = false;
$pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_IS_MANAGED] = false;
}
}
if (count($this->checkVarError)) {
$this->response->failure();
$this->response->data(array('errors' => $this->checkVarError));
} else {
$this->db->BeginTrans();
try {
$this->env->enablePlatform(SERVER_PLATFORMS::RACKSPACE, $enabled);
foreach ($pars as $cloud => $prs) {
$this->makeCloudCredentials("{$cloud}." . SERVER_PLATFORMS::RACKSPACE, $prs);
$this->env->setPlatformConfig([Entity\Account\EnvironmentProperty::RACKSPACE_LOCATIONS => 'enabled'], true, $cloud);
}
if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
$this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
}
$this->response->success('Cloud credentials have been ' . ($enabled ? 'saved' : 'removed from Scalr'));
$this->response->data(array('enabled' => $enabled));
} catch (Exception $e) {
$this->db->RollbackTrans();
throw new Exception(_('Failed to save Rackspace settings'));
}
$this->db->CommitTrans();
}
}
示例3: xSaveEucalyptusAction
public function xSaveEucalyptusAction()
{
$this->request->defineParams(array('clouds' => array('type' => 'json')));
$pars = array();
$enabled = false;
$clouds = $this->getParam('clouds');
$cloudsDeleted = array();
if (count($clouds)) {
$enabled = true;
foreach ($clouds as $cloud) {
$pars[$cloud][EucalyptusPlatformModule::ACCOUNT_ID] = $this->checkVar(EucalyptusPlatformModule::ACCOUNT_ID, 'string', "Account ID required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::ACCESS_KEY] = $this->checkVar(EucalyptusPlatformModule::ACCESS_KEY, 'string', "Access Key required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::EC2_URL] = $this->checkVar(EucalyptusPlatformModule::EC2_URL, 'string', "EC2 URL required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::S3_URL] = $this->checkVar(EucalyptusPlatformModule::S3_URL, 'string', "S3 URL required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::SECRET_KEY] = $this->checkVar(EucalyptusPlatformModule::SECRET_KEY, 'password', "Secret Key required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::PRIVATE_KEY] = $this->checkVar(EucalyptusPlatformModule::PRIVATE_KEY, 'file', "x.509 Private Key required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::CERTIFICATE] = $this->checkVar(EucalyptusPlatformModule::CERTIFICATE, 'file', "x.509 Certificate required", $cloud);
$pars[$cloud][EucalyptusPlatformModule::CLOUD_CERTIFICATE] = $this->checkVar(EucalyptusPlatformModule::CLOUD_CERTIFICATE, 'file', "x.509 Cloud Certificate required", $cloud);
}
}
// clear old cloud locations
foreach ($this->db->GetAll('SELECT * FROM client_environment_properties WHERE env_id = ? AND name LIKE "eucalyptus.%" AND `group` != "" GROUP BY `group', $this->env->id) as $key => $value) {
if (!in_array($value['group'], $clouds)) {
$cloudsDeleted[] = $value['group'];
}
}
if (count($this->checkVarError)) {
$this->response->failure();
$this->response->data(array('errors' => $this->checkVarError));
} else {
$this->db->BeginTrans();
try {
$this->env->enablePlatform(SERVER_PLATFORMS::EUCALYPTUS, $enabled);
foreach ($cloudsDeleted as $key => $cloud) {
$this->db->Execute('DELETE FROM client_environment_properties WHERE env_id = ? AND `group` = ? AND name LIKE "eucalyptus.%"', array($this->env->id, $cloud));
}
foreach ($pars as $cloud => $prs) {
$this->env->setPlatformConfig($prs, true, $cloud);
}
if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
$this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
}
$this->response->success(_('Environment saved'));
$this->response->data(array('enabled' => $enabled));
} catch (Exception $e) {
$this->db->RollbackTrans();
throw new Exception(_('Failed to save Eucalyptus settings'));
}
$this->db->CommitTrans();
}
}
示例4: getClient
/**
* @param \Scalr_Environment $environment
* @return \Google_Service_Compute
*/
public function getClient(\Scalr_Environment $environment)
{
$client = new \Google_Client();
$client->setApplicationName("Scalr GCE");
$client->setScopes(array('https://www.googleapis.com/auth/compute'));
$key = base64_decode($environment->getPlatformConfigValue(self::KEY));
$client->setAssertionCredentials(new \Google_Auth_AssertionCredentials($environment->getPlatformConfigValue(self::SERVICE_ACCOUNT_NAME), array('https://www.googleapis.com/auth/compute'), $key, $environment->getPlatformConfigValue(self::JSON_KEY) ? null : 'notasecret'));
$client->setClientId($environment->getPlatformConfigValue(self::CLIENT_ID));
$gce = new \Google_Service_Compute($client);
//**** Store access token ****//
$jsonAccessToken = $environment->getPlatformConfigValue(self::ACCESS_TOKEN);
$accessToken = @json_decode($jsonAccessToken);
if ($accessToken && $accessToken->created + $accessToken->expires_in > time()) {
$client->setAccessToken($jsonAccessToken);
} else {
$gce->zones->listZones($environment->getPlatformConfigValue(self::PROJECT_ID));
$token = $client->getAccessToken();
$environment->setPlatformConfig(array(self::ACCESS_TOKEN => $token));
}
return $gce;
}
示例5: saveEc2
//.........这里部分代码省略.........
} catch (Exception $e) {
throw new Exception(sprintf(_("Failed to verify your EC2 access key and secret key: %s"), $e->getMessage()));
}
//Extract AWS Account ID
$pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] = $aws->getAccountNumber();
try {
if ($ccProps[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] != $pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID]) {
$this->db->Execute("DELETE FROM client_environment_properties WHERE name LIKE 'ec2.vpc.default%' AND env_id = ?", [$this->env->id]);
}
} catch (Exception $e) {
}
} else {
$pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] = $ccProps[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID];
}
} else {
$this->response->failure();
$this->response->data(['errors' => $this->checkVarError]);
return;
}
}
if ($enabled && $this->getContainer()->analytics->enabled && !empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET])) {
try {
$region = $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION];
$aws = $this->env->aws($region, $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY]);
if (!empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]) && $aws->getAccountNumber() != $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]) {
$payerCredentials = $this->getUser()->getAccount()->cloudCredentialsList([SERVER_PLATFORMS::EC2], [], [Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID => [['value' => $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]]]]);
if (count($payerCredentials) == 0) {
throw new Exception("Payer account not found!");
}
$payerCredentials = $payerCredentials->current();
$aws = $this->env->aws($region, $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_SECRET_KEY], !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] : null, !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] : null);
}
try {
$bucketObjects = $aws->s3->bucket->listObjects($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET]);
} catch (ClientException $e) {
if ($e->getErrorData() && $e->getErrorData()->getCode() == ErrorData::ERR_AUTHORIZATION_HEADER_MALFORMED && preg_match("/expecting\\s+'(.+?)'/", $e->getMessage(), $matches) && in_array($matches[1], Aws::getCloudLocations())) {
$expectingRegion = $matches[1];
if (isset($payerCredentials)) {
$aws = $this->env->aws($expectingRegion, $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_SECRET_KEY], !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] : null, !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] : null);
} else {
$aws = $this->env->aws($expectingRegion, $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY]);
}
$bucketObjects = $aws->s3->bucket->listObjects($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET]);
$pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION] = $expectingRegion;
} else {
throw $e;
}
}
$objectName = (empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]) ? '' : "{$pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]}-") . 'aws-billing-detailed-line-items-with-resources-and-tags';
$objectExists = false;
$bucketObjectName = null;
foreach ($bucketObjects as $bucketObject) {
/* @var $bucketObject Scalr\Service\Aws\S3\DataType\ObjectData */
if (strpos($bucketObject->objectName, $objectName) !== false) {
$bucketObjectName = $bucketObject->objectName;
$pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_ENABLED] = 1;
$objectExists = true;
break;
}
}
if (!$objectExists) {
$this->response->failure();
$this->response->data(['errors' => [Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT => "Object with name '{$objectName}' does not exist."]]);
return;
}
$aws->s3->object->getMetadata($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET], $bucketObjectName);
} catch (Exception $e) {
$this->response->failure();
$this->response->data(['errors' => [Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET => sprintf("Cannot access billing bucket with name %s. Error: %s", $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET], $e->getMessage())]]);
return;
}
}
$this->db->BeginTrans();
try {
$this->env->enablePlatform(SERVER_PLATFORMS::EC2, $enabled);
if ($enabled) {
$this->makeCloudCredentials(SERVER_PLATFORMS::EC2, $pars);
if ($this->getContainer()->analytics->enabled && $bNew) {
$this->getContainer()->analytics->notifications->onCloudAdd('ec2', $this->env, $this->user);
}
}
if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
$this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
}
//TODO: cloud suspension info must work with cloud credentials
if ($enabled && $this->env->status == Scalr_Environment::STATUS_INACTIVE && $this->env->getPlatformConfigValue('system.auto-disable-reason')) {
// env was inactive due invalid keys for amazon, activate it
$this->env->status = Scalr_Environment::STATUS_ACTIVE;
$this->env->save();
$this->env->setPlatformConfig(['system.auto-disable-reason' => NULL]);
$envAutoEnabled = true;
}
$this->db->CommitTrans();
} catch (Exception $e) {
$this->db->RollbackTrans();
throw new Exception(_("Failed to save AWS settings: {$e->getMessage()}"));
}
$this->response->success('Cloud credentials have been ' . ($enabled ? 'saved' : 'removed from Scalr'));
$this->response->data(['enabled' => $enabled, 'demoFarm' => $demoFarm, 'envAutoEnabled' => $envAutoEnabled]);
}
示例6: BuildRestServer
public function BuildRestServer($request)
{
try {
$Reflect = new ReflectionObject($this);
if ($Reflect->hasMethod($request['Action'])) {
//Authenticate
if ($request['AuthType'] == 'ldap') {
$this->AuthenticateLdap($request);
} else {
if ($request['AuthVersion'] == 2) {
$this->AuthenticateRESTv2($request);
} elseif ($request['AuthVersion'] == 3) {
$this->AuthenticateRESTv3($request);
} else {
$this->AuthenticateREST($request);
}
if ($this->user->getSetting(Scalr_Account_User::SETTING_API_ENABLED) != 1) {
throw new Exception(_("Your API keys are currently disabled. You can enable access at Settings > API access."));
}
//Check IP Addresses
if ($this->user->getSetting(Scalr_Account_User::SETTING_API_IP_WHITELIST)) {
$ips = explode(",", $this->user->getSetting(Scalr_Account_User::SETTING_API_IP_WHITELIST));
if (!$this->IPAccessCheck($ips)) {
throw new Exception(sprintf(_("Access to the API is not allowed from your IP '%s'"), $_SERVER['REMOTE_ADDR']));
}
}
}
//Check limit
if ($this->Environment->getPlatformConfigValue(Scalr_Environment::SETTING_API_LIMIT_ENABLED, false) == 1) {
$hour = $this->Environment->getPlatformConfigValue(Scalr_Environment::SETTING_API_LIMIT_HOUR, false);
$limit = $this->Environment->getPlatformConfigValue(Scalr_Environment::SETTING_API_LIMIT_REQPERHOUR, false);
$usage = $this->Environment->getPlatformConfigValue(Scalr_Environment::SETTING_API_LIMIT_USAGE, false);
if ($usage >= $limit && $hour == date("YmdH")) {
$reset = 60 - (int) date("i");
header("HTTP/1.0 429 Too Many Requests");
exit;
//throw new Exception(sprintf("Hourly API requests limit (%s) exceeded. Limit will be reset within %s minutes", $limit, $reset));
}
if (date("YmdH") > $hour) {
$hour = date("YmdH");
$usage = 0;
}
$this->Environment->setPlatformConfig(array(Scalr_Environment::SETTING_API_LIMIT_USAGE => $usage + 1, Scalr_Environment::SETTING_API_LIMIT_HOUR => $hour), false);
}
//Execute API call
$ReflectMethod = $Reflect->getMethod($request['Action']);
$args = array();
foreach ($ReflectMethod->getParameters() as $param) {
if (!$param->isOptional() && !isset($request[$param->getName()])) {
throw new Exception(sprintf("Missing required parameter '%s'", $param->getName()));
} else {
if ($param->isArray()) {
$args[$param->getName()] = (array) $request[$param->getName()];
} else {
$args[$param->getName()] = $request[$param->getName()];
}
}
}
$result = $ReflectMethod->invokeArgs($this, $args);
$this->LastTransactionID = $result->TransactionID;
// Create response
$DOMDocument = new DOMDocument('1.0', 'UTF-8');
$DOMDocument->loadXML("<{$request['Action']}Response></{$request['Action']}Response>");
$this->ObjectToXML($result, $DOMDocument->documentElement, $DOMDocument);
$retval = $DOMDocument->saveXML();
} else {
throw new Exception(sprintf("Action '%s' is not defined", $request['Action']));
}
} catch (Exception $e) {
if (!$this->LastTransactionID) {
$this->LastTransactionID = Scalr::GenerateUID();
}
$retval = "<?xml version=\"1.0\"?>\n" . "<Error>\n" . "\t<TransactionID>{$this->LastTransactionID}</TransactionID>\n" . "\t<Message>{$e->getMessage()}</Message>\n" . "</Error>\n";
}
if (isset($this->user)) {
$this->LogRequest($this->LastTransactionID, $request['Action'], $_SERVER['REMOTE_ADDR'], $request, $retval);
}
header("Content-type: text/xml");
header("Content-length: " . strlen($retval));
header("Access-Control-Allow-Origin: *");
print $retval;
}
示例7: getDefaultVpc
public function getDefaultVpc(\Scalr_Environment $environment, $cloudLocation)
{
$vpcId = $environment->getPlatformConfigValue(self::DEFAULT_VPC_ID . ".{$cloudLocation}");
if ($vpcId === null || $vpcId === false) {
$vpcId = "";
$aws = $environment->aws($cloudLocation);
$list = $aws->ec2->describeAccountAttributes(array('default-vpc'));
foreach ($list as $item) {
if ($item->attributeName == 'default-vpc') {
$vpcId = $item->attributeValueSet[0]->attributeValue;
}
}
if ($vpcId == 'none') {
$vpcId = '';
}
$environment->setPlatformConfig(array(self::DEFAULT_VPC_ID . ".{$cloudLocation}" => $vpcId));
}
return $vpcId;
}
示例8: xSaveEucalyptusAction
public function xSaveEucalyptusAction()
{
$this->request->defineParams(array('clouds' => array('type' => 'json')));
$pars = array();
$enabled = false;
$clouds = $this->getParam('clouds');
$cloudsDeleted = array();
if (count($clouds)) {
$enabled = true;
foreach ($clouds as $cloud) {
$pars[$cloud][Modules_Platforms_Eucalyptus::ACCOUNT_ID] = $this->checkVar(Modules_Platforms_Eucalyptus::ACCOUNT_ID, 'string', "Account ID required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::ACCESS_KEY] = $this->checkVar(Modules_Platforms_Eucalyptus::ACCESS_KEY, 'string', "Access Key required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::EC2_URL] = $this->checkVar(Modules_Platforms_Eucalyptus::EC2_URL, 'string', "EC2 URL required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::S3_URL] = $this->checkVar(Modules_Platforms_Eucalyptus::S3_URL, 'string', "S3 URL required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::SECRET_KEY] = $this->checkVar(Modules_Platforms_Eucalyptus::SECRET_KEY, 'password', "Secret Key required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::PRIVATE_KEY] = $this->checkVar(Modules_Platforms_Eucalyptus::PRIVATE_KEY, 'file', "x.509 Private Key required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::CERTIFICATE] = $this->checkVar(Modules_Platforms_Eucalyptus::CERTIFICATE, 'file', "x.509 Certificate required", $cloud);
$pars[$cloud][Modules_Platforms_Eucalyptus::CLOUD_CERTIFICATE] = $this->checkVar(Modules_Platforms_Eucalyptus::CLOUD_CERTIFICATE, 'file', "x.509 Cloud Certificate required", $cloud);
}
}
// clear old cloud locations
foreach ($this->db->GetAll("\n SELECT * FROM client_environment_properties\n WHERE env_id = ? AND name LIKE 'eucalyptus.%' AND `group` != ''\n GROUP BY `group`\n ", $this->env->id) as $key => $value) {
if (!in_array($value['group'], $clouds)) {
$cloudsDeleted[] = $value['group'];
}
}
if (count($this->checkVarError)) {
$this->response->failure();
$this->response->data(array('errors' => $this->checkVarError));
} else {
$this->db->BeginTrans();
try {
$this->env->enablePlatform(SERVER_PLATFORMS::EUCALYPTUS, $enabled);
foreach ($cloudsDeleted as $key => $cloud) {
$this->db->Execute('
DELETE FROM client_environment_properties
WHERE env_id = ? AND `group` = ? AND name LIKE "eucalyptus.%"
', array($this->env->id, $cloud));
}
foreach ($pars as $cloud => $prs) {
//Saves options to database
$this->env->setPlatformConfig($prs, true, $cloud);
//Verifies cloud credentials
$client = $this->env->eucalyptus($cloud);
try {
//Checks ec2url
$client->ec2->availabilityZone->describe();
} catch (ClientException $e) {
throw new Exception(sprintf("Failed to verify your access key and secret key against ec2 service for location %s: (%s)", $cloud, $e->getMessage()));
}
try {
//Verifies s3url
$client->s3->bucket->getList();
} catch (ClientException $e) {
throw new Exception(sprintf("Failed to verify your access key and secret key against s3 service for location %s: (%s)", $cloud, $e->getMessage()));
}
}
if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
$this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
}
$this->response->success(_('Environment saved'));
$this->response->data(array('enabled' => $enabled));
} catch (Exception $e) {
$this->db->RollbackTrans();
throw new Exception(sprintf("Failed to save Eucalyptus settings. %s", $e->getMessage()));
}
$this->db->CommitTrans();
}
}