Exemplo n.º 1
0
 public static function farmSave(DBFarm $DBFarm, array $roles)
 {
     foreach ($roles as $DBFarmRole) {
         if ($DBFarmRole->Platform != SERVER_PLATFORMS::EUCALYPTUS) {
             continue;
         }
         $location = $DBFarmRole->CloudLocation;
         $sshKey = Scalr_Model::init(Scalr_Model::SSH_KEY);
         if (!$sshKey->loadGlobalByFarmId($DBFarm->ID, $location)) {
             $key_name = "FARM-{$DBFarm->ID}";
             $eucaClient = Scalr_Service_Cloud_Eucalyptus::newCloud($DBFarm->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::SECRET_KEY, true, $location), $DBFarm->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::ACCESS_KEY, true, $location), $DBFarm->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::EC2_URL, true, $location));
             $result = $eucaClient->CreateKeyPair($key_name);
             if ($result->keyMaterial) {
                 $sshKey->farmId = $DBFarm->ID;
                 $sshKey->clientId = $DBFarm->ClientID;
                 $sshKey->envId = $DBFarm->EnvID;
                 $sshKey->type = Scalr_SshKey::TYPE_GLOBAL;
                 $sshKey->cloudLocation = $location;
                 $sshKey->cloudKeyName = $key_name;
                 $sshKey->platform = SERVER_PLATFORMS::EUCALYPTUS;
                 $sshKey->setPrivate($result->keyMaterial);
                 $sshKey->save();
             }
         }
     }
 }
Exemplo n.º 2
0
 public function xGetAvailZonesAction()
 {
     $client = Scalr_Service_Cloud_Eucalyptus::newCloud($this->getEnvironment()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::SECRET_KEY, true, $this->getParam('cloudLocation')), $this->getEnvironment()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::ACCESS_KEY, true, $this->getParam('cloudLocation')), $this->getEnvironment()->getPlatformConfigValue(Modules_Platforms_Eucalyptus::EC2_URL, true, $this->getParam('cloudLocation')));
     $result = $client->describeAvailabilityZones();
     $data = array();
     foreach ($result->availabilityZoneInfo->item as $zone) {
         $data[] = array('id' => (string) $zone->zoneName, 'name' => (string) $zone->zoneName);
     }
     $this->response->data(array('data' => $data));
 }
Exemplo n.º 3
0
 /**
  * @return Scalr_Service_Cloud_Eucalyptus_Client
  * Enter description here ...
  */
 private function getEucaClient(Scalr_Environment $environment, $cloudLocation)
 {
     return Scalr_Service_Cloud_Eucalyptus::newCloud($environment->getPlatformConfigValue(self::SECRET_KEY, true, $cloudLocation), $environment->getPlatformConfigValue(self::ACCESS_KEY, true, $cloudLocation), $environment->getPlatformConfigValue(self::EC2_URL, true, $cloudLocation));
 }