diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-06-16 17:24:01 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-07-25 13:23:58 -0400 |
commit | 210fc2d3849a1baf9c1d8535044d92df23424274 (patch) | |
tree | 20b6998ca0696257eb816e4ace464ee95b926816 /roles/openshift_health_checker/openshift_checks/disk_availability.py | |
parent | 2a0936b291992ba1b7343680aec915df0c29892c (diff) | |
download | openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.gz openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.bz2 openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.xz openshift-210fc2d3849a1baf9c1d8535044d92df23424274.zip |
openshift_checks: refactor to internalize task_vars
Move task_vars into instance variable so we don't have to pass it
around everywhere. Also store tmp. Make sure both are filled in on
execute_module.
In the process, is_active became an instance method, and task_vars is
basically never used directly outside of test code.
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/disk_availability.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/disk_availability.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/disk_availability.py b/roles/openshift_health_checker/openshift_checks/disk_availability.py index e93e81efa..283461294 100644 --- a/roles/openshift_health_checker/openshift_checks/disk_availability.py +++ b/roles/openshift_health_checker/openshift_checks/disk_availability.py @@ -3,7 +3,7 @@ import os.path import tempfile -from openshift_checks import OpenShiftCheck, OpenShiftCheckException, get_var +from openshift_checks import OpenShiftCheck, OpenShiftCheckException class DiskAvailability(OpenShiftCheck): @@ -35,22 +35,21 @@ class DiskAvailability(OpenShiftCheck): }, } - @classmethod - def is_active(cls, task_vars): + def is_active(self): """Skip hosts that do not have recommended disk space requirements.""" - group_names = get_var(task_vars, "group_names", default=[]) + group_names = self.get_var("group_names", default=[]) active_groups = set() - for recommendation in cls.recommended_disk_space_bytes.values(): + for recommendation in self.recommended_disk_space_bytes.values(): active_groups.update(recommendation.keys()) has_disk_space_recommendation = bool(active_groups.intersection(group_names)) - return super(DiskAvailability, cls).is_active(task_vars) and has_disk_space_recommendation + return super(DiskAvailability, self).is_active() and has_disk_space_recommendation - def run(self, tmp, task_vars): - group_names = get_var(task_vars, "group_names") - ansible_mounts = get_var(task_vars, "ansible_mounts") + def run(self): + group_names = self.get_var("group_names") + ansible_mounts = self.get_var("ansible_mounts") ansible_mounts = {mount['mount']: mount for mount in ansible_mounts} - user_config = get_var(task_vars, "openshift_check_min_host_disk_gb", default={}) + user_config = self.get_var("openshift_check_min_host_disk_gb", default={}) try: # For backwards-compatibility, if openshift_check_min_host_disk_gb # is a number, then it overrides the required config for '/var'. |