|
@@ -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), []))
|
|
|
|