diff options
author | Jeff Layton <jlayton@redhat.com> | 2018-10-31 18:42:56 +0100 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2018-11-15 13:21:15 +0100 |
commit | 1c0b172a2c0f6fc3aa364376744cc2518014bd72 (patch) | |
tree | 8e69823f2e595bdd6799aa671aeccfa2b03552f6 /src/pybind/mgr/rook/rook_cluster.py | |
parent | orchestrator: rework describe_service prototype to allow for nodename (diff) | |
download | ceph-1c0b172a2c0f6fc3aa364376744cc2518014bd72.tar.xz ceph-1c0b172a2c0f6fc3aa364376744cc2518014bd72.zip |
orchestrator/rook: rework describe_service() to accomodate "service ls"
Rework the describe_service operation for rook to allow listing of
services, with optional filters for service type, id and nodename.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/rook/rook_cluster.py | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index ff2b90ceb18..ccd2bcb6bb8 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -125,7 +125,7 @@ class RookCluster(object): return nodename_to_devices - def describe_pods(self, service_type, service_id): + def describe_pods(self, service_type, service_id, nodename): # Go query the k8s API about deployment, containers related to this # filesystem @@ -143,25 +143,32 @@ class RookCluster(object): # Label filter is rook_cluster=<cluster name> # rook_file_system=<self.fs_name> - label_filter = "rook_cluster={0},app=rook-ceph-{1}".format( - self.cluster_name, service_type) - if service_type == "mds": - label_filter += ",rook_file_system={0}".format(service_id) - elif service_type == "osd": - # Label added in https://github.com/rook/rook/pull/1698 - label_filter += ",ceph-osd-id={0}".format(service_id) - elif service_type == "mon": - # label like mon=rook-ceph-mon0 - label_filter += ",mon={0}".format(service_id) - elif service_type == "mgr": - label_filter += ",mgr={0}".format(service_id) - elif service_type == "rgw": - # TODO: rgw - pass + label_filter = "rook_cluster={0}".format(self.cluster_name) + if service_type != None: + label_filter += ",app=rook-ceph-{0}".format(service_type) + if service_id != None: + if service_type == "mds": + label_filter += ",rook_file_system={0}".format(service_id) + elif service_type == "osd": + # Label added in https://github.com/rook/rook/pull/1698 + label_filter += ",ceph-osd-id={0}".format(service_id) + elif service_type == "mon": + # label like mon=rook-ceph-mon0 + label_filter += ",mon={0}".format(service_id) + elif service_type == "mgr": + label_filter += ",mgr={0}".format(service_id) + elif service_type == "rgw": + # TODO: rgw + pass + + field_filter = "" + if nodename != None: + field_filter = "spec.nodeName={0}".format(nodename); pods = self.k8s.list_namespaced_pod( self.rook_namespace, - label_selector=label_filter) + label_selector=label_filter, + field_selector=field_filter) # import json # print json.dumps(pods.items[0]) |