From 3543aeb84cfc3d7b8e9874cc70dad4d96cfefaf8 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 25 Mar 2020 13:12:46 +0100 Subject: [PATCH] mgr/orch: Add `ceph orch ls --export` * defaults to `--format yaml` * don't include `status` ``` $ ceph orch ls --export placement: host_pattern: '*' service_name: crash service_type: crash ``` Signed-off-by: Sebastian Wagner --- doc/mgr/orchestrator.rst | 19 +++++++++++++++---- src/pybind/mgr/orchestrator/module.py | 12 ++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/doc/mgr/orchestrator.rst b/doc/mgr/orchestrator.rst index 2f66d0484e2..5741808bf42 100644 --- a/doc/mgr/orchestrator.rst +++ b/doc/mgr/orchestrator.rst @@ -206,18 +206,29 @@ services of a particular type via optional --type parameter :: - ceph orch ps - ceph orch service ls [--host host] [--svc_type type] [--refresh] + ceph orch ls [--service_type type] [--service_name name] [--export] [--format f] [--refresh] Discover the status of a particular service or daemons:: - ceph orch service ls --svc_type type --svc_id [--refresh] + ceph orch ls --service_type type --service_name [--refresh] + +Export the service specs known to the orchestrator as yaml in format +that is compatible to ``ceph orch apply -i``:: + + ceph orch ls --export + +Daemon Status +============= +Print a list of all daemons known to the orchestrator:: + + ceph orch ps [--hostname host] [--daemon_type type] [--service_name name] [--daemon_id id] [--format f] [--refresh] + Query the status of a particular service instance (mon, osd, mds, rgw). For OSDs the id is the numeric OSD ID, for MDS services it is the file system name:: - ceph orch daemon status  [--refresh] + ceph orch ps --daemon_type osd --daemon_id 0 .. _orchestrator-cli-cephfs: diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index b023f3d6d3b..60d84386d13 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -327,10 +327,15 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): 'orch ls', "name=service_type,type=CephString,req=false " "name=service_name,type=CephString,req=false " + "name=export,type=CephBool,req=false " "name=format,type=CephChoices,strings=plain|json|json-pretty|yaml,req=false " "name=refresh,type=CephBool,req=false", 'List services known to orchestrator') - def _list_services(self, host=None, service_type=None, service_name=None, format='plain', refresh=False): + def _list_services(self, host=None, service_type=None, service_name=None, export=False, format='plain', refresh=False): + + if export and format == 'plain': + format = 'yaml' + completion = self.describe_service(service_type, service_name, refresh=refresh) @@ -347,7 +352,10 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): if len(services) == 0: return HandleCommandResult(stdout="No services reported") elif format != 'plain': - data = [s.to_json() for s in services] + if export: + data = [s.spec.to_json() for s in services] + else: + data = [s.to_json() for s in services] return HandleCommandResult(stdout=to_format(data, format)) else: now = datetime.datetime.utcnow() -- 2.39.5