validate_descriptor.py: new option for validate charms 66/7966/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 20 Sep 2019 07:10:52 +0000 (09:10 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 20 Sep 2019 07:14:20 +0000 (09:14 +0200)
Default behaviour is NOT to validate whether the charm is in the folder.
The rationale is that this tool is intended to validate only the descriptor,
not the package. Validating the package requires more aspects to be
taken into account, not only the charm
Moreover, in a CICD for a VNF vendor, charms can be created and tested
independently from the descriptors and only be merged in the same folder
in the last step.

Change-Id: I33aa986493931df463fa8f9d2c6cda2e4be45cf9
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
descriptor-packages/tools/validate_descriptor.py

index 9fe751a..3c6dd41 100755 (executable)
@@ -45,6 +45,7 @@ def usage():
     print("      -v|--version: prints current version")
     print("      -h|--help: shows this help")
     print("      -i|--input FILE: (same as param FILE) descriptor file to be upgraded")
+    print("      -c|--charms: looks for the charms folder and validates its coherency with the descriptor")
     return
 
 
@@ -102,6 +103,7 @@ if __name__ == "__main__":
     input_file_name = None
     test_file = None
     file_name = None
+    validate_charms = False
     try:
         # load parameters and configuration
         opts, args = getopt.getopt(sys.argv[1:], "hvi:o:", ["input=", "help", "version",])
@@ -115,6 +117,8 @@ if __name__ == "__main__":
                 sys.exit()
             elif o in ("-i", "--input"):
                 input_file_name = a
+            elif o in ("-c", "--charms"):
+                validate_charms = True
             else:
                 assert False, "Unhandled option"
         if not input_file_name:
@@ -162,14 +166,14 @@ if __name__ == "__main__":
                             raise KeyError(
                                 "Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'PARAVIRT' instead")
                     # Mrityunjay yadav: Verify charm if included in vdu
-                    if vdu.get("vdu-configuration", False):
+                    if vdu.get("vdu-configuration", False) and validate_charms:
                         validate_charm(vdu["vdu-configuration"], input_file_name)
                 if vnfd.get("mgmt-interface"):
                     mgmt_iface = True
                     if vnfd["mgmt-interface"].get("vdu-id"):
                         raise KeyError("'mgmt-iface': Deprecated 'vdu-id' field. Please, use 'cp' field instead")
                 # Mrityunjay yadav: Verify charm if included in vnf
-                if vnfd.get("vnf-configuration", False):
+                if vnfd.get("vnf-configuration", False) and validate_charms:
                     validate_charm(vnfd["vnf-configuration"], input_file_name)
 
             if not mgmt_iface: