]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: add inspect-image command
authorSage Weil <sage@redhat.com>
Sat, 25 Jan 2020 22:07:56 +0000 (16:07 -0600)
committerSage Weil <sage@redhat.com>
Mon, 27 Jan 2020 17:30:32 +0000 (11:30 -0600)
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 <sage@redhat.com>
src/cephadm/cephadm

index 03b551490bc131680d352864a63d4d0cb22bea2f..c91593d4d7c7999f521dbe2c1fdd517bddaf68c8 100755 (executable)
@@ -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)