From 0122679331d414bbf72c32be188b2d62d187f351 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 17 Dec 2019 07:22:48 -0600 Subject: [PATCH] cephadm: return 'cephadm pull' result as JSON Signed-off-by: Sage Weil --- src/cephadm/cephadm | 5 ++++- src/pybind/mgr/cephadm/module.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index e32b4731f21..c1faf5103c3 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1530,7 +1530,10 @@ def command_pull(): '--format', '{{.Id}}', args.image]) ver = CephContainer(args.image, 'ceph', ['--version']).run() - print(out.strip() + ',' + ver) + print(json.dumps({ + 'ceph_version': ver, + 'image_id': out.strip(), + }, indent=4, sort_keys=True)) ################################## diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index ddf88133d3d..c6be640aadc 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1528,7 +1528,9 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): host, None, 'pull', [], image=image_name, no_fsid=True) - (image_id, ceph_version) = out[0].split(',', 1) + j = json.loads('\n'.join(out)) + image_id = j.get('image_id') + ceph_version = j.get('ceph_version') self.log.debug('image %s -> id %s version %s' % (image_name, image_id, ceph_version)) return image_id, ceph_version -- 2.39.5