(self, mors)
return resource_tags
Get resource tags.

        Response structure:

            {
                <RESOURCE_TYPE>: {
                    <RESOURCE_MOR_ID>: ['<CATEGORY_NAME>:<TAG_NAME>', ...]
                },
                ...
            }
Get resource tags.
Get resource tags .
def get_resource_tags_for_mors(self, mors):
        # type: (List[vim.ManagedEntity]) -> ResourceTags
        """
        Get resource tags.

        Response structure:

            {
                <RESOURCE_TYPE>: {
                    <RESOURCE_MOR_ID>: ['<CATEGORY_NAME>:<TAG_NAME>', ...]
                },
                ...
            }
        """
        tag_associations = []
        for mors_batch in self.make_batch(mors):
            batch_tag_associations = self._client.tagging_tag_association_list_attached_tags_on_objects(mors_batch)
            tag_associations.extend(batch_tag_associations)

        self.log.debug("Fetched tag associations: %s", tag_associations)

        # Initialise resource_tags
        resource_tags = {
            resource_type: defaultdict(list) for resource_type in ALL_RESOURCES_WITH_METRICS
        }  # type: ResourceTags

        all_tag_ids = set()
        for tag_asso in tag_associations:
            all_tag_ids.update(tag_asso["tag_ids"])

        tags = self._get_tags(all_tag_ids)

        for tag_asso in tag_associations:
            mor_id = tag_asso["object_id"]["id"]
            mor_type = MOR_TYPE_MAPPING_FROM_STRING[tag_asso["object_id"]["type"]]
            mor_tag_ids = tag_asso["tag_ids"]
            for mor_tag_id in mor_tag_ids:
                if mor_tag_id not in tags:
                    self.log.debug("MOR tag id '%s' was not found in response, ignoring.", mor_tag_id)
                    continue
                resource_tags[mor_type][mor_id].append(tags[mor_tag_id])

        self.log.debug("Result resource tags: %s", resource_tags)
        return resource_tags
def get_resource_tags_for_mors ( self , mors ) : # type: (List[vim.ManagedEntity]) -> ResourceTags tag_associations = [ ] for mors_batch in self . make_batch ( mors ) : batch_tag_associations = self . _client . tagging_tag_association_list_attached_tags_on_objects ( mors_batch ) tag_associations . extend ( batch_tag_associations ) self . log . debug ( "Fetched tag associations: %s" , tag_associations ) # Initialise resource_tags resource_tags = { resource_type : defaultdict ( list ) for resource_type in ALL_RESOURCES_WITH_METRICS } # type: ResourceTags all_tag_ids = set ( ) for tag_asso in tag_associations : all_tag_ids . update ( tag_asso [ "tag_ids" ] ) tags = self . _get_tags ( all_tag_ids ) for tag_asso in tag_associations : mor_id = tag_asso [ "object_id" ] [ "id" ] mor_type = MOR_TYPE_MAPPING_FROM_STRING [ tag_asso [ "object_id" ] [ "type" ] ] mor_tag_ids = tag_asso [ "tag_ids" ] for mor_tag_id in mor_tag_ids : if mor_tag_id not in tags : self . log . debug ( "MOR tag id '%s' was not found in response, ignoring." , mor_tag_id ) continue resource_tags [ mor_type ] [ mor_id ] . append ( tags [ mor_tag_id ] ) self . log . debug ( "Result resource tags: %s" , resource_tags ) return resource_tags