createTags() публичный Метод

Adds or overwrites one or more tags for the specified EC2 resource or resources. Each resource can have a maximum of 10 tags. Each tag consists of a key and optional value. Tag keys must be unique per resource.
public createTags ( Scalr\Service\Aws\Ec2\DataType\ResourceTagSetList | Scalr\Service\Aws\Ec2\DataType\ResourceTagSetData | array $tagList ) : boolean
$tagList Scalr\Service\Aws\Ec2\DataType\ResourceTagSetList | Scalr\Service\Aws\Ec2\DataType\ResourceTagSetData | array The key/value pair list of the Tags.
Результат boolean Returns true on success or throws an exception otherwise
Пример #1
0
 /**
  * Attaches volume to server
  *
  * It uses request params and can't be used without UI request
  *
  * @param    VolumeData $info AWS EBS Volume info
  * @throws   Exception
  */
 protected function attachVolumeToServer(VolumeData $info)
 {
     $dBServer = DBServer::LoadByID($this->getParam('serverId'));
     //Check access permission to specified server
     $this->request->checkPermissions($dBServer->GetFarmObject()->__getNewFarmObject(), Acl::PERM_FARMS_SERVERS);
     $errmsg = null;
     try {
         $dbEbsVolume = DBEBSVolume::loadByVolumeId($this->getParam('volumeId'));
         if ($dbEbsVolume->isManual == 0) {
             $errmsg = sprintf(_("This volume was automatically created for role '%s' on farm '%s' and cannot be re-attahced manually."), $this->db->GetOne("\n                        SELECT name FROM roles\n                        JOIN farm_roles ON farm_roles.role_id = roles.id\n                        WHERE farm_roles.id=?\n                        LIMIT 1\n                    ", array($dbEbsVolume->farmRoleId)), $this->db->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($dbEbsVolume->farmId)));
         }
     } catch (Exception $e) {
     }
     if (!empty($errmsg)) {
         throw new Exception($errmsg);
     }
     $image = Image::findOne([['platform' => $dBServer->platform], ['id' => $dBServer->imageId], ['cloudLocation' => $dBServer->GetCloudLocation()]]);
     $device = $dBServer->GetFreeDeviceName($image->isEc2HvmImage());
     $res = $info->attach($dBServer->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID), $device);
     if ($this->getParam('attachOnBoot') == 'on') {
         $dbEbsVolume = new DBEBSVolume();
         $dbEbsVolume->attachmentStatus = EC2_EBS_ATTACH_STATUS::ATTACHING;
         $dbEbsVolume->isManual = true;
         $dbEbsVolume->volumeId = $info->volumeId;
         $dbEbsVolume->ec2AvailZone = $info->availabilityZone;
         $dbEbsVolume->ec2Region = $this->getParam('cloudLocation');
         $dbEbsVolume->deviceName = $device;
         $dbEbsVolume->farmId = $dBServer->farmId;
         $dbEbsVolume->farmRoleId = $dBServer->farmRoleId;
         $dbEbsVolume->serverId = $dBServer->serverId;
         $dbEbsVolume->serverIndex = $dBServer->index;
         $dbEbsVolume->size = $info->size;
         $dbEbsVolume->snapId = $info->snapshotId;
         $dbEbsVolume->mount = $this->getParam('mount') == 1;
         $dbEbsVolume->mountPoint = $this->getParam('mountPoint');
         $dbEbsVolume->mountStatus = $this->getParam('mount') == 1 ? EC2_EBS_MOUNT_STATUS::AWAITING_ATTACHMENT : EC2_EBS_MOUNT_STATUS::NOT_MOUNTED;
         $dbEbsVolume->clientId = $this->user->getAccountId();
         $dbEbsVolume->envId = $this->getEnvironmentId();
         $dbEbsVolume->Save();
     }
     //Updates/Creates AWS Tags of Volume
     $tags = [];
     foreach ($dBServer->getAwsTags() as $k => $v) {
         $tags[] = ['key' => $k, 'value' => $v];
     }
     if (!empty($tags)) {
         $info->createTags($tags);
     }
 }