Physical network not included in vif details

SR-IOV mechanism driver in networking_powervm/plugins/ml2/drivers/
mech_pvm_sriov.PvmSRIOVMechanismDriver does not include
'physical network' in the custom vif details. Method
customize_vif_details prepares a dictionary like this :
{'redundancy': 1, 'physical_ports': [u'U78C9.001.WZS05TG-P1-C5-T1'],
'vlan': '2200', 'port_filter': False, 'capacity': 0.02}
It does not include physical_network.
This is not a bug, but SR-IOV vif plug mechanism in
nova_powervm/virt/powervm/vif.PvmVnicSriovVifDriver.plug can use
physical_network value to calculate physical ports in migration
scenario (future work in nova_powervm).

Above mentioned plug mechanism currently uses get_physical_network method
in nova/network/model.VIF class. This method expects physical_network in
custom vif details prepared by mechanism driver.

This patchset fixes this by adding physical_network to vif details by
getting it from network segment.

Unit tests added.

Change-Id: I379c9deceb72e4d5ea17891120d065230578d59e
Closes-Bug: #1651129
Sridhar Venkat 6 years ago
parent a5f5fccdc0
commit e64928fd16

@ -67,6 +67,7 @@ class PvmSRIOVMechanismDriver(mech_pvm_base.PvmMechanismDriverBase):
context, segment, agent))
vif_details['physical_ports'] = self.get_mappings(agent).get(
segment['physical_network'], [])
vif_details['physical_network'] = segment['physical_network']
profile = context.current.get(portbindings.PROFILE, {})
# TODO(efried): binding:profile info is not in the 'profile' var!
# Redundancy: from binding:profile or the ml2 conf.

@ -167,6 +167,7 @@ class TestPvmSriovMechDriver(BaseTestPvmMechDriver):
# No profile in context, mismatched network in segment
self.segment['physical_network'] = 'bogus_net'
vif_dets = self.verify_vif_details()
self.assertEqual('bogus_net', vif_dets['physical_network'])
# No ports
self.assertEqual([], vif_dets['physical_ports'])
# default_redundancy from agent config
@ -178,6 +179,7 @@ class TestPvmSriovMechDriver(BaseTestPvmMechDriver):
self.agent['configurations']['default_capacity'] = '0.04'
vif_dets = self.verify_vif_details()
self.assertEqual(0.04, vif_dets['capacity'])
self.assertEqual('bogus_net', vif_dets['physical_network'])
# Now with proper values set in profile & segment
self.segment['physical_network'] = 'the_other_network'
@ -187,3 +189,4 @@ class TestPvmSriovMechDriver(BaseTestPvmMechDriver):
self.assertEqual(['p3', 'p4'], vif_dets['physical_ports'])
self.assertEqual(10, vif_dets['redundancy'])
self.assertEqual(0.16, vif_dets['capacity'])
self.assertEqual('the_other_network', vif_dets['physical_network'])