]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: fix image_id normalization
authorSage Weil <sage@redhat.com>
Wed, 22 Jan 2020 22:46:05 +0000 (16:46 -0600)
committerSage Weil <sage@redhat.com>
Wed, 22 Jan 2020 22:46:05 +0000 (16:46 -0600)
Remove sha256: prefix from id (hash), not name.

Signed-off-by: Sage Weil <sage@redhat.com>
src/cephadm/cephadm

index c6736972f93481aa6da326657be4b7f3e40cace6..df53bb5364f62e39f265e5ac8cedca01a7da1eba 100755 (executable)
@@ -608,6 +608,16 @@ def generate_password():
     return ''.join(random.choice(string.ascii_lowercase + string.digits)
                    for i in range(10))
 
+def normalize_container_id(i):
+    # docker adds the sha256: prefix, but AFAICS both
+    # docker (18.09.7 in bionic at least) and podman
+    # both always use sha256, so leave off the prefix
+    # for consistency.
+    prefix = 'sha256:'
+    if i.startswith(prefix):
+        i = i[len(prefix):]
+    return i
+
 def make_fsid():
     # type: () -> str
     return str(uuid.uuid1())
@@ -2188,13 +2198,7 @@ def list_daemons(detail=True, legacy_dir=None):
                             verbose_on_failure=False)
                         if not code:
                             (container_id, image_name, image_id) = out.strip().split(',')
-                            # docker adds the sha256: prefix, but AFAICS both
-                            # docker (18.09.7 in bionic at least) and podman
-                            # both always use sha256, so leave off the prefix
-                            # for consistency.
-                            prefix = 'sha256:'
-                            if image_name.startswith(prefix):
-                                image_name = image_name[len(prefix):]
+                            image_id = normalize_container_id(image_id)
                             out, err, code = call(
                                 [container_path, 'exec', container_id,
                                  'ceph', '-v'])