(self, sampler, wmi_obj, tag_query)
return tag
Design a query based on the given WMIObject to extract a tag.

        Returns: tag or TagQueryUniquenessFailure exception.
Design a query based on the given WMIObject to extract a tag.
Design a query based on the given WMIObject to extract a tag .
def _get_tag_query_tag(self, sampler, wmi_obj, tag_query):
        # type: (WMISampler, WMIObject, TagQuery) -> str
        """
        Design a query based on the given WMIObject to extract a tag.

        Returns: tag or TagQueryUniquenessFailure exception.
        """
        self.log.debug(u"`tag_queries` parameter found. wmi_object=%s - query=%s", wmi_obj, tag_query)

        # Extract query information
        target_class, target_property, filters = self._format_tag_query(sampler, wmi_obj, tag_query)

        # Create a specific sampler
        with WMISampler(
            self.log, target_class, [target_property], filters=filters, **sampler.connection
        ) as tag_query_sampler:
            tag_query_sampler.sample()

            # Extract tag
            self._raise_on_invalid_tag_query_result(tag_query_sampler, wmi_obj, tag_query)

            link_value = str(tag_query_sampler[0][target_property]).lower()

        tag = "{tag_name}:{tag_value}".format(tag_name=target_property.lower(), tag_value="_".join(link_value.split()))

        self.log.debug(u"Extracted `tag_queries` tag: '%s'", tag)
        return tag
def _get_tag_query_tag ( self , sampler , wmi_obj , tag_query ) : # type: (WMISampler, WMIObject, TagQuery) -> str self . log . debug ( u"`tag_queries` parameter found. wmi_object=%s - query=%s" , wmi_obj , tag_query ) # Extract query information target_class , target_property , filters = self . _format_tag_query ( sampler , wmi_obj , tag_query ) # Create a specific sampler with WMISampler ( self . log , target_class , [ target_property ] , filters = filters , * * sampler . connection ) as tag_query_sampler : tag_query_sampler . sample ( ) # Extract tag self . _raise_on_invalid_tag_query_result ( tag_query_sampler , wmi_obj , tag_query ) link_value = str ( tag_query_sampler [ 0 ] [ target_property ] ) . lower ( ) tag = "{tag_name}:{tag_value}" . format ( tag_name = target_property . lower ( ) , tag_value = "_" . join ( link_value . split ( ) ) ) self . log . debug ( u"Extracted `tag_queries` tag: '%s'" , tag ) return tag