From ff41f5f69d9e0da19b09ba8091ee10d40c78f132 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 25 Jan 2020 16:07:56 -0600 Subject: [PATCH] cephadm: add inspect-image command This has the same output as pull, except that it inspects the copy of the image that is local, and does not do a pull. Signed-off-by: Sage Weil --- src/cephadm/cephadm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 03b551490bc13..c91593d4d7c79 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1552,6 +1552,21 @@ def command_pull(): 'image_id': image_id, }, indent=4, sort_keys=True)) +################################## + +def command_inspect_image(): + # type: () -> int + out, err, ret = call_throws([ + container_path, 'images', '--format', 'json', args.image]) + j = json.loads(out) + if not j: + return -errno.ENOENT + r = { + 'image_id': normalize_container_id(j[0].get('id')), + 'ceph_version': CephContainer(args.image, 'ceph', ['--version']).run(), + } + print(json.dumps(r, indent=4, sort_keys=True)) + return 0 ################################## @@ -2492,6 +2507,10 @@ def _get_parser(): 'pull', help='pull latest image version') parser_pull.set_defaults(func=command_pull) + parser_inspect_image = subparsers.add_parser( + 'inspect-image', help='inspect local container image') + parser_inspect_image.set_defaults(func=command_inspect_image) + parser_ls = subparsers.add_parser( 'ls', help='list daemon instances on this host') parser_ls.set_defaults(func=command_ls) -- 2.39.5