Fix SR-IOV qos extension calls to clear_rate functions.

New public functions are added to ESwitchManager class,
'clear_max_rate' and 'clear_min_tx_rate', instead of using
'_clear_rate' exposing the rate_type parameter. This
rate_type parameter could change in future releases only
modifying the Embedded Switch Manager.

Change-Id: Ib7046c87f3480ba8859d2d472fe154f1e3466d1b
Closes-Bug: 1621461
This commit is contained in:
Rodolfo Alonso Hernandez 2016-09-08 13:46:01 +01:00
parent 80c1a6b981
commit 13808567ab
2 changed files with 37 additions and 3 deletions

View File

@ -384,8 +384,26 @@ class ESwitchManager(object):
embedded_switch = None
return embedded_switch
def clear_rate(self, pci_slot, rate_type):
"""Clear the VF rate
def clear_max_rate(self, pci_slot):
"""Clear the VF "rate" parameter
Clear the "rate" configuration from VF by setting it to 0.
@param pci_slot: VF PCI slot
"""
self._clear_rate(pci_slot,
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_RATE)
def clear_min_tx_rate(self, pci_slot):
"""Clear the VF "min_tx_rate" parameter
Clear the "min_tx_rate" configuration from VF by setting it to 0.
@param pci_slot: VF PCI slot
"""
self._clear_rate(pci_slot,
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_MIN_TX_RATE)
def _clear_rate(self, pci_slot, rate_type):
"""Clear the VF rate parameter specified in rate_type
Clear the rate configuration from VF by setting it to 0.
@param pci_slot: VF PCI slot

View File

@ -245,6 +245,22 @@ class TestESwitchManagerApi(base.BaseTestCase):
'device_mac': self.WRONG_MAC})
self.assertFalse(result)
def test_clear_max_rate(self):
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.agent.'
'eswitch_manager.ESwitchManager._clear_rate') \
as clear_rate_mock:
self.eswitch_mgr.clear_max_rate(self.PCI_SLOT)
clear_rate_mock.assert_called_once_with(self.PCI_SLOT,
self.MAX_RATE)
def test_clear_min_tx_rate(self):
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.agent.'
'eswitch_manager.ESwitchManager._clear_rate') \
as clear_rate_mock:
self.eswitch_mgr.clear_min_tx_rate(self.PCI_SLOT)
clear_rate_mock.assert_called_once_with(self.PCI_SLOT,
self.MIN_RATE)
def _test_clear_rate(self, rate_type, pci_slot, passed, mac_address):
with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.agent.'
'eswitch_manager.EmbSwitch.set_device_rate') \
@ -252,7 +268,7 @@ class TestESwitchManagerApi(base.BaseTestCase):
mock.patch('neutron.plugins.ml2.drivers.mech_sriov.agent.'
'pci_lib.PciDeviceIPWrapper.get_assigned_macs',
return_value=mac_address):
self.eswitch_mgr.clear_rate(pci_slot, rate_type)
self.eswitch_mgr._clear_rate(pci_slot, rate_type)
if passed:
set_rate_mock.assert_called_once_with(pci_slot, rate_type, 0)
else: