Ejemplo n.º 1
0
 public function setupService()
 {
     return $this->getConnection()->loadBalancerService('cloudLoadBalancers', Utils::getRegion());
 }
Ejemplo n.º 2
0
 public function main()
 {
     // Flavors
     $this->step('List Flavors');
     $flavorList = $this->getService()->flavorList();
     $flavorList->sort('id');
     foreach ($flavorList as $flavor) {
         $this->stepInfo('%s: %sMB, ID: [%s]', $flavor->name, $flavor->ram, $flavor->id);
     }
     // Images
     $this->step('List Images');
     $imageList = $this->getService()->imageList();
     //$imageList->sort('name');
     foreach ($imageList as $image) {
         $this->stepInfo('%s; ID: [%s]; OS distro: [%s]', $image->name, $image->id, $image->metadata->os_distro);
     }
     // Create network
     $this->step('Create Network');
     $network = $this->getService()->network();
     try {
         $network->create(array('label' => $this->prepend(self::NETWORK_NAME), 'cidr' => '192.168.0.0/24'));
     } catch (ClientErrorResponseException $e) {
         $this->stepInfo('Failed to create network :(');
     }
     // List networks
     $this->step('List Networks');
     $networks = $this->getService()->networkList();
     //$networks->sort('label');
     foreach ($networks as $network) {
         $this->stepInfo('%s: %s (%s)', $network->id, $network->label, $network->cidr);
     }
     // Volumes
     $this->step('Connect to the VolumeService');
     $volumeService = $this->getConnection()->volumeService('cloudBlockStorage', Utils::getRegion());
     // Volume types
     $this->step('Volume Types');
     $volumeTypes = $volumeService->volumeTypeList();
     $volumeTypes->populateAll();
     foreach ($volumeTypes as $volumeType) {
         $this->stepInfo('%s - %s', $volumeType->id, $volumeType->name);
         // save the ID for later
         if (!isset($savedId)) {
             $savedId = $volumeType->id;
         }
     }
     // Create volume
     $this->step('Create a new Volume');
     $volume = $volumeService->volume();
     $volume->create(array('display_name' => $this->prepend(self::VOLUME_NAME), 'display_description' => 'A sample volume for testing', 'size' => self::VOLUME_SIZE, 'volume_type' => $volumeService->volumeType($savedId)));
     // List volumes
     $this->step('Listing volumes');
     $volumeList = $volumeService->volumeList();
     foreach ($volumeList as $volume1) {
         $this->stepInfo('Volume: %s %s [%s] size=%d', $volume1->id, $volume1->display_name, $volume1->display_description, $volume1->size);
     }
     // Create server
     $this->step('Create Server');
     $server = $this->getService()->server();
     $server->addFile('/var/test1', 'TEST 1');
     $server->addFile('/var/test2', 'TEST 2');
     $server->create(array('name' => $this->prepend(self::SERVER_NAME . time()), 'image' => $this->getService()->image(self::IMAGE), 'flavor' => $this->getService()->flavor(self::FLAVOR), 'networks' => array($this->getService()->network(Network::RAX_PUBLIC), $this->getService()->network(Network::RAX_PRIVATE)), "OS-DCF:diskConfig" => "AUTO"));
     $adminPassword = $server->adminPass;
     $this->stepInfo('ADMIN PASSWORD = %s', $adminPassword);
     $this->step('Wait for Server create');
     $server->waitFor('ACTIVE', 600, $this->getWaiterCallback());
     if ($server->status() == 'ERROR') {
         $this->stepInfo("Server create failed with ERROR\n");
         return false;
     }
     // Rebuild
     $this->step('Rebuild the server');
     $server->rebuild(array('adminPass' => $adminPassword, 'image' => $this->getService()->image(self::IMAGE)));
     sleep(3);
     $this->step('Wait for Server rebuild');
     $server->waitFor('ACTIVE', 600, $this->getWaiterCallback());
     if ($server->status() == 'ERROR') {
         $this->stepInfo("Server rebuild failed with ERROR\n");
         return false;
     }
     sleep(3);
     // Attach volume
     $this->step('Attach the volume');
     $server->attachVolume($volume);
     $volume->waitFor('in-use', 300, $this->getWaiterCallback());
     // Update & reboot server
     $this->step('Update the server name');
     $server->update(array('name' => $this->prepend(self::SERVER_NAME . time())));
     $server->waitFor('ACTIVE', 300, $this->getWaiterCallback());
     $this->step('Reboot Server');
     $server->reboot();
     $server->waitFor('ACTIVE', 300, $this->getWaiterCallback());
     // List all servers
     $this->step('List Servers');
     $list = $this->getService()->serverList();
     //$list->sort('name');
     foreach ($list as $server1) {
         $this->stepInfo($server1->name);
     }
 }
Ejemplo n.º 3
0
 public function setupService()
 {
     return $this->getConnection()->networkingService('cloudNetworks', Utils::getRegion());
 }
Ejemplo n.º 4
0
 public function setupService()
 {
     return $this->getConnection()->objectStoreService('cloudFiles', Utils::getRegion());
 }
Ejemplo n.º 5
0
 private function createClient()
 {
     Utils::log('Authenticate');
     $secret = array('username' => Utils::getEnvVar(Enum::ENV_USERNAME), 'apiKey' => Utils::getEnvVar(Enum::ENV_API_KEY));
     $identityEndpoint = Utils::getIdentityEndpoint();
     // Do connection stuff
     $client = new Rackspace($identityEndpoint, $secret);
     $client->setUserAgent($client->getUserAgent() . '/' . Enum::USER_AGENT);
     // enable logging
     if ($this->debugMode) {
         $client->addSubscriber(LogPlugin::getDebugPlugin());
     }
     $client->authenticate();
     Utils::logf('   Using identity endpoint: %s', $identityEndpoint);
     Utils::logf('   Using region: %s', Utils::getRegion());
     Utils::logf('   Token generated: %s', (string) $client->getToken());
     return $client;
 }
 public function setupService()
 {
     return $this->getConnection()->cloudMonitoringService('cloudMonitoring', Utils::getRegion());
 }
Ejemplo n.º 7
0
 public function stepInfoDotter()
 {
     $string = Utils::convertArgsToString(func_get_args());
     return $this->createSubStep($string, Step::TYPE_DOTTER);
 }
Ejemplo n.º 8
0
 public function setupService()
 {
     return $this->getConnection()->databaseService('cloudDatabases', Utils::getRegion(), 'publicURL');
 }
Ejemplo n.º 9
0
 public function setupService()
 {
     return $this->getConnection()->orchestrationService('cloudOrchestration', Utils::getRegion());
 }