From 7003b46ad480d0fc50e6b543a7c48bb328698998 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 2 Jan 2017 12:36:41 +0200 Subject: [PATCH] NSX-V| Validate default policy configuration if use_nsx_policies When use_nsx_policies=true, the default policy must be defined Change-Id: Ie847642d78b059e285e9f6b28a63cdd390d79b36 --- vmware_nsx/plugins/nsx_v/plugin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 01af22716f..33c5629418 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -3678,8 +3678,13 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, for res in az_resources: inventory.append((res, 'availability_zones')) - if cfg.CONF.nsxv.default_policy_id: - inventory.append((cfg.CONF.nsxv.default_policy_id, 'policy')) + if cfg.CONF.nsxv.use_nsx_policies: + # if use_nsx_policies=True, the default policy must be defined + if not cfg.CONF.nsxv.default_policy_id: + error = _("default_policy_id must be defined") + raise nsx_exc.NsxPluginException(err_msg=error) + inventory.append((cfg.CONF.nsxv.default_policy_id, + 'default_policy_id')) for moref, field in inventory: if moref and not self.nsx_v.vcns.validate_inventory(moref):