8568: Enhance image_hash parsing when using Docker 1.10+
authorradhika <radhika@curoverse.com>
Tue, 26 Jul 2016 20:23:14 +0000 (16:23 -0400)
committerradhika <radhika@curoverse.com>
Tue, 26 Jul 2016 20:23:14 +0000 (16:23 -0400)
sdk/python/arvados/commands/keepdocker.py

index e8ce2ee21d6299dfb9cf4082d105b2d9a439757f..9310f066219ae3063153e4a4393ecba771b7c6ff 100644 (file)
@@ -399,7 +399,12 @@ def main(arguments=None, stdout=sys.stdout):
     # Read the image metadata and make Arvados links from it.
     image_file.seek(0)
     image_tar = tarfile.open(fileobj=image_file)
-    json_file = image_tar.extractfile(image_tar.getmember(image_hash + '/json'))
+    image_hash_type, _, raw_image_hash = image_hash.rpartition(':')
+    if image_hash_type:
+        json_filename = raw_image_hash + '.json'
+    else:
+        json_filename = raw_image_hash + '/json'
+    json_file = image_tar.extractfile(image_tar.getmember(json_filename))
     image_metadata = json.load(json_file)
     json_file.close()
     image_tar.close()