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/docker_storage.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/docker_storage.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/docker_storage.py | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/docker_storage.py b/roles/openshift_health_checker/openshift_checks/docker_storage.py index 7ae384bd7..0558ddf14 100644 --- a/roles/openshift_health_checker/openshift_checks/docker_storage.py +++ b/roles/openshift_health_checker/openshift_checks/docker_storage.py @@ -1,6 +1,5 @@ """Check Docker storage driver and usage.""" import json -import os.path import re from openshift_checks import OpenShiftCheck, OpenShiftCheckException from openshift_checks.mixins import DockerHostMixin @@ -252,7 +251,7 @@ class DockerStorage(DockerHostMixin, OpenShiftCheck): "msg": "Specified 'max_overlay_usage_percent' is not a percentage: {}".format(threshold), } - mount = self.find_ansible_mount(path, self.get_var("ansible_mounts")) + mount = self.find_ansible_mount(path) try: free_bytes = mount['size_available'] total_bytes = mount['size_total'] @@ -275,22 +274,3 @@ class DockerStorage(DockerHostMixin, OpenShiftCheck): } return {} - - # TODO(lmeyer): migrate to base class - @staticmethod - def find_ansible_mount(path, ansible_mounts): - """Return the mount point for path from ansible_mounts.""" - - mount_for_path = {mount['mount']: mount for mount in ansible_mounts} - mount_point = path - while mount_point not in mount_for_path: - if mount_point in ["/", ""]: # "/" not in ansible_mounts??? - break - mount_point = os.path.dirname(mount_point) - - try: - return mount_for_path[mount_point] - except KeyError: - known_mounts = ', '.join('"{}"'.format(mount) for mount in sorted(mount_for_path)) or 'none' - msg = 'Unable to determine mount point for path "{}". Known mount points: {}.' - raise OpenShiftCheckException(msg.format(path, known_mounts)) |