Exemplo n.º 1
0
 public function xGetSnapshotsAction()
 {
     $aws = $this->getEnvironment()->aws($this->getParam('cloudLocation'));
     $response = $aws->ec2->snapshot->describe(null, null, array(array('name' => SnapshotFilterNameType::ownerId(), 'value' => $this->getEnvironment()->getPlatformConfigValue(Ec2PlatformModule::ACCOUNT_ID)), array('name' => SnapshotFilterNameType::status(), 'value' => SnapshotData::STATUS_COMPLETED)));
     $data = array();
     /* @var $pv \Scalr\Service\Aws\Ec2\DataType\SnapshotData */
     foreach ($response as $pv) {
         if ($pv->status == SnapshotData::STATUS_COMPLETED) {
             $data[] = array('snapid' => $pv->snapshotId, 'createdat' => Scalr_Util_DateTime::convertTz($pv->startTime), 'size' => $pv->volumeSize, 'snapshotId' => $pv->snapshotId, 'createdDate' => Scalr_Util_DateTime::convertTz($pv->startTime), 'size' => $pv->volumeSize, 'volumeId' => $pv->volumeId, 'description' => (string) $pv->description, 'encrypted' => $pv->encrypted);
         }
     }
     $this->response->data(array('data' => $data));
 }
Exemplo n.º 2
0
Arquivo: Ec2.php Projeto: mheydt/scalr
 /**
  * @param string $cloudLocation
  * @param string $query
  * @param int    $limit
  * @param string $nextToken
  */
 public function xGetSnapshotsAction($cloudLocation, $query = null, $limit = null, $nextToken = null)
 {
     $aws = $this->getEnvironment()->aws($cloudLocation);
     $filters = [['name' => SnapshotFilterNameType::status(), 'value' => SnapshotData::STATUS_COMPLETED]];
     if ($query) {
         if (strpos($query, 'snap-') === 0) {
             $filters[] = ['name' => SnapshotFilterNameType::snapshotId(), 'value' => $query . '*'];
         } elseif (strpos($query, 'vol-') === 0) {
             $filters[] = ['name' => SnapshotFilterNameType::volumeId(), 'value' => $query . '*'];
         } else {
             $filters[] = ['name' => SnapshotFilterNameType::description(), 'value' => '*' . $query . '*'];
         }
     }
     $response = $aws->ec2->snapshot->describe(null, [$this->getEnvironment()->cloudCredentials(SERVER_PLATFORMS::EC2)->properties[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID]], $filters, null, $query ? null : $nextToken, $query ? null : $limit);
     $data = array();
     $count = 0;
     /* @var $pv \Scalr\Service\Aws\Ec2\DataType\SnapshotData */
     foreach ($response as $pv) {
         $count++;
         $data[] = array('snapid' => $pv->snapshotId, 'createdat' => Scalr_Util_DateTime::convertTz($pv->startTime), 'size' => $pv->volumeSize, 'snapshotId' => $pv->snapshotId, 'createdDate' => Scalr_Util_DateTime::convertTz($pv->startTime), 'volumeSize' => $pv->volumeSize, 'volumeId' => $pv->volumeId, 'description' => (string) $pv->description, 'encrypted' => $pv->encrypted);
     }
     $this->response->data(['data' => $data, 'nextToken' => $response->getNextToken()]);
 }