summaryrefslogtreecommitdiffstats
path: root/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2018-01-11 18:43:36 -0500
committerGitHub <noreply@github.com>2018-01-11 18:43:36 -0500
commitfa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1 (patch)
tree6c891a58fb0642d9e0f7399f139940fe46c919e9 /roles/openshift_aws/filter_plugins/openshift_aws_filters.py
parentfdc5829d6ca252e1574278cd1dc50e932378d98d (diff)
parentd3fefc32a727fe3c13159c4e9fe4399f35b487a8 (diff)
downloadopenshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.gz
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.bz2
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.tar.xz
openshift-fa649787c6a19bbfffb16d9cce3f8e3f7de5a8a1.zip
Merge pull request #6614 from mgugino-upstream-stage/plugins-to-lib-utils
Move more plugins to lib_utils
Diffstat (limited to 'roles/openshift_aws/filter_plugins/openshift_aws_filters.py')
-rw-r--r--roles/openshift_aws/filter_plugins/openshift_aws_filters.py74
1 files changed, 0 insertions, 74 deletions
diff --git a/roles/openshift_aws/filter_plugins/openshift_aws_filters.py b/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
deleted file mode 100644
index dfcb11da3..000000000
--- a/roles/openshift_aws/filter_plugins/openshift_aws_filters.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-'''
-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
-
- '''
- for scale_group in scale_group_info:
- if scale_group['desired_capacity'] != len(scale_group['instances']):
- return False
-
- return True
-
- @staticmethod
- def build_instance_tags(clusterid):
- ''' This function will return a dictionary of the instance tags.
-
- The main desire to have this inside of a filter_plugin is that we
- need to build the following key.
-
- {"kubernetes.io/cluster/{{ openshift_aws_clusterid }}": "{{ openshift_aws_clusterid}}"}
-
- '''
- tags = {'clusterid': clusterid,
- 'kubernetes.io/cluster/{}'.format(clusterid): clusterid}
-
- return tags
-
- 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_serial': self.scale_groups_serial}