NSX|V: Fix init connectivity validation
1. Make the validation optional (If False - only log the warnings) 2. Validate each resource against all clusters and fail only if not connected to any Change-Id: I9abd091fc42d4dbe22e1b806df4d9131ab054726
This commit is contained in:
parent
8329e8e6c5
commit
22060b7b37
|
@ -851,6 +851,10 @@ nsxv_opts = [
|
||||||
default='%(name)s (%(id)s)',
|
default='%(name)s (%(id)s)',
|
||||||
help=_("(Optional) Format for the NSX name of an openstack "
|
help=_("(Optional) Format for the NSX name of an openstack "
|
||||||
"security group")),
|
"security group")),
|
||||||
|
cfg.BoolOpt('init_validation',
|
||||||
|
default=True,
|
||||||
|
help=_("Set to False to skip plugin init validation")),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# define the configuration of each NSX-V availability zone.
|
# define the configuration of each NSX-V availability zone.
|
||||||
|
|
|
@ -230,6 +230,9 @@ class NsxVAvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
||||||
self.dvs_id, self.external_network, self.mgt_net_moid)
|
self.dvs_id, self.external_network, self.mgt_net_moid)
|
||||||
|
|
||||||
# Look for each configured cluster
|
# Look for each configured cluster
|
||||||
|
ext_net_connected = False
|
||||||
|
mgt_net_connected = False
|
||||||
|
dvs_connected = False
|
||||||
for configured_cluster in cfg.CONF.nsxv.cluster_moid:
|
for configured_cluster in cfg.CONF.nsxv.cluster_moid:
|
||||||
found_cluster = False
|
found_cluster = False
|
||||||
for cluster_info in info['clustersInfo']:
|
for cluster_info in info['clustersInfo']:
|
||||||
|
@ -242,17 +245,8 @@ class NsxVAvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
||||||
external_net_portgroup = self._validate_opt_connectivity(
|
external_net_portgroup = self._validate_opt_connectivity(
|
||||||
cluster_info, 'distributedVirtualPortGroups',
|
cluster_info, 'distributedVirtualPortGroups',
|
||||||
self.external_network)
|
self.external_network)
|
||||||
if (not external_net_standard and
|
if external_net_standard or external_net_portgroup:
|
||||||
not external_net_portgroup):
|
ext_net_connected = True
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
|
||||||
opt_name='external_network',
|
|
||||||
opt_value=self.external_network,
|
|
||||||
reason=(_("Edge cluster %(ec)s in not connected "
|
|
||||||
"to external network %(val)s in AZ "
|
|
||||||
"%(az)s") % {
|
|
||||||
'ec': configured_cluster,
|
|
||||||
'val': self.external_network,
|
|
||||||
'az': self.name}))
|
|
||||||
|
|
||||||
# Validate mgt_net_moid
|
# Validate mgt_net_moid
|
||||||
if self.mgt_net_moid:
|
if self.mgt_net_moid:
|
||||||
|
@ -262,39 +256,68 @@ class NsxVAvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
||||||
mgt_net_portgroup = self._validate_opt_connectivity(
|
mgt_net_portgroup = self._validate_opt_connectivity(
|
||||||
cluster_info, 'distributedVirtualPortGroups',
|
cluster_info, 'distributedVirtualPortGroups',
|
||||||
self.mgt_net_moid)
|
self.mgt_net_moid)
|
||||||
if not mgt_net_standard and not mgt_net_portgroup:
|
if mgt_net_standard or mgt_net_portgroup:
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
mgt_net_connected = True
|
||||||
opt_name='mgt_net_moid',
|
|
||||||
opt_value=self.mgt_net_moid,
|
|
||||||
reason=(_("Edge cluster %(ec)s in not "
|
|
||||||
"connected to mgt_net_moid %(val)s "
|
|
||||||
"in AZ %(az)s") % {
|
|
||||||
'ec': configured_cluster,
|
|
||||||
'val': self.mgt_net_moid,
|
|
||||||
'az': self.name}))
|
|
||||||
|
|
||||||
# Validate DVS
|
# Validate DVS
|
||||||
if self.dvs_id and not self._validate_opt_connectivity(
|
if self.dvs_id and self._validate_opt_connectivity(
|
||||||
cluster_info, 'distributedVirtualSwitches',
|
cluster_info, 'distributedVirtualSwitches',
|
||||||
self.dvs_id):
|
self.dvs_id):
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
dvs_connected = True
|
||||||
opt_name='dvs_id', opt_value=self.dvs_id,
|
|
||||||
reason=(_("Edge cluster %(ec)s in not connected "
|
|
||||||
"to dvs_id %(val)s in AZ %(az)s") % {
|
|
||||||
'ec': configured_cluster,
|
|
||||||
'val': self.dvs_id,
|
|
||||||
'az': self.name}))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# Didn't find the edge cluster
|
# Didn't find the edge cluster
|
||||||
if not found_cluster:
|
if not found_cluster:
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
reason = (_("Edge cluster %(ec)s is not connected "
|
||||||
opt_name='vdn_scope_id', opt_value=self.vdn_scope_id,
|
|
||||||
reason=(_("Edge cluster %(ec)s in not connected "
|
|
||||||
"to vdn_scope_id %(val)s in AZ %(az)s") % {
|
"to vdn_scope_id %(val)s in AZ %(az)s") % {
|
||||||
'ec': configured_cluster,
|
'ec': configured_cluster,
|
||||||
'val': self.vdn_scope_id,
|
'val': self.vdn_scope_id,
|
||||||
'az': self.name}))
|
'az': self.name})
|
||||||
|
if cfg.CONF.nsxv.init_validation:
|
||||||
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
|
opt_name='vdn_scope_id', opt_value=self.vdn_scope_id,
|
||||||
|
reason=reason)
|
||||||
|
LOG.warning(reason)
|
||||||
|
|
||||||
|
if self.external_network and not ext_net_connected:
|
||||||
|
reason = (_("Edge cluster %(ec)s is not connected "
|
||||||
|
"to external network %(val)s in AZ "
|
||||||
|
"%(az)s") % {
|
||||||
|
'ec': cfg.CONF.nsxv.cluster_moid,
|
||||||
|
'val': self.external_network,
|
||||||
|
'az': self.name})
|
||||||
|
if cfg.CONF.nsxv.init_validation:
|
||||||
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
|
opt_name='external_network',
|
||||||
|
opt_value=self.external_network,
|
||||||
|
reason=reason)
|
||||||
|
LOG.warning(reason)
|
||||||
|
|
||||||
|
if self.mgt_net_moid and not mgt_net_connected:
|
||||||
|
reason = (_("Edge cluster %(ec)s is not "
|
||||||
|
"connected to mgt_net_moid %(val)s "
|
||||||
|
"in AZ %(az)s") % {
|
||||||
|
'ec': cfg.CONF.nsxv.cluster_moid,
|
||||||
|
'val': self.mgt_net_moid,
|
||||||
|
'az': self.name})
|
||||||
|
if cfg.CONF.nsxv.init_validation:
|
||||||
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
|
opt_name='mgt_net_moid',
|
||||||
|
opt_value=self.mgt_net_moid,
|
||||||
|
reason=reason)
|
||||||
|
LOG.warning(reason)
|
||||||
|
|
||||||
|
if self.dvs_id and not dvs_connected:
|
||||||
|
reason = (_("Edge cluster %(ec)s is not connected "
|
||||||
|
"to dvs_id %(val)s in AZ %(az)s") % {
|
||||||
|
'ec': cfg.CONF.nsxv.cluster_moid,
|
||||||
|
'val': self.dvs_id,
|
||||||
|
'az': self.name})
|
||||||
|
if cfg.CONF.nsxv.init_validation:
|
||||||
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
|
opt_name='dvs_id', opt_value=self.dvs_id,
|
||||||
|
reason=reason)
|
||||||
|
LOG.warning(reason)
|
||||||
|
|
||||||
|
|
||||||
class NsxVAvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
class NsxVAvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
||||||
|
|
|
@ -5082,7 +5082,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||||
edge_utils.validate_vdr_transit_network()
|
edge_utils.validate_vdr_transit_network()
|
||||||
|
|
||||||
# Validate configuration connectivity per AZ
|
# Validate configuration connectivity per AZ
|
||||||
self._availability_zones_data.validate_connectivity(self.nsx_v.vcns)
|
self._availability_zones_data.validate_connectivity(
|
||||||
|
self.nsx_v.vcns)
|
||||||
|
|
||||||
def _nsx_policy_is_hidden(self, policy):
|
def _nsx_policy_is_hidden(self, policy):
|
||||||
for attrib in policy.get('extendedAttributes', []):
|
for attrib in policy.get('extendedAttributes', []):
|
||||||
|
|
Loading…
Reference in New Issue