From 3c71d009c034c4a0f795ae0fb939746aea80fbca Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Fri, 28 Jul 2017 17:06:54 -0400 Subject: openshift_checks: refactor find_ansible_mount Reuse the code for finding the ansible_mounts mount for a path. --- .../openshift_checks/etcd_imagedata_size.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py') diff --git a/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py b/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py index ae8460b7e..f4296753a 100644 --- a/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py +++ b/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py @@ -2,7 +2,7 @@ Ansible module for determining if the size of OpenShift image data exceeds a specified limit in an etcd cluster. """ -from openshift_checks import OpenShiftCheck, OpenShiftCheckException +from openshift_checks import OpenShiftCheck class EtcdImageDataSize(OpenShiftCheck): @@ -12,7 +12,7 @@ class EtcdImageDataSize(OpenShiftCheck): tags = ["etcd"] def run(self): - etcd_mountpath = self._get_etcd_mountpath(self.get_var("ansible_mounts")) + etcd_mountpath = self.find_ansible_mount("/var/lib/etcd") etcd_avail_diskspace = etcd_mountpath["size_available"] etcd_total_diskspace = etcd_mountpath["size_total"] @@ -67,19 +67,6 @@ class EtcdImageDataSize(OpenShiftCheck): return {} - @staticmethod - def _get_etcd_mountpath(ansible_mounts): - valid_etcd_mount_paths = ["/var/lib/etcd", "/var/lib", "/var", "/"] - - mount_for_path = {mnt.get("mount"): mnt for mnt in ansible_mounts} - for path in valid_etcd_mount_paths: - if path in mount_for_path: - return mount_for_path[path] - - paths = ', '.join(sorted(mount_for_path)) or 'none' - msg = "Unable to determine a valid etcd mountpath. Paths mounted: {}.".format(paths) - raise OpenShiftCheckException(msg) - @staticmethod def _to_gigabytes(byte_size): return float(byte_size) / 10.0**9 -- cgit v1.2.3