Fix rollback op's search call
The pypowervm search call only accepts one input. We need to key off a few (PVID and vswitch id). This change updates the vif rollback code to search appropriately. Change-Id: Ib813fe4b668d208b379ec05cacd1704f60c7abc6 Closes-Bug: 1639235
This commit is contained in:
parent
7a584175e4
commit
75e9992b11
|
@ -785,21 +785,30 @@ class TestVifOvsDriver(test.TestCase):
|
||||||
'br-int', 'tap-dev', 'vif_id', 'aa:bb:cc:dd:ee:ff', self.inst.uuid)
|
'br-int', 'tap-dev', 'vif_id', 'aa:bb:cc:dd:ee:ff', self.inst.uuid)
|
||||||
|
|
||||||
@mock.patch('nova.network.linux_net.delete_ovs_vif_port')
|
@mock.patch('nova.network.linux_net.delete_ovs_vif_port')
|
||||||
@mock.patch('pypowervm.wrappers.network.CNA.search')
|
@mock.patch('pypowervm.wrappers.network.CNA.get')
|
||||||
@mock.patch('pypowervm.tasks.partition.get_this_partition')
|
@mock.patch('pypowervm.tasks.partition.get_this_partition')
|
||||||
@mock.patch('pypowervm.wrappers.network.VSwitch.search')
|
@mock.patch('pypowervm.wrappers.network.VSwitch.search')
|
||||||
def test_rollback_live_migration_at_destination(
|
def test_rollback_live_migration_at_destination(
|
||||||
self, mock_vs_search, mock_get_part, mock_cna_search,
|
self, mock_vs_search, mock_get_part, mock_cna_get,
|
||||||
mock_delete_ovs_port):
|
mock_delete_ovs_port):
|
||||||
# All the fun mocking
|
# All the fun mocking
|
||||||
mock_vs_search.return_value = mock.MagicMock(switch_id=5)
|
mock_vs_search.return_value = mock.MagicMock(switch_id=5)
|
||||||
vea_vlan_mappings = {'aa:bb:cc:dd:ee:ff': 3, 'aa:bb:cc:dd:ee:ee': 4}
|
|
||||||
|
# Since this gets passed through conductor, the VLAN's switch to string
|
||||||
|
# format.
|
||||||
|
vea_vlan_mappings = {'aa:bb:cc:dd:ee:ff': '3',
|
||||||
|
'aa:bb:cc:dd:ee:ee': '4'}
|
||||||
vif = {'devname': 'tap-dev', 'address': 'aa:bb:cc:dd:ee:ee',
|
vif = {'devname': 'tap-dev', 'address': 'aa:bb:cc:dd:ee:ee',
|
||||||
'network': {'bridge': 'br-int'}, 'id': 'vif_id'}
|
'network': {'bridge': 'br-int'}, 'id': 'vif_id'}
|
||||||
mock_get_part.return_value = mock.MagicMock(schema_type='VIO',
|
|
||||||
uuid='uuid')
|
mock_vio = mock.MagicMock(schema_type='VIO', uuid='uuid')
|
||||||
mock_trunk = mock.MagicMock()
|
mock_get_part.return_value = mock_vio
|
||||||
mock_cna_search.return_value = mock_trunk
|
|
||||||
|
trunk1 = mock.Mock(pvid=2, vswitch_id=3, trunk_pri=1)
|
||||||
|
trunk2 = mock.Mock(pvid=3, vswitch_id=5, trunk_pri=1)
|
||||||
|
trunk3 = mock.Mock(pvid=4, vswitch_id=5, trunk_pri=None)
|
||||||
|
trunk4 = mock.Mock(pvid=4, vswitch_id=5, trunk_pri=1)
|
||||||
|
mock_cna_get.return_value = [trunk1, trunk2, trunk3, trunk4]
|
||||||
|
|
||||||
# Invoke
|
# Invoke
|
||||||
self.drv.rollback_live_migration_at_destination(vif, vea_vlan_mappings)
|
self.drv.rollback_live_migration_at_destination(vif, vea_vlan_mappings)
|
||||||
|
@ -808,7 +817,7 @@ class TestVifOvsDriver(test.TestCase):
|
||||||
mock_delete_ovs_port.assert_called_once_with('br-int', 'tap-dev')
|
mock_delete_ovs_port.assert_called_once_with('br-int', 'tap-dev')
|
||||||
|
|
||||||
# Make sure the trunk was deleted
|
# Make sure the trunk was deleted
|
||||||
mock_trunk.delete.assert_called_once()
|
trunk4.delete.assert_called_once()
|
||||||
|
|
||||||
# Now make sure the calls were done correctly to actually produce a
|
# Now make sure the calls were done correctly to actually produce a
|
||||||
# trunk adapter
|
# trunk adapter
|
||||||
|
@ -816,9 +825,8 @@ class TestVifOvsDriver(test.TestCase):
|
||||||
self.drv.adapter, parent_type=pvm_ms.System, one_result=True,
|
self.drv.adapter, parent_type=pvm_ms.System, one_result=True,
|
||||||
name=CONF.powervm.pvm_vswitch_for_novalink_io)
|
name=CONF.powervm.pvm_vswitch_for_novalink_io)
|
||||||
mock_get_part.assert_called_once_with(self.drv.adapter)
|
mock_get_part.assert_called_once_with(self.drv.adapter)
|
||||||
mock_cna_search.assert_called_once_with(
|
mock_cna_get.assert_called_once_with(
|
||||||
self.drv.adapter, parent_type='VIO', parent_uuid='uuid',
|
self.drv.adapter, parent=mock_vio)
|
||||||
vswitch_id=5, pvid=4, one_result=True)
|
|
||||||
|
|
||||||
@mock.patch('nova.network.linux_net.delete_ovs_vif_port')
|
@mock.patch('nova.network.linux_net.delete_ovs_vif_port')
|
||||||
def test_post_live_migrate_at_source(self, mock_delete_ovs_port):
|
def test_post_live_migrate_at_source(self, mock_delete_ovs_port):
|
||||||
|
|
|
@ -789,7 +789,7 @@ class PvmOvsVifDriver(PvmLioVifDriver):
|
||||||
# We know that we just attached the VIF to the NovaLink VM. Search
|
# We know that we just attached the VIF to the NovaLink VM. Search
|
||||||
# for a trunk adapter with the PVID and vSwitch that we specified
|
# for a trunk adapter with the PVID and vSwitch that we specified
|
||||||
# above. This is guaranteed to be unique.
|
# above. This is guaranteed to be unique.
|
||||||
vlan = vea_vlan_mappings[vif['address']]
|
vlan = int(vea_vlan_mappings[vif['address']])
|
||||||
vswitch_id = pvm_net.VSwitch.search(
|
vswitch_id = pvm_net.VSwitch.search(
|
||||||
self.adapter, parent_type=pvm_ms.System, one_result=True,
|
self.adapter, parent_type=pvm_ms.System, one_result=True,
|
||||||
name=CONF.powervm.pvm_vswitch_for_novalink_io).switch_id
|
name=CONF.powervm.pvm_vswitch_for_novalink_io).switch_id
|
||||||
|
@ -800,10 +800,15 @@ class PvmOvsVifDriver(PvmLioVifDriver):
|
||||||
|
|
||||||
# Find the trunk
|
# Find the trunk
|
||||||
mgmt_wrap = pvm_par.get_this_partition(self.adapter)
|
mgmt_wrap = pvm_par.get_this_partition(self.adapter)
|
||||||
trunk = pvm_net.CNA.search(
|
child_adpts = pvm_net.CNA.get(self.adapter, parent=mgmt_wrap)
|
||||||
self.adapter, parent_type=mgmt_wrap.schema_type,
|
trunk = None
|
||||||
parent_uuid=mgmt_wrap.uuid, pvid=vlan, vswitch_id=vswitch_id,
|
for adpt in child_adpts:
|
||||||
one_result=True)
|
# We need a trunk adapter (so check trunk_pri). Then the trunk
|
||||||
|
# is unique by PVID and PowerVM vSwitch ID.
|
||||||
|
if (adpt.pvid == vlan and adpt.vswitch_id == vswitch_id and
|
||||||
|
adpt.trunk_pri):
|
||||||
|
trunk = adpt
|
||||||
|
break
|
||||||
|
|
||||||
if trunk:
|
if trunk:
|
||||||
# Delete the peer'd trunk adapter.
|
# Delete the peer'd trunk adapter.
|
||||||
|
|
Loading…
Reference in New Issue