From 21a77bf417629904b31a9202d2f7bbe28c38b395 Mon Sep 17 00:00:00 2001 From: Michal Kelner Mishali Date: Sun, 23 Dec 2018 12:58:20 +0200 Subject: [PATCH] DVS: Adding proper error message when missing net provider data When the user doesn't indicate Network provider information, an error message should be presented. Change-Id: I4e6b235465b46265e1cc084dfa14b8dbba6282c0 Signed-off-by: Michal Kelner Mishali --- vmware_nsx/plugins/dvs/plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index 80ef96be89..ad9b79b384 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -254,6 +254,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, def _validate_network(self, context, net_data): network_type = net_data.get(pnet.NETWORK_TYPE) + network_type_set = validators.is_attr_set(network_type) segmentation_id = net_data.get(pnet.SEGMENTATION_ID) segmentation_id_set = validators.is_attr_set(segmentation_id) if not context.is_admin: @@ -261,6 +262,10 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, "network") raise n_exc.InvalidInput(error_message=err_msg) err_msg = None + if not network_type_set: + err_msg = _("Network provider information must be " + "specified") + raise n_exc.InvalidInput(error_message=err_msg) if (network_type == c_utils.NetworkTypes.FLAT or network_type == c_utils.NetworkTypes.PORTGROUP): if segmentation_id_set: