From 8bc90dcf25e7daefc206b963ecc1d8cd4d822121 Mon Sep 17 00:00:00 2001 From: gcalvino Date: Wed, 27 Jun 2018 11:02:43 +0200 Subject: [PATCH] Adding validations to upgrade and validate scripts(VDU-ID and OM-MGT) Signed-off-by: gcalvino --- .../tools/upgrade_descriptor_version.py | 15 +++++++++++++++ descriptor-packages/tools/validate_descriptor.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/descriptor-packages/tools/upgrade_descriptor_version.py b/descriptor-packages/tools/upgrade_descriptor_version.py index 66bdbb18..7db1ec6f 100755 --- a/descriptor-packages/tools/upgrade_descriptor_version.py +++ b/descriptor-packages/tools/upgrade_descriptor_version.py @@ -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() diff --git a/descriptor-packages/tools/validate_descriptor.py b/descriptor-packages/tools/validate_descriptor.py index d2888c30..010ba16f 100755 --- a/descriptor-packages/tools/validate_descriptor.py +++ b/descriptor-packages/tools/validate_descriptor.py @@ -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() -- 2.25.1