Adding validations to upgrade and validate scripts(VDU-ID and OM-MGT) 20/6420/1
authorgcalvino <guillermo.calvinosanchez@altran.com>
Wed, 27 Jun 2018 09:02:43 +0000 (11:02 +0200)
committergcalvino <guillermo.calvinosanchez@altran.com>
Fri, 17 Aug 2018 11:26:02 +0000 (13:26 +0200)
Signed-off-by: gcalvino <guillermo.calvinosanchez@altran.com>
descriptor-packages/tools/upgrade_descriptor_version.py
descriptor-packages/tools/validate_descriptor.py

index 66bdbb1..7db1ec6 100755 (executable)
@@ -135,8 +135,23 @@ if __name__=="__main__":
                 vnfd_list = vnfd_descriptor["vnfd"]
                 mgmt_iface = False
                 for vnfd in vnfd_list:
+                    vdu_list = vnfd["vdu"]
+                    for vdu in vdu_list:
+                        interface_list = []
+                        external_interface_list = vdu.pop("external-interface", ())
+                        for external_interface in external_interface_list:
+                            if external_interface.get("virtual-interface", {}).get("type") == "OM-MGMT":
+                                raise KeyError(
+                                    "Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'VIRTIO' instead")
+                        interface_list = vdu.pop("interface", ())
+                        for interface in interface_list:
+                            if interface.get("virtual-interface", {}).get("type") == "OM-MGMT":
+                                raise KeyError(
+                                    "Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'VIRTIO' instead")
                     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")
                 if not mgmt_iface:
                     raise KeyError("'mgmt-iface' is a mandatory field and it is not defined")
                 myvnfd = vnfd_catalog.vnfd()
index d2888c3..010ba16 100755 (executable)
@@ -119,8 +119,23 @@ if __name__=="__main__":
             vnfd_list = vnfd_descriptor["vnfd"]
             mgmt_iface = False
             for vnfd in vnfd_list:
+                vdu_list = vnfd["vdu"]
+                for vdu in vdu_list:
+                    interface_list = []
+                    external_interface_list = vdu.pop("external-interface", ())
+                    for external_interface in external_interface_list:
+                        if external_interface.get("virtual-interface", {}).get("type") == "OM-MGMT":
+                            raise KeyError(
+                                "Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'VIRTIO' instead")
+                    interface_list = vdu.pop("interface", ())
+                    for interface in interface_list:
+                        if interface.get("virtual-interface", {}).get("type") == "OM-MGMT":
+                            raise KeyError(
+                                "Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'VIRTIO' instead")
                 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")
             if not mgmt_iface:
                 raise KeyError("'mgmt-iface' is a mandatory field and it is not defined")
             myvnfd = vnfd_catalog.vnfd()