Change set_device_rate calls according to new signature

[1] changed the signature of set_device_rate to be alligned with how
pyroute2 expects rate parameters, some method which calls
set_device_rate needs to be changed also to use the new dict format for
calling it.

[1]: https://review.opendev.org/q/Ibbb6d938355440c42850812e368224b76b1fce19

Related-Bug: #1962844
Closes-Bug: #1968206
Change-Id: I7256747f45308b011edbb0f8c802439ea277423d
This commit is contained in:
elajkat 2022-04-08 09:29:14 +02:00
parent bcdabad1c8
commit 837fda7566
2 changed files with 7 additions and 6 deletions

View File

@ -381,7 +381,7 @@ class ESwitchManager(object):
embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
if embedded_switch:
embedded_switch.set_device_rate(
pci_slot, IP_LINK_CAPABILITY_RATE, max_kbps)
pci_slot, {IP_LINK_CAPABILITY_RATE: max_kbps})
def set_device_min_tx_rate(self, device_mac, pci_slot, min_kbps):
"""Set device min_tx_rate
@ -394,7 +394,7 @@ class ESwitchManager(object):
embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
if embedded_switch:
embedded_switch.set_device_rate(
pci_slot, IP_LINK_CAPABILITY_MIN_TX_RATE, min_kbps)
pci_slot, {IP_LINK_CAPABILITY_MIN_TX_RATE: min_kbps})
def set_device_state(self, device_mac, pci_slot, admin_state_up,
propagate_uplink_state):
@ -540,7 +540,7 @@ class ESwitchManager(object):
# NOTE(Moshe Levi): check the pci_slot is not assigned to some
# other port before resetting the rate.
if embedded_switch.get_pci_device(pci_slot) is None:
embedded_switch.set_device_rate(pci_slot, rate_type, 0)
embedded_switch.set_device_rate(pci_slot, {rate_type: 0})
else:
LOG.warning("VF with PCI slot %(pci_slot)s is already "
"assigned; skipping reset for '%(rate_type)s' "

View File

@ -215,7 +215,7 @@ class TestESwitchManagerApi(base.BaseTestCase):
self.PCI_SLOT, 1000)
get_pci_mock.assert_called_once_with(self.PCI_SLOT)
set_device_rate_mock.assert_called_once_with(
self.PCI_SLOT, self.MAX_RATE, 1000)
self.PCI_SLOT, {self.MAX_RATE: 1000})
def test_set_device_min_tx_rate(self):
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
@ -228,7 +228,7 @@ class TestESwitchManagerApi(base.BaseTestCase):
self.PCI_SLOT, 1000)
get_pci_mock.assert_called_once_with(self.PCI_SLOT)
set_device_rate_mock.assert_called_once_with(
self.PCI_SLOT, self.MIN_RATE, 1000)
self.PCI_SLOT, {self.MIN_RATE: 1000})
def test_set_device_status_mismatch(self):
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
@ -335,7 +335,8 @@ class TestESwitchManagerApi(base.BaseTestCase):
return_value=True):
self.eswitch_mgr._clear_rate(pci_slot, rate_type)
if passed:
set_rate_mock.assert_called_once_with(pci_slot, rate_type, 0)
set_rate_mock.assert_called_once_with(pci_slot,
{rate_type: 0})
else:
self.assertFalse(set_rate_mock.called)