Scalr\Server\Import\Platforms\Ec2ServerImport::applyTags PHP Method

applyTags() protected method

See also: AbstractServerImport::applyTags
protected applyTags ( )
    protected function applyTags()
    {
        if (empty($this->instance)) {
            throw new ServerImportException("Instance property is empty. Cannot add tags to server");
        }
        $dbServer = DBServer::LoadByID($this->server->serverId);
        try {
            // Invar: move applyGlobalVarsToValue to Entity\Server
            $tags = [['key' => Scalr_Governance::SCALR_META_TAG_NAME, 'value' => $dbServer->applyGlobalVarsToValue(Scalr_Governance::SCALR_META_TAG_VALUE)]];
            foreach ($this->tags as $key => $value) {
                $tags[] = ['key' => $key, 'value' => $dbServer->applyGlobalVarsToValue($value)];
            }
            $this->instance->createTags($tags);
        } catch (Exception $e) {
            throw new ServerImportException(sprintf('Scalr was unable to add tags to server %s: %s', $this->server->serverId, $e->getMessage()), $e->getCode(), $e);
        }
    }