Skip to content

Commit 480bd3f

Browse files
elajkatralonsoh
authored andcommitted
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 (cherry picked from commit 837fda7)
1 parent baded9b commit 480bd3f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def set_device_max_rate(self, device_mac, pci_slot, max_kbps):
381381
embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
382382
if embedded_switch:
383383
embedded_switch.set_device_rate(
384-
pci_slot, IP_LINK_CAPABILITY_RATE, max_kbps)
384+
pci_slot, {IP_LINK_CAPABILITY_RATE: max_kbps})
385385

386386
def set_device_min_tx_rate(self, device_mac, pci_slot, min_kbps):
387387
"""Set device min_tx_rate
@@ -394,7 +394,7 @@ def set_device_min_tx_rate(self, device_mac, pci_slot, min_kbps):
394394
embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
395395
if embedded_switch:
396396
embedded_switch.set_device_rate(
397-
pci_slot, IP_LINK_CAPABILITY_MIN_TX_RATE, min_kbps)
397+
pci_slot, {IP_LINK_CAPABILITY_MIN_TX_RATE: min_kbps})
398398

399399
def set_device_state(self, device_mac, pci_slot, admin_state_up,
400400
propagate_uplink_state):
@@ -540,7 +540,7 @@ def _clear_rate(self, pci_slot, rate_type):
540540
# NOTE(Moshe Levi): check the pci_slot is not assigned to some
541541
# other port before resetting the rate.
542542
if embedded_switch.get_pci_device(pci_slot) is None:
543-
embedded_switch.set_device_rate(pci_slot, rate_type, 0)
543+
embedded_switch.set_device_rate(pci_slot, {rate_type: 0})
544544
else:
545545
LOG.warning("VF with PCI slot %(pci_slot)s is already "
546546
"assigned; skipping reset for '%(rate_type)s' "

neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_set_device_max_rate(self):
215215
self.PCI_SLOT, 1000)
216216
get_pci_mock.assert_called_once_with(self.PCI_SLOT)
217217
set_device_rate_mock.assert_called_once_with(
218-
self.PCI_SLOT, self.MAX_RATE, 1000)
218+
self.PCI_SLOT, {self.MAX_RATE: 1000})
219219

220220
def test_set_device_min_tx_rate(self):
221221
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
@@ -228,7 +228,7 @@ def test_set_device_min_tx_rate(self):
228228
self.PCI_SLOT, 1000)
229229
get_pci_mock.assert_called_once_with(self.PCI_SLOT)
230230
set_device_rate_mock.assert_called_once_with(
231-
self.PCI_SLOT, self.MIN_RATE, 1000)
231+
self.PCI_SLOT, {self.MIN_RATE: 1000})
232232

233233
def test_set_device_status_mismatch(self):
234234
with mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent."
@@ -335,7 +335,8 @@ def _test_clear_rate(self, rate_type, pci_slot, passed, mac_address):
335335
return_value=True):
336336
self.eswitch_mgr._clear_rate(pci_slot, rate_type)
337337
if passed:
338-
set_rate_mock.assert_called_once_with(pci_slot, rate_type, 0)
338+
set_rate_mock.assert_called_once_with(pci_slot,
339+
{rate_type: 0})
339340
else:
340341
self.assertFalse(set_rate_mock.called)
341342

0 commit comments

Comments
 (0)