From 4252b617ed5d71cb90a89c8d3ad07a343ce336cb Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Mon, 13 Nov 2017 01:26:47 -0800 Subject: [PATCH] DVS: ensure that network is configured if one of more hosts are down If a host in the cluster is down we should still configure the network. That is, the VC will configure it on the hosts that are up. Change-Id: I8498c92d5e4f81ba5c03631a3edc9631858f22c1 --- vmware_nsx/dvs/dvs_utils.py | 12 +++++++++++- vmware_nsx/plugins/dvs/plugin.py | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/dvs/dvs_utils.py b/vmware_nsx/dvs/dvs_utils.py index 67a5af146c..1840790985 100644 --- a/vmware_nsx/dvs/dvs_utils.py +++ b/vmware_nsx/dvs/dvs_utils.py @@ -14,7 +14,7 @@ from oslo_config import cfg from oslo_vmware import api - +from oslo_vmware import exceptions as oslo_vmware_exc from vmware_nsx._i18n import _ @@ -57,6 +57,16 @@ CONF = cfg.CONF CONF.register_opts(dvs_opts, 'dvs') +# Create and register exceptions not in oslo.vmware +class DvsOperationBulkFault(oslo_vmware_exc.VimException): + msg_fmt = _("Cannot complete a DVS operation for one or more members.") + + +def dvs_register_exceptions(): + oslo_vmware_exc.register_fault_class('DvsOperationBulkFault', + DvsOperationBulkFault) + + def dvs_is_enabled(dvs_id=None): """Returns the configured DVS status.""" return bool(CONF.dvs.host_ip and CONF.dvs.host_username and diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index c3e73cc355..dee88f0096 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -102,6 +102,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, security_group=securitygroup_model.SecurityGroup, security_group_rule=securitygroup_model.SecurityGroupRule) def __init__(self): + dvs_utils.dvs_register_exceptions() self._extension_manager = nsx_managers.ExtensionManager() super(NsxDvsV2, self).__init__() LOG.debug('Driver support: DVS: %s' % dvs_utils.dvs_is_enabled()) @@ -190,7 +191,11 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, dvs_id = dvpg_moref.value else: dvs_id = self._dvs_get_id(net_data) - self._dvs.add_port_group(dvs_id, vlan_tag, trunk_mode=trunk_mode) + try: + self._dvs.add_port_group(dvs_id, vlan_tag, + trunk_mode=trunk_mode) + except dvs_utils.DvsOperationBulkFault: + LOG.warning('One or more hosts may not be configured') try: with db_api.context_manager.writer.using(context):