summaryrefslogtreecommitdiffstats
path: root/bin/openshift_ansible/awsutil.py
diff options
context:
space:
mode:
authorMatt Woodson <mwoodson@gmail.com>2016-03-01 14:03:28 -0500
committerMatt Woodson <mwoodson@gmail.com>2016-03-01 14:03:28 -0500
commit803586871bec03d203f1c95117885abe3304cdbf (patch)
tree70906dfbd7d623f9422165c3b16774ffe2e720ce /bin/openshift_ansible/awsutil.py
parent6ff12aa4f8d3a6191e27cbf5b24d9df09b494d3a (diff)
parent5335c1660445b8128932c484f8667f966f95f34b (diff)
downloadopenshift-803586871bec03d203f1c95117885abe3304cdbf.tar.gz
openshift-803586871bec03d203f1c95117885abe3304cdbf.tar.bz2
openshift-803586871bec03d203f1c95117885abe3304cdbf.tar.xz
openshift-803586871bec03d203f1c95117885abe3304cdbf.zip
Merge pull request #1527 from mwoodson/ohi_fix
ohi: added subtype searching
Diffstat (limited to 'bin/openshift_ansible/awsutil.py')
-rw-r--r--bin/openshift_ansible/awsutil.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/bin/openshift_ansible/awsutil.py b/bin/openshift_ansible/awsutil.py
index 945e6a20c..d46af3d66 100644
--- a/bin/openshift_ansible/awsutil.py
+++ b/bin/openshift_ansible/awsutil.py
@@ -37,6 +37,7 @@ class AwsUtil(object):
self.file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)))
self.setup_host_type_alias_lookup()
+ self.alias_lookup = None
def setup_host_type_alias_lookup(self):
"""Sets up the alias to host-type lookup table."""
@@ -101,6 +102,20 @@ class AwsUtil(object):
host_types.sort()
return host_types
+ def get_sub_host_types(self):
+ """Searches for sub-host-type tags in the inventory and returns all sub-host-types found."""
+ pattern = re.compile(r'^oo_subhosttype_(.*)')
+
+ sub_host_types = []
+ inv = self.get_inventory()
+ for key in inv.keys():
+ matched = pattern.match(key)
+ if matched:
+ sub_host_types.append(matched.group(1))
+
+ sub_host_types.sort()
+ return sub_host_types
+
def get_security_groups(self):
"""Searches for security_groups in the inventory and returns all SGs found."""
pattern = re.compile(r'^security_group_(.*)')
@@ -192,9 +207,15 @@ class AwsUtil(object):
host_type = self.resolve_host_type(host_type)
return "oo_hosttype_%s" % host_type
+ @staticmethod
+ def gen_sub_host_type_tag(sub_host_type):
+ """Generate the host type tag
+ """
+ return "oo_subhosttype_%s" % sub_host_type
+
# This function uses all of these params to perform a filters on our host inventory.
# pylint: disable=too-many-arguments
- def get_host_list(self, clusters=None, host_type=None, envs=None, version=None, cached=False):
+ def get_host_list(self, clusters=None, host_type=None, sub_host_type=None, envs=None, version=None, cached=False):
"""Get the list of hosts from the inventory using host-type and environment
"""
retval = set([])
@@ -229,6 +250,9 @@ class AwsUtil(object):
if host_type:
retval.intersection_update(inv.get(self.gen_host_type_tag(host_type, version), []))
+ if sub_host_type:
+ retval.intersection_update(inv.get(self.gen_sub_host_type_tag(sub_host_type), []))
+
if version != 'all':
retval.intersection_update(inv.get(AwsUtil.gen_version_tag(version), []))