Remove dead code from get_port_chassis function
The function returned a tuple but the second returned object was always ignored. The patch also deletes redunant unittest. TrivialFix Change-Id: I85b3b9a58c8d07aa6bbce240d22cceccbb8a7588
This commit is contained in:
parent
5238fad375
commit
c5eaef9c55
@ -118,8 +118,6 @@ WITHDRAW = "withdraw"
|
||||
OVN_REQUESTED_CHASSIS = "requested-chassis"
|
||||
OVN_STATUS_CHASSIS = "hosting-chassis"
|
||||
OVN_HOST_ID_EXT_ID_KEY = "neutron:host_id"
|
||||
OVN_CHASSIS_AT_OPTIONS = "options"
|
||||
OVN_CHASSIS_AT_EXT_IDS = "external-ids"
|
||||
|
||||
# Exposing method names
|
||||
EXPOSE_METHOD_UNDERLAY = 'underlay'
|
||||
|
@ -50,7 +50,7 @@ def get_port_chassis(port, chassis,
|
||||
# if that is the case, please supply a default in the arguments.
|
||||
|
||||
port_type = getattr(port, 'type', default_port_type)
|
||||
if (port_type not in [constants.OVN_VIRTUAL_VIF_PORT_TYPE] and
|
||||
if (port_type != constants.OVN_VIRTUAL_VIF_PORT_TYPE and
|
||||
hasattr(port, 'options') and
|
||||
port.options.get(constants.OVN_REQUESTED_CHASSIS)):
|
||||
|
||||
@ -59,19 +59,13 @@ def get_port_chassis(port, chassis,
|
||||
# to do a == equal comparison
|
||||
req_chassis = port.options[constants.OVN_REQUESTED_CHASSIS]
|
||||
if chassis in req_chassis.split(','):
|
||||
req_chassis = chassis
|
||||
return chassis
|
||||
|
||||
return req_chassis.split(',')[0], constants.OVN_CHASSIS_AT_OPTIONS
|
||||
return req_chassis.split(',')[0]
|
||||
|
||||
elif (hasattr(port, 'external_ids') and
|
||||
port.external_ids.get(constants.OVN_HOST_ID_EXT_ID_KEY)):
|
||||
|
||||
return (
|
||||
port.external_ids[constants.OVN_HOST_ID_EXT_ID_KEY],
|
||||
constants.OVN_CHASSIS_AT_EXT_IDS
|
||||
)
|
||||
|
||||
return None, None
|
||||
return port.external_ids[constants.OVN_HOST_ID_EXT_ID_KEY]
|
||||
|
||||
|
||||
def check_name_prefix(entity, prefix):
|
||||
|
@ -437,7 +437,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
||||
ports = []
|
||||
cmd = self.db_find_rows('Logical_Switch_Port', ('up', '=', True))
|
||||
for row in cmd.execute(check_error=True):
|
||||
port_chassis, _ = driver_utils.get_port_chassis(row, chassis)
|
||||
port_chassis = driver_utils.get_port_chassis(row, chassis)
|
||||
if port_chassis == chassis:
|
||||
ports.append(row)
|
||||
|
||||
|
@ -52,7 +52,7 @@ class LogicalSwitchPortProviderCreateEvent(base_watcher.LSPChassisEvent):
|
||||
if not self._check_ip_associated(row.addresses[0]):
|
||||
return False
|
||||
|
||||
current_chassis, _ = self._get_chassis(row)
|
||||
current_chassis = self._get_chassis(row)
|
||||
logical_switch = self._get_network(row)
|
||||
|
||||
if logical_switch in self.agent.ovn_local_lrps:
|
||||
@ -119,7 +119,7 @@ class LogicalSwitchPortProviderDeleteEvent(base_watcher.LSPChassisEvent):
|
||||
if event == self.ROW_DELETE:
|
||||
return True
|
||||
|
||||
current_chassis, _ = self._get_chassis(row)
|
||||
current_chassis = self._get_chassis(row)
|
||||
# Delete the port from current chassis, if
|
||||
# 1. port went down (while only attached here)
|
||||
if (hasattr(old, 'up') and bool(old.up[0]) and # port was up
|
||||
@ -183,7 +183,7 @@ class LogicalSwitchPortFIPCreateEvent(base_watcher.LSPChassisEvent):
|
||||
if not self._check_ip_associated(row.addresses[0]):
|
||||
return False
|
||||
|
||||
current_chassis, _ = self._get_chassis(row)
|
||||
current_chassis = self._get_chassis(row)
|
||||
current_port_fip = row.external_ids.get(
|
||||
constants.OVN_FIP_EXT_ID_KEY)
|
||||
if (current_chassis != self.agent.chassis or
|
||||
@ -291,7 +291,7 @@ class LogicalSwitchPortFIPDeleteEvent(base_watcher.LSPChassisEvent):
|
||||
return True
|
||||
|
||||
# If we reach here, just check if host changed
|
||||
current_chassis, _ = self._get_chassis(row)
|
||||
current_chassis = self._get_chassis(row)
|
||||
return current_chassis != self.agent.chassis
|
||||
|
||||
except (IndexError, AttributeError):
|
||||
|
@ -77,7 +77,7 @@ class TestDriverUtils(test_base.TestCase):
|
||||
options={constants.OVN_REQUESTED_CHASSIS: my_host})
|
||||
|
||||
self.assertEqual(driver_utils.get_port_chassis(row, chassis=my_host),
|
||||
(my_host, constants.OVN_CHASSIS_AT_OPTIONS))
|
||||
my_host)
|
||||
|
||||
def test_get_port_chassis_from_external_ids(self):
|
||||
my_host = 'foo-host'
|
||||
@ -87,7 +87,7 @@ class TestDriverUtils(test_base.TestCase):
|
||||
external_ids={constants.OVN_HOST_ID_EXT_ID_KEY: my_host})
|
||||
|
||||
self.assertEqual(driver_utils.get_port_chassis(row, chassis=my_host),
|
||||
(my_host, constants.OVN_CHASSIS_AT_EXT_IDS))
|
||||
my_host)
|
||||
|
||||
def test_get_port_chassis_from_external_ids_virtual_port(self):
|
||||
my_host = 'foo-host'
|
||||
@ -99,12 +99,12 @@ class TestDriverUtils(test_base.TestCase):
|
||||
type=constants.OVN_VIRTUAL_VIF_PORT_TYPE)
|
||||
|
||||
self.assertEqual(driver_utils.get_port_chassis(row, chassis=my_host),
|
||||
(my_host, constants.OVN_CHASSIS_AT_EXT_IDS))
|
||||
my_host)
|
||||
|
||||
def test_get_port_chassis_no_information(self):
|
||||
row = utils.create_row()
|
||||
self.assertEqual(driver_utils.get_port_chassis(row, chassis='foo'),
|
||||
(None, None))
|
||||
None)
|
||||
|
||||
def test_check_name_prefix(self):
|
||||
lb = utils.create_row(name='some-name')
|
||||
|
@ -130,51 +130,6 @@ class TestLSPChassisEvent(test_base.TestCase):
|
||||
self.assertTrue(self.lsp_event._check_ip_associated(
|
||||
'aa:bb:cc:dd:ee:ff 10.10.1.16 10.10.1.17 10.10.1.18'))
|
||||
|
||||
def test__check_chassis_from_options(self):
|
||||
my_host = 'foo-host'
|
||||
|
||||
# it is a VM port type, should use options field.
|
||||
row = utils.create_row(
|
||||
external_ids={constants.OVN_HOST_ID_EXT_ID_KEY: 'bar-host'},
|
||||
options={constants.OVN_REQUESTED_CHASSIS: my_host})
|
||||
|
||||
self.assertEqual(self.lsp_event._get_chassis(row),
|
||||
(my_host, constants.OVN_CHASSIS_AT_OPTIONS))
|
||||
|
||||
def test__check_chassis_from_external_ids(self):
|
||||
my_host = 'foo-host'
|
||||
|
||||
# it is a VM port type, should use options field.
|
||||
row = utils.create_row(
|
||||
external_ids={constants.OVN_HOST_ID_EXT_ID_KEY: my_host})
|
||||
|
||||
self.assertEqual(self.lsp_event._get_chassis(row),
|
||||
(my_host, constants.OVN_CHASSIS_AT_EXT_IDS))
|
||||
|
||||
def test__check_chassis_from_external_ids_virtual_port(self):
|
||||
my_host = 'foo-host'
|
||||
|
||||
# it is a VM port type, should use options field.
|
||||
row = utils.create_row(
|
||||
external_ids={constants.OVN_HOST_ID_EXT_ID_KEY: my_host},
|
||||
options={constants.OVN_REQUESTED_CHASSIS: 'bar-host'},
|
||||
type=constants.OVN_VIRTUAL_VIF_PORT_TYPE)
|
||||
|
||||
self.assertEqual(self.lsp_event._get_chassis(row),
|
||||
(my_host, constants.OVN_CHASSIS_AT_EXT_IDS))
|
||||
|
||||
def test__check_chassis_no_information(self):
|
||||
row = utils.create_row()
|
||||
self.assertEqual(self.lsp_event._get_chassis(row),
|
||||
(None, None))
|
||||
|
||||
def test__check_chassis_no_information_virtual_port(self):
|
||||
row = utils.create_row(
|
||||
options={constants.OVN_REQUESTED_CHASSIS: 'bar-host'},
|
||||
type=constants.OVN_VIRTUAL_VIF_PORT_TYPE)
|
||||
self.assertEqual(self.lsp_event._get_chassis(row),
|
||||
(None, None))
|
||||
|
||||
def test__has_additional_binding(self):
|
||||
row = utils.create_row(
|
||||
options={constants.OVN_REQUESTED_CHASSIS: 'host1,host2'})
|
||||
|
Loading…
Reference in New Issue
Block a user