11.3.3. Tag Filter of Latest VM Configuration

This example filters the latest virtual machine configuration list using the history tag tables. This kind of report demonstrates usage of the tags tree built in the Red Hat Enterprise Virtualization Manager to filter lists. The following SQL query defines this report. This query uses a predefined function that receives tag history IDs and returns the tag path with latest names of the tags in the Administration Portal. Ensure the values provided for the function result components of the where clause are substituted with appropriate values for your environment.

Example 11.3. 

	SELECT vm_name
  FROM v3_0_latest_vm_configuration_view
		inner join v3_0_latest_tag_relations_history_view on (v3_0_latest_vm_configuration_view.vm_id = v3_0_latest_tag_relations_history_view.entity_id)
			inner join v3_0_latest_tag_details_view on (v3_0_latest_tag_details_view.tag_id = v3_0_latest_tag_relations_history_view.parent_id)
 WHERE getpathinnames(v3_0_latest_tag_details_view.history_id) like '/root/tlv%'

This query returns a table of data with all virtual machine names that are attached to this tag:

Table 11.3. Tag Filtering of Latest VM Configuration

vm_name
RHEL6-Pool-67
RHEL6-Pool-5
RHEL6-Pool-6
RHEL6-23