GNS3/gns3-registry

check.py reports duplicate image filenames

Closed this issue · 3 comments

Currently check.py reports an error in cisco-asav.gns3a and juniper-vrr.gns3a, that they contain duplicate image filenames. After reporting this error check.py stops testing further appliances.

$ python3 check.py
=> Check appliances
Check danos.gns3a
Check arista-ceos.gns3a
.
.
Check f5-bigip.gns3a
Check cisco-asav.gns3a
Duplicate image filename asav9-16-2.qcow2
$

These duplicate images were allowed by @grossmj in #678 (comment). Maybe check.py should be changed so that this condition won't stop the check.

I made two changes to check.py to allow duplicate filenames, see the enclosed patch:

  • Allow duplicate filenames with different MD5 checksums as used in cisco-asav.gns3a. The change now issues a warning.
  • Allow duplicate filenames with the same MD5 checksum, as used in juniper-vrr.gns3a. If you don't like that modification, remove all changes involving "md5sums".
diff --git a/check.py b/check.py
index 25ce584..411e1d7 100644
--- a/check.py
+++ b/check.py
@@ -71,7 +71,7 @@ def signal_abort(sig, frame):
 def check_appliance(appliance):
     global warnings
     images = {}
-    md5sums = set()
+    md5sums = {}
 
     schemas = {}
     for version in SCHEMA_VERSIONS:
@@ -95,8 +95,9 @@ def check_appliance(appliance):
         for image in appliance_json['images']:
             if image['filename'] in images:
                 print('Duplicate image filename ' + image['filename'])
-                sys.exit(1)
-            if image['md5sum'] in md5sums:
+                warnings += 1
+            if image['md5sum'] in md5sums and \
+               md5sums[image['md5sum']] != image['filename']:
                 print('Duplicate image md5sum ' + image['md5sum'])
                 sys.exit(1)
             versions_found = False
@@ -106,8 +107,8 @@ def check_appliance(appliance):
             if not versions_found:
                 print('Unused image ' + image['filename'] + ' in ' + appliance)
                 warnings += 1
-            images[image['filename']] = image['version']
-            md5sums.add(image['md5sum'])
+            images.setdefault(image['filename'], []).append(image['version'])
+            md5sums[image['md5sum']] = image['filename']
 
         for version in appliance_json['versions']:
             version_match = False
@@ -115,7 +116,7 @@ def check_appliance(appliance):
                 if image not in images:
                     print('Missing relation ' + image + ' in ' + appliance + ' for version ' + version['name'])
                     sys.exit(1)
-                if images[image] == version['name']:
+                if version['name'] in images[image]:
                     version_match = True
             if not version_match:
                 print('Version mismatch for version ' + version['name'] + ' in ' + appliance)

Hi, have you closed this issue because it takes us too long to add your changes? ;)

I think that this issue is not important enough to spend time on it.