Browse Source

oo_filter: added custom fitler to return hosts group info

Matt Woodson 9 years ago
parent
commit
012428e6bc
1 changed files with 14 additions and 0 deletions
  1. 14 0
      filter_plugins/oo_filters.py

+ 14 - 0
filter_plugins/oo_filters.py

@@ -697,6 +697,19 @@ class FilterModule(object):
 
         return matching_pods
 
+    @staticmethod
+    def oo_get_hosts_from_hostvars(hostvars, hosts):
+        """ Return a list of hosts from hostvars """
+        retval = []
+        for host in hosts:
+            try:
+                retval.append(hostvars[host])
+            except errors.AnsibleError as _:
+                # host does not exist
+                pass
+
+        return retval
+
     def filters(self):
         """ returns a mapping of filters to methods """
         return {
@@ -724,4 +737,5 @@ class FilterModule(object):
             "oo_persistent_volume_claims": self.oo_persistent_volume_claims,
             "oo_31_rpm_rename_conversion": self.oo_31_rpm_rename_conversion,
             "oo_pods_match_component": self.oo_pods_match_component,
+            "oo_get_hosts_from_hostvars": self.oo_get_hosts_from_hostvars,
         }