Merge "QoS SR-IOV: allow to reset vf rate when VF is assigend to VM"

This commit is contained in:
Jenkins
2015-10-12 13:53:14 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 2 deletions

View File

@@ -47,7 +47,11 @@ class QosSRIOVAgentDriver(qos.QosAgentDriver):
def delete_bandwidth_limit(self, port):
pci_slot = port['profile'].get('pci_slot')
if port.get('device_owner') is None:
self.eswitch_mgr.clear_max_rate(pci_slot)
else:
device = port['device']
self._set_vf_max_rate(device, pci_slot)
def _set_vf_max_rate(self, device, pci_slot, max_kbps=0):
if self.eswitch_mgr.device_exists(device, pci_slot):

View File

@@ -85,7 +85,13 @@ class QosSRIOVAgentDriverTestCase(base.BaseTestCase):
self.max_rate_mock.assert_called_once_with(
self.ASSIGNED_MAC, self.PCI_SLOT, self.rule.max_kbps)
def test_delete_rules(self):
def test_delete_rules_on_assigned_vf(self):
self.qos_driver.delete(self.port, self.qos_policy)
self.max_rate_mock.assert_called_once_with(
self.ASSIGNED_MAC, self.PCI_SLOT, 0)
def test_delete_rules_on_released_vf(self):
del self.port['device_owner']
self.qos_driver.delete(self.port, self.qos_policy)
self.clear_max_rate_mock.assert_called_once_with(self.PCI_SLOT)