diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-07-28 17:06:54 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-08-08 15:42:28 -0400 |
commit | 3c71d009c034c4a0f795ae0fb939746aea80fbca (patch) | |
tree | 86a3b227f2322300ba23999843ac6d8bead27a61 /roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py | |
parent | 566731dc4dd1aebbbf0244dc8a31eefb8cd42de5 (diff) | |
download | openshift-3c71d009c034c4a0f795ae0fb939746aea80fbca.tar.gz openshift-3c71d009c034c4a0f795ae0fb939746aea80fbca.tar.bz2 openshift-3c71d009c034c4a0f795ae0fb939746aea80fbca.tar.xz openshift-3c71d009c034c4a0f795ae0fb939746aea80fbca.zip |
openshift_checks: refactor find_ansible_mount
Reuse the code for finding the ansible_mounts mount for a path.
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py | 17 |
1 files changed, 2 insertions, 15 deletions
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"] @@ -68,18 +68,5 @@ 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 |