Scalr\Model\Entity\FarmRole::getCloudTags PHP Method

getCloudTags() public method

Return list of tags that should be applied on cloud resources. GV interpolation IS NOT applied on it yet.
public getCloudTags ( boolean $addNameTag = false ) : array
$addNameTag boolean optional If true add tag Name (on EC2 cloud)
return array Return list of tags [key => value]
    public function getCloudTags($addNameTag = false)
    {
        $tags = [];
        $governance = new Scalr_Governance($this->getFarm()->envId);
        if ($addNameTag && $this->platform == SERVER_PLATFORMS::EC2) {
            $nameFormat = $governance->getValue(SERVER_PLATFORMS::EC2, Scalr_Governance::AWS_INSTANCE_NAME_FORMAT);
            if (!$nameFormat) {
                $nameFormat = $this->settings[FarmRoleSetting::AWS_INSTANCE_NAME_FORMAT];
                if (!$nameFormat) {
                    $nameFormat = "{SCALR_FARM_NAME} -> {SCALR_FARM_ROLE_ALIAS} #{SCALR_INSTANCE_INDEX}";
                }
            }
            $tags['Name'] = $nameFormat;
        }
        $tags[Scalr_Governance::SCALR_META_TAG_NAME] = Scalr_Governance::SCALR_META_TAG_VALUE;
        $gTags = (array) $governance->getValue(SERVER_PLATFORMS::EC2, Scalr_Governance::AWS_TAGS);
        $gAllowAdditionalTags = $governance->getValue(SERVER_PLATFORMS::EC2, Scalr_Governance::AWS_TAGS, 'allow_additional_tags');
        if (count($gTags) > 0) {
            foreach ($gTags as $tKey => $tValue) {
                if ($tKey && count($tags) < 10 && !isset($tags[$tKey])) {
                    $tags[$tKey] = $tValue;
                }
            }
        }
        if (count($gTags) == 0 || $gAllowAdditionalTags) {
            //Custom tags
            $cTags = $this->settings[FarmRoleSetting::AWS_TAGS_LIST];
            $tagsList = @explode("\n", $cTags);
            foreach ((array) $tagsList as $tag) {
                $tag = trim($tag);
                if ($tag && count($tags) < 10) {
                    $tagChunks = explode("=", $tag);
                    if (!isset($tags[trim($tagChunks[0])])) {
                        $tags[trim($tagChunks[0])] = trim($tagChunks[1]);
                    }
                }
            }
        }
        return $tags;
    }