Filtering based on multiple tags




The goal is to retrieve master/infra nodes belonging to openshift clusters which have tag lets say development using cloudform rest api.

For example , I have 5 openshift clusters where 3 clusters are tagged with cloudforms tag dev and 3 clusters with cloudforms tag test and I want to find the container nodes which are of type master/infra which belong to cluster with cloudforms tag dev



In Automation filter clusters by department tag “engineering” and hosts by environment tag “prd” (resulting hostnames in hosts list, you can also put entire host objects in the list if you want/need):

hosts =
clusters = $evm.vmdb(:ems_cluster).find_tagged_with(:all => "department/engineering", :ns => "/managed")
clusters.each { |cluster| cluster.hosts.each { |host| hosts << if host.tagged_with?("environment", "prd") } }

The last two lines can be combined into a single line but it’s too long.

For further details see Using Tags from Automate.


@xian, thanks for replying. I have rephrased the question to be more precise about the requirement and also I am looking for the rest api to do the same.