[OVN] Method `get_port_qos
` should always return 2 values
The method ``neutron.agent.ovn.agent.ovsdb.get_port_qos`` should always return 2 values, even when the LSP is not present. This patch: * fixes the output, returning 2 values * catches the exception raised when the LSP is not present in the OVN NB database * returns the default max_kbps and min_kbps values (0, 0). Closes-Bug: #2009804 Change-Id: I03ea78fcc5825e35c07dda1aa790769aa918dd8a
This commit is contained in:
parent
50dc9dd243
commit
bffa642b35
neutron
@ -160,9 +160,12 @@ def get_port_qos(nb_idl, port_id):
|
||||
this method is only returning the egress one. The min-bw rule is only
|
||||
implemented for egress traffic.
|
||||
"""
|
||||
lsp = nb_idl.lsp_get(port_id).execute(check_error=True)
|
||||
if not lsp:
|
||||
return {}
|
||||
try:
|
||||
lsp = nb_idl.lsp_get(port_id).execute(check_error=True)
|
||||
except idlutils.RowNotFound:
|
||||
# If the LSP is not present, we can't retrieve any QoS info. The
|
||||
# default values are (0, 0).
|
||||
return 0, 0
|
||||
|
||||
net_name = lsp.external_ids[ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY]
|
||||
ls = nb_idl.lookup('Logical_Switch', net_name)
|
||||
|
@ -69,9 +69,17 @@ class GetPortQosTestCase(base.TestOVNFunctionalBase):
|
||||
max_kbps, min_kbps = agent_ovsdb.get_port_qos(self.nb_api, lsp.name)
|
||||
self.assertEqual((max_qos_value, 0), (max_kbps, min_kbps))
|
||||
|
||||
# Remove the max-bw rukle
|
||||
# Remove the max-bw rule
|
||||
ext_ids = {ovn_const.OVN_PORT_EXT_ID_KEY: lsp_name}
|
||||
self.nb_api.qos_del_ext_ids(
|
||||
network_name, ext_ids).execute(check_error=True)
|
||||
max_kbps, min_kbps = agent_ovsdb.get_port_qos(self.nb_api, lsp.name)
|
||||
self.assertEqual((0, 0), (max_kbps, min_kbps))
|
||||
|
||||
# Remove the port, the default values returned by the method are (0, 0)
|
||||
lsp_name = lsp.name
|
||||
self.nb_api.lsp_del(lsp_name).execute(check_error=True)
|
||||
lsp = self.nb_api.lookup('Logical_Switch_Port', lsp_name, default=None)
|
||||
self.assertIsNone(lsp)
|
||||
max_kbps, min_kbps = agent_ovsdb.get_port_qos(self.nb_api, lsp_name)
|
||||
self.assertEqual((0, 0), (max_kbps, min_kbps))
|
||||
|
Loading…
x
Reference in New Issue
Block a user