summaryrefslogtreecommitdiffstats
path: root/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-12-01 21:39:00 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-12-11 16:39:27 -0500
commit35c1abb6050f2cd1f31396edd42618a2998bd546 (patch)
treedfb31882e7eb459b173ea206a89bc834aba10dd0 /roles/openshift_aws/filter_plugins/openshift_aws_filters.py
parenta53b8f63175c80c9d0a8d590fd0854e2ed8e1aae (diff)
downloadopenshift-35c1abb6050f2cd1f31396edd42618a2998bd546.tar.gz
openshift-35c1abb6050f2cd1f31396edd42618a2998bd546.tar.bz2
openshift-35c1abb6050f2cd1f31396edd42618a2998bd546.tar.xz
openshift-35c1abb6050f2cd1f31396edd42618a2998bd546.zip
Changing the node group format to a list.
Diffstat (limited to 'roles/openshift_aws/filter_plugins/openshift_aws_filters.py')
-rw-r--r--roles/openshift_aws/filter_plugins/openshift_aws_filters.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/roles/openshift_aws/filter_plugins/openshift_aws_filters.py b/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
index e707abd3f..dfcb11da3 100644
--- a/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
+++ b/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
@@ -4,11 +4,43 @@
Custom filters for use in openshift_aws
'''
+from ansible import errors
+
class FilterModule(object):
''' Custom ansible filters for use by openshift_aws role'''
@staticmethod
+ def scale_groups_serial(scale_group_info, upgrade=False):
+ ''' This function will determine what the deployment serial should be and return it
+
+ Search through the tags and find the deployment_serial tag. Once found,
+ determine if an increment is needed during an upgrade.
+ if upgrade is true then increment the serial and return it
+ else return the serial
+ '''
+ if scale_group_info == []:
+ return 1
+
+ scale_group_info = scale_group_info[0]
+
+ if not isinstance(scale_group_info, dict):
+ raise errors.AnsibleFilterError("|filter plugin failed: Expected scale_group_info to be a dict")
+
+ serial = None
+
+ for tag in scale_group_info['tags']:
+ if tag['key'] == 'deployment_serial':
+ serial = int(tag['value'])
+ if upgrade:
+ serial += 1
+ break
+ else:
+ raise errors.AnsibleFilterError("|filter plugin failed: deployment_serial tag was not found")
+
+ return serial
+
+ @staticmethod
def scale_groups_match_capacity(scale_group_info):
''' This function will verify that the scale group instance count matches
the scale group desired capacity
@@ -38,4 +70,5 @@ class FilterModule(object):
def filters(self):
''' returns a mapping of filters to methods '''
return {'build_instance_tags': self.build_instance_tags,
- 'scale_groups_match_capacity': self.scale_groups_match_capacity}
+ 'scale_groups_match_capacity': self.scale_groups_match_capacity,
+ 'scale_groups_serial': self.scale_groups_serial}