summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/inventory.py
diff options
context:
space:
mode:
authorAdam King <adking@redhat.com>2023-06-02 01:23:45 +0200
committerAdam King <adking@redhat.com>2023-06-02 01:47:16 +0200
commitb4002529b6ec4fae83ae3958f9fc288b22106f90 (patch)
treedb6285a87b061e4dcf52398fe214040b618fdc3b /src/pybind/mgr/cephadm/inventory.py
parentMerge pull request #51176 from linuxbox2/wip-fix-rgwfile-ver (diff)
downloadceph-b4002529b6ec4fae83ae3958f9fc288b22106f90.tar.xz
ceph-b4002529b6ec4fae83ae3958f9fc288b22106f90.zip
mgr/cephadm: add is_host_<status> functions to HostCache
A bunch of places were doing list compression to see if a host was unreachable/draining/schedulable by hostname. This is meant to replace all those instances of list compression with a function call that does the same Fixes: https://tracker.ceph.com/issues/61548 Signed-off-by: Adam King <adking@redhat.com>
Diffstat (limited to 'src/pybind/mgr/cephadm/inventory.py')
-rw-r--r--src/pybind/mgr/cephadm/inventory.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pybind/mgr/cephadm/inventory.py b/src/pybind/mgr/cephadm/inventory.py
index 98c9a488078..5cc18b6f485 100644
--- a/src/pybind/mgr/cephadm/inventory.py
+++ b/src/pybind/mgr/cephadm/inventory.py
@@ -1045,6 +1045,18 @@ class HostCache():
)
]
+ def is_host_unreachable(self, hostname: str) -> bool:
+ # take hostname and return if it matches the hostname of an unreachable host
+ return hostname in [h.hostname for h in self.get_unreachable_hosts()]
+
+ def is_host_schedulable(self, hostname: str) -> bool:
+ # take hostname and return if it matches the hostname of a schedulable host
+ return hostname in [h.hostname for h in self.get_schedulable_hosts()]
+
+ def is_host_draining(self, hostname: str) -> bool:
+ # take hostname and return if it matches the hostname of a draining host
+ return hostname in [h.hostname for h in self.get_draining_hosts()]
+
def get_facts(self, host: str) -> Dict[str, Any]:
return self.facts.get(host, {})
@@ -1294,8 +1306,7 @@ class HostCache():
return True
def all_host_metadata_up_to_date(self) -> bool:
- unreachables = [h.hostname for h in self.get_unreachable_hosts()]
- if [h for h in self.get_hosts() if (not self.host_metadata_up_to_date(h) and h not in unreachables)]:
+ if [h for h in self.get_hosts() if (not self.host_metadata_up_to_date(h) and not self.is_host_unreachable(h))]:
# this function is primarily for telling if it's safe to try and apply a service
# spec. Since offline/maintenance hosts aren't considered in that process anyway
# we don't want to return False if the host without up-to-date metadata is in one