summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/openshift_checks/memory_availability.py
diff options
context:
space:
mode:
authorLuke Meyer <lmeyer@redhat.com>2017-06-16 17:24:01 -0400
committerLuke Meyer <lmeyer@redhat.com>2017-07-25 13:23:58 -0400
commit210fc2d3849a1baf9c1d8535044d92df23424274 (patch)
tree20b6998ca0696257eb816e4ace464ee95b926816 /roles/openshift_health_checker/openshift_checks/memory_availability.py
parent2a0936b291992ba1b7343680aec915df0c29892c (diff)
downloadopenshift-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/memory_availability.py')
-rw-r--r--roles/openshift_health_checker/openshift_checks/memory_availability.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/memory_availability.py b/roles/openshift_health_checker/openshift_checks/memory_availability.py
index 2b42c72a9..765ba072d 100644
--- a/roles/openshift_health_checker/openshift_checks/memory_availability.py
+++ b/roles/openshift_health_checker/openshift_checks/memory_availability.py
@@ -1,5 +1,5 @@
"""Check that recommended memory is available."""
-from openshift_checks import OpenShiftCheck, get_var
+from openshift_checks import OpenShiftCheck
MIB = 2**20
GIB = 2**30
@@ -21,19 +21,18 @@ class MemoryAvailability(OpenShiftCheck):
# https://access.redhat.com/solutions/3006511 physical RAM is partly reserved from memtotal
memtotal_adjustment = 1 * GIB
- @classmethod
- def is_active(cls, task_vars):
+ def is_active(self):
"""Skip hosts that do not have recommended memory requirements."""
- group_names = get_var(task_vars, "group_names", default=[])
- has_memory_recommendation = bool(set(group_names).intersection(cls.recommended_memory_bytes))
- return super(MemoryAvailability, cls).is_active(task_vars) and has_memory_recommendation
+ group_names = self.get_var("group_names", default=[])
+ has_memory_recommendation = bool(set(group_names).intersection(self.recommended_memory_bytes))
+ return super(MemoryAvailability, self).is_active() and has_memory_recommendation
- def run(self, tmp, task_vars):
- group_names = get_var(task_vars, "group_names")
- total_memory_bytes = get_var(task_vars, "ansible_memtotal_mb") * MIB
+ def run(self):
+ group_names = self.get_var("group_names")
+ total_memory_bytes = self.get_var("ansible_memtotal_mb") * MIB
recommended_min = max(self.recommended_memory_bytes.get(name, 0) for name in group_names)
- configured_min = float(get_var(task_vars, "openshift_check_min_host_memory_gb", default=0)) * GIB
+ configured_min = float(self.get_var("openshift_check_min_host_memory_gb", default=0)) * GIB
min_memory_bytes = configured_min or recommended_min
if total_memory_bytes + self.memtotal_adjustment < min_memory_bytes: