VMware: make the opaque network attachment more robust
Ensure that the correct network ID is used when attaching the instance to the opaque network. Change-Id: I6bd615370075d44232d28f5ecebc34c08075daec Closes-bug: #1549288 Depends-On: Iea09105912f2a8d8766f02e71b45163e233a0eac
This commit is contained in:
parent
c4763d46fe
commit
9ca37ab19c
|
@ -250,6 +250,25 @@ class VMwareVifTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(expected_ref, network_ref)
|
||||
mock_check.assert_called_once_with('fake-session')
|
||||
|
||||
@mock.patch.object(vif, '_check_ovs_supported_version')
|
||||
def test_get_neutron_network_ovs_logical_switch_id(self, mock_check):
|
||||
vif_info = network_model.NetworkInfo([
|
||||
network_model.VIF(type=network_model.VIF_TYPE_OVS,
|
||||
address='DE:AD:BE:EF:00:00',
|
||||
network=self._network,
|
||||
details={'nsx-logical-switch-id':
|
||||
'fake-nsx-id'})]
|
||||
)[0]
|
||||
network_ref = vif._get_neutron_network('fake-session',
|
||||
'fake-cluster',
|
||||
vif_info)
|
||||
expected_ref = {'type': 'OpaqueNetwork',
|
||||
'network-id': 'fake-nsx-id',
|
||||
'network-type': 'nsx.LogicalSwitch',
|
||||
'use-external-id': True}
|
||||
self.assertEqual(expected_ref, network_ref)
|
||||
mock_check.assert_called_once_with('fake-session')
|
||||
|
||||
@mock.patch.object(network_util, 'get_network_with_the_name')
|
||||
def test_get_neutron_network_dvs(self, mock_network_name):
|
||||
fake_network_obj = {'type': 'DistributedVirtualPortgroup',
|
||||
|
|
|
@ -21,7 +21,7 @@ from oslo_utils import versionutils
|
|||
from oslo_vmware import vim_util
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _, _LW
|
||||
from nova.i18n import _, _LI, _LW
|
||||
from nova.network import model
|
||||
from nova.virt.vmwareapi import constants
|
||||
from nova.virt.vmwareapi import network_util
|
||||
|
@ -124,7 +124,18 @@ def _get_neutron_network(session, cluster, vif):
|
|||
use_external_id = False
|
||||
network_type = 'opaque'
|
||||
else:
|
||||
net_id = vif['network']['id']
|
||||
# The NSX|V3 plugin will pass the nsx-logical-switch-id as part
|
||||
# of the port details. This will enable the VC to connect to
|
||||
# that specific opaque network
|
||||
net_id = (vif.get('details') and
|
||||
vif['details'].get('nsx-logical-switch-id'))
|
||||
if not net_id:
|
||||
# Make use of the original one, in the event that the
|
||||
# plugin does not pass the aforementioned id
|
||||
LOG.info(_LI('NSX Logical switch ID is not present. '
|
||||
'Using network ID to attach to the '
|
||||
'opaque network.'))
|
||||
net_id = vif['network']['id']
|
||||
use_external_id = True
|
||||
network_type = 'nsx.LogicalSwitch'
|
||||
network_ref = {'type': 'OpaqueNetwork',
|
||||
|
|
Loading…
Reference in New Issue