From 53ad85ac35d8b24089cee292848c0f28bb2582ab Mon Sep 17 00:00:00 2001 From: Shachar Snapiri Date: Wed, 25 Jul 2018 18:37:12 +0300 Subject: [PATCH] Rename ovs_port throughout the code As the notation of ovs_port is not relevant any more, rename it throughout the code to switch_port which is the new class. Change-Id: I1eb1ff4d10265c7a64f38d158ddb6c7186eba06e Partial-Bug: #1781376 --- dragonflow/controller/apps/chassis_snat.py | 6 +- dragonflow/controller/apps/classifier.py | 22 +-- .../controller/apps/metadata_service.py | 12 +- dragonflow/controller/apps/provider.py | 8 +- dragonflow/controller/df_local_controller.py | 7 +- dragonflow/controller/topology.py | 126 +++++++++--------- dragonflow/switch/drivers/df_ovs_driver.py | 4 +- dragonflow/tests/common/utils.py | 2 +- dragonflow/tests/fullstack/test_portqos.py | 6 +- dragonflow/tests/unit/test_app_base.py | 8 +- dragonflow/tests/unit/test_classifier_app.py | 24 ++-- dragonflow/tests/unit/test_dnat_app.py | 7 +- .../tests/unit/test_metadata_service_app.py | 8 +- dragonflow/tests/unit/test_topology.py | 26 ++-- 14 files changed, 133 insertions(+), 133 deletions(-) diff --git a/dragonflow/controller/apps/chassis_snat.py b/dragonflow/controller/apps/chassis_snat.py index aed261754..01a9ef9fe 100644 --- a/dragonflow/controller/apps/chassis_snat.py +++ b/dragonflow/controller/apps/chassis_snat.py @@ -84,12 +84,12 @@ class ChassisSNATApp(df_base_app.DFlowApp, snat_mixin.SNATApp_mixin): @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED) @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED) - def ovs_port_updated(self, ovs_port, orig_ovs_port=None): - if ovs_port.name != self.external_network_bridge: + def switch_port_updated(self, switch_port, orig_switch_port=None): + if switch_port.name != self.external_network_bridge: return LOG.debug("Ex. Bridge port update is called ... ") - mac = ovs_port.mac_in_use + mac = switch_port.mac_in_use if mac in (None, const.EMPTY_MAC, self.external_bridge_mac): return diff --git a/dragonflow/controller/apps/classifier.py b/dragonflow/controller/apps/classifier.py index 4c6b6a716..ec19f826f 100644 --- a/dragonflow/controller/apps/classifier.py +++ b/dragonflow/controller/apps/classifier.py @@ -42,18 +42,19 @@ class ClassifierApp(df_base_app.DFlowApp): switch.SwitchPort, model_constants.EVENT_CREATED) @df_base_app.register_event( switch.SwitchPort, model_constants.EVENT_UPDATED) - def _ovs_port_created(self, ovs_port, orig_ovs_port=None): - port_num = ovs_port.port_num - lport_ref = ovs_port.lport + def _switch_port_created(self, switch_port, orig_switch_port=None): + port_num = switch_port.port_num + lport_ref = switch_port.lport if not lport_ref: return # Not relevant - if orig_ovs_port and orig_ovs_port.port_num != port_num: - self._ovs_port_deleted(ovs_port) + if orig_switch_port and orig_switch_port.port_num != port_num: + self._switch_port_deleted(switch_port) if not port_num or port_num == -1: return # Not ready yet, or error lport = self.nb_api.get(lport_ref) - self._ofport_unique_key_map[ovs_port.id] = (port_num, lport.unique_key) - LOG.info("Add local ovs port %(ovs_port)s, logical port " + self._ofport_unique_key_map[switch_port.id] = ( + port_num, lport.unique_key) + LOG.info("Add local ovs port %(switch_port)s, logical port " "%(lport)s for classification", {'switch_port': port_num, 'lport': lport}) self._make_ingress_classification_flow(lport, port_num) @@ -102,11 +103,12 @@ class ClassifierApp(df_base_app.DFlowApp): @df_base_app.register_event( switch.SwitchPort, model_constants.EVENT_DELETED) - def _ovs_port_deleted(self, ovs_port): + def _switch_port_deleted(self, switch_port): try: - port_num, port_key = self._ofport_unique_key_map.pop(ovs_port.id) + port_num, port_key = self._ofport_unique_key_map.pop( + switch_port.id) except KeyError: - # OvsPort not present in lookup, was either not added, or removed + # Port not present in lookup, was either not added, or removed # by a previous update. In both cases irrelevant. return self._del_ingress_dispatch_flow(port_key) diff --git a/dragonflow/controller/apps/metadata_service.py b/dragonflow/controller/apps/metadata_service.py index ccb73b09f..c8bb6025b 100644 --- a/dragonflow/controller/apps/metadata_service.py +++ b/dragonflow/controller/apps/metadata_service.py @@ -68,12 +68,12 @@ class MetadataServiceApp(df_base_app.DFlowApp): @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED) @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED) - def ovs_port_updated(self, ovs_port, orig_ovs_port=None): - if ovs_port.name != cfg.CONF.df_metadata.metadata_interface: + def switch_port_updated(self, switch_port, orig_switch_port=None): + if switch_port.name != cfg.CONF.df_metadata.metadata_interface: return - port_num = ovs_port.port_num - mac = ovs_port.mac_in_use + port_num = switch_port.port_num + mac = switch_port.mac_in_use if not port_num or not mac: return @@ -88,8 +88,8 @@ class MetadataServiceApp(df_base_app.DFlowApp): self._interface_mac = mac @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_DELETED) - def ovs_port_deleted(self, ovs_port): - if ovs_port.name != cfg.CONF.df_metadata.metadata_interface: + def switch_port_deleted(self, switch_port): + if switch_port.name != cfg.CONF.df_metadata.metadata_interface: return self._remove_metadata_interface_flows() diff --git a/dragonflow/controller/apps/provider.py b/dragonflow/controller/apps/provider.py index f98e0e49e..45ea0b343 100644 --- a/dragonflow/controller/apps/provider.py +++ b/dragonflow/controller/apps/provider.py @@ -82,12 +82,12 @@ class ProviderApp(df_base_app.DFlowApp): @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED) @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED) - def _bridge_updated(self, ovsport, orig_ovsport=None): - self._update_bridge_mac(ovsport.name, ovsport.mac_in_use) + def _bridge_updated(self, switch_port, orig_switch_port=None): + self._update_bridge_mac(switch_port.name, switch_port.mac_in_use) @df_base_app.register_event(switch.SwitchPort, model_const.EVENT_DELETED) - def _bridge_deleted(self, ovsport): - self._update_bridge_mac(ovsport.name, None) + def _bridge_deleted(self, switch_port): + self._update_bridge_mac(switch_port.name, None) def _update_bridge_mac(self, bridge, mac): if bridge not in self.bridge_macs: diff --git a/dragonflow/controller/df_local_controller.py b/dragonflow/controller/df_local_controller.py index 1a49dfe00..8840cfcb0 100644 --- a/dragonflow/controller/df_local_controller.py +++ b/dragonflow/controller/df_local_controller.py @@ -125,8 +125,6 @@ class DfLocalController(object): ignore_models = self.switch_backend.sync_ignore_models() for model in model_framework.iter_models_by_dependency_order(): # FIXME (dimak) generalize sync to support non-northbound models - # Adding OvsPort will cause sync to delete all OVS ports - # periodically if model not in ignore_models: self._sync.add_model(model) @@ -257,10 +255,9 @@ class DfLocalController(object): def get_chassis_name(self): return self.chassis_name - # TODO(snapiri): We should not have ovs here # TODO(snapiri): This should be part of the interface - def notify_port_status(self, ovs_port, status): - self.switch_backend.notify_port_status(ovs_port, status) + def notify_port_status(self, switch_port, status): + self.switch_backend.notify_port_status(switch_port, status) def _get_delete_handler(self, table): method_name = 'delete_{0}'.format(table) diff --git a/dragonflow/controller/topology.py b/dragonflow/controller/topology.py index be6dac8c9..7731d3424 100644 --- a/dragonflow/controller/topology.py +++ b/dragonflow/controller/topology.py @@ -50,85 +50,85 @@ class Topology(object): self.db_store = db_store.get_instance() # TODO(snapiri) this should not be ovs specific - switch.SwitchPort.register_created(self.ovs_port_updated) - switch.SwitchPort.register_updated(self.ovs_port_updated) - switch.SwitchPort.register_deleted(self.ovs_port_deleted) + switch.SwitchPort.register_created(self.switch_port_updated) + switch.SwitchPort.register_updated(self.switch_port_updated) + switch.SwitchPort.register_deleted(self.switch_port_deleted) - def ovs_port_updated(self, ovs_port, orig_ovs_port=None): + def switch_port_updated(self, switch_port, orig_switch_port=None): """ Changes in ovs port status will be monitored by ovsdb monitor thread and notified to topology. This method is the entry port to process port online/update event - @param ovs_port: + @param switch_port: @return : None """ - LOG.info("Ovs port updated: %s", ovs_port) + LOG.info("Ovs port updated: %s", switch_port) - if ovs_port.type not in _SWITCH_PORT_TYPES: - LOG.info("Unmanaged port online: %s", ovs_port) + if switch_port.type not in _SWITCH_PORT_TYPES: + LOG.info("Unmanaged port online: %s", switch_port) return try: - if orig_ovs_port is None: - self._handle_ovs_port_added(ovs_port) + if orig_switch_port is None: + self._handle_switch_port_added(switch_port) else: - self._handle_ovs_port_updated(ovs_port) + self._handle_switch_port_updated(switch_port) except Exception: LOG.exception( "Exception occurred when handling port online event") - def _handle_ovs_port_added(self, ovs_port): - port_type = ovs_port.type + def _handle_switch_port_added(self, switch_port): + port_type = switch_port.type if port_type == constants.SWITCH_COMPUTE_INTERFACE: - self._compute_port_added(ovs_port) + self._compute_port_added(switch_port) elif port_type == constants.SWITCH_TUNNEL_INTERFACE: - self._tunnel_port_added(ovs_port) + self._tunnel_port_added(switch_port) else: - LOG.warning('Invalid port type on %r', ovs_port) + LOG.warning('Invalid port type on %r', switch_port) - def _handle_ovs_port_updated(self, ovs_port): - port_type = ovs_port.type + def _handle_switch_port_updated(self, switch_port): + port_type = switch_port.type if port_type == constants.SWITCH_COMPUTE_INTERFACE: - self._compute_port_updated(ovs_port) + self._compute_port_updated(switch_port) elif port_type == constants.SWITCH_TUNNEL_INTERFACE: - self._tunnel_port_updated(ovs_port) + self._tunnel_port_updated(switch_port) else: - LOG.warning('Invalid port type on %r', ovs_port) + LOG.warning('Invalid port type on %r', switch_port) - def ovs_port_deleted(self, ovs_port): + def switch_port_deleted(self, switch_port): """ Changes in ovs port status will be monitored by ovsdb monitor thread and notified to topology. This method is the entrance port to process port offline event - @param ovs_port: + @param switch_port: @return : None """ - if ovs_port.type not in _SWITCH_PORT_TYPES: - LOG.info("Unmanaged port offline: %s", ovs_port) + if switch_port.type not in _SWITCH_PORT_TYPES: + LOG.info("Unmanaged port offline: %s", switch_port) return try: - self._handle_ovs_port_deleted(ovs_port) + self._handle_switch_port_deleted(switch_port) except Exception: LOG.exception("Exception occurred when handling " "ovs port offline event") - def _handle_ovs_port_deleted(self, ovs_port): - port_type = ovs_port.type + def _handle_switch_port_deleted(self, switch_port): + port_type = switch_port.type if port_type == constants.SWITCH_COMPUTE_INTERFACE: - self._compute_port_deleted(ovs_port) + self._compute_port_deleted(switch_port) elif port_type == constants.SWITCH_TUNNEL_INTERFACE: - self._tunnel_port_deleted(ovs_port) + self._tunnel_port_deleted(switch_port) else: - LOG.warning('Invalid port type on %r', ovs_port) + LOG.warning('Invalid port type on %r', switch_port) - def _tunnel_port_added(self, ovs_port): - self._tunnel_port_updated(ovs_port) + def _tunnel_port_added(self, switch_port): + self._tunnel_port_updated(switch_port) - def _process_ovs_tunnel_port(self, ovs_port, action): - tunnel_type = ovs_port.tunnel_type + def _process_ovs_tunnel_port(self, switch_port, action): + tunnel_type = switch_port.tunnel_type if not tunnel_type: return @@ -155,29 +155,29 @@ class Topology(object): "when %(action)s tunnel %(lport)s", {'action': action, 'lport': lport}) - def _tunnel_port_updated(self, ovs_port): - self._process_ovs_tunnel_port(ovs_port, "set") + def _tunnel_port_updated(self, switch_port): + self._process_ovs_tunnel_port(switch_port, "set") - def _tunnel_port_deleted(self, ovs_port): - self._process_ovs_tunnel_port(ovs_port, "delete") + def _tunnel_port_deleted(self, switch_port): + self._process_ovs_tunnel_port(switch_port, "delete") - def _compute_port_added(self, ovs_port): - self._compute_port_updated(ovs_port) + def _compute_port_added(self, switch_port): + self._compute_port_updated(switch_port) self.controller.notify_port_status( - ovs_port, n_const.PORT_STATUS_ACTIVE) + switch_port, n_const.PORT_STATUS_ACTIVE) - def _compute_port_updated(self, ovs_port): - lport = self._get_lport(ovs_port) + def _compute_port_updated(self, switch_port): + lport = self._get_lport(switch_port) if lport is None: LOG.warning("No logical port found for ovs port: %s", - ovs_port) + switch_port) return topic = lport.topic if not topic: return self._add_to_topic_subscribed(topic, lport.id) - self.ovs_to_lport_mapping[ovs_port.id] = OvsLportMapping( + self.ovs_to_lport_mapping[switch_port.id] = OvsLportMapping( lport_id=lport.id, topic=topic) chassis = lport.binding.chassis @@ -192,7 +192,7 @@ class Topology(object): status=migration.MIGRATION_STATUS_DEST_PLUG)) return - cached_lport = ovs_port.lport.get_object() + cached_lport = switch_port.lport.get_object() if not cached_lport: # If the logical port is not in db store it has not been applied # to dragonflow apps. We need to update it in dragonflow controller @@ -203,16 +203,16 @@ class Topology(object): LOG.exception('Failed to process logical port online ' 'event: %s', lport) - def _compute_port_deleted(self, ovs_port): - ovs_port_id = ovs_port.id - lport_ref = ovs_port.lport + def _compute_port_deleted(self, switch_port): + switch_port_id = switch_port.id + lport_ref = switch_port.lport lport = lport_ref.get_object() if lport is None: - lport_mapping = self.ovs_to_lport_mapping.get(ovs_port_id) + lport_mapping = self.ovs_to_lport_mapping.get(switch_port_id) if lport_mapping is None: return topic = lport_mapping.topic - del self.ovs_to_lport_mapping[ovs_port_id] + del self.ovs_to_lport_mapping[switch_port_id] self._del_from_topic_subscribed(topic, lport_mapping.lport_id) return @@ -226,7 +226,7 @@ class Topology(object): lport_ref.id) finally: self.controller.notify_port_status( - ovs_port, n_const.PORT_STATUS_DOWN) + switch_port, n_const.PORT_STATUS_DOWN) migration_obj = self.nb_api.get( migration.Migration(id=lport_ref.id)) @@ -236,7 +236,7 @@ class Topology(object): migration_obj.status = migration.MIGRATION_STATUS_SRC_UNPLUG self.nb_api.update(migration_obj) - del self.ovs_to_lport_mapping[ovs_port_id] + del self.ovs_to_lport_mapping[switch_port_id] self._del_from_topic_subscribed(topic, lport_ref.id) def _add_to_topic_subscribed(self, topic, lport_id): @@ -271,12 +271,12 @@ class Topology(object): # set, which represents no topic is subscribed now. return set(self.topic_subscribed) - def _get_lport(self, ovs_port): - if not ovs_port.lport: + def _get_lport(self, switch_port): + if not switch_port.lport: return None - lport = ovs_port.lport.get_object() + lport = switch_port.lport.get_object() if lport is None: - lport = self.nb_api.get(ovs_port.lport) + lport = self.nb_api.get(switch_port.lport) return lport def check_topology_info(self): @@ -289,13 +289,13 @@ class Topology(object): new_ovs_to_lport_mapping = {} add_ovs_to_lport_mapping = {} delete_ovs_to_lport_mapping = self.ovs_to_lport_mapping - for ovs_port in self.db_store.get_all(switch.SwitchPort): - key = ovs_port.id - if ovs_port.type == constants.SWITCH_COMPUTE_INTERFACE: - lport = self._get_lport(ovs_port) + for switch_port in self.db_store.get_all(switch.SwitchPort): + key = switch_port.id + if switch_port.type == constants.SWITCH_COMPUTE_INTERFACE: + lport = self._get_lport(switch_port) if lport is None: LOG.warning("No logical port found for ovs port: %s", - ovs_port) + switch_port) continue topic = lport.topic if not topic: diff --git a/dragonflow/switch/drivers/df_ovs_driver.py b/dragonflow/switch/drivers/df_ovs_driver.py index 479b739f9..1d8b3477d 100644 --- a/dragonflow/switch/drivers/df_ovs_driver.py +++ b/dragonflow/switch/drivers/df_ovs_driver.py @@ -81,10 +81,10 @@ class DfOvsDriver(df_switch_driver.DfSwitchDriver): def sync_ignore_models(self): return [switch.SwitchPort, ] - def notify_port_status(self, ovs_port, status): + def notify_port_status(self, switch_port, status): if self.neutron_notifier: table_name = l2.LogicalPort.table_name - iface_id = ovs_port.lport + iface_id = switch_port.lport self.neutron_notifier.notify_neutron_server(table_name, iface_id, 'update', status) diff --git a/dragonflow/tests/common/utils.py b/dragonflow/tests/common/utils.py index 93545ac1e..30d4c663b 100644 --- a/dragonflow/tests/common/utils.py +++ b/dragonflow/tests/common/utils.py @@ -169,7 +169,7 @@ class OvsTestApi(vswitch_impl.OvsApi): continue return interface['external_ids'].get('iface-id') - def get_ovs_port_by_id_with_specified_columns( + def get_switch_port_by_id_with_specified_columns( self, port_id, specified_columns): port_name = self._get_port_name_by_id(port_id) if not port_name: diff --git a/dragonflow/tests/fullstack/test_portqos.py b/dragonflow/tests/fullstack/test_portqos.py index cea974d03..b69bf2d6c 100644 --- a/dragonflow/tests/fullstack/test_portqos.py +++ b/dragonflow/tests/fullstack/test_portqos.py @@ -77,10 +77,10 @@ class TestPortQos(test_base.DFTestBase): self.assertIsNotNone(qos) self.assertEqual(qos['queues'][0].uuid, queue['_uuid']) - ovs_port = self.vswitch_api.get_ovs_port_by_id_with_specified_columns( + port = self.vswitch_api.get_switch_port_by_id_with_specified_columns( vm_port_id, {'qos'}) - self.assertIsNotNone(ovs_port) - self.assertEqual(ovs_port['qos'], qos['_uuid']) + self.assertIsNotNone(port) + self.assertEqual(port['qos'], qos['_uuid']) vm.close() time.sleep(const.DEFAULT_CMD_TIMEOUT) diff --git a/dragonflow/tests/unit/test_app_base.py b/dragonflow/tests/unit/test_app_base.py index 8868b33af..c7802b713 100644 --- a/dragonflow/tests/unit/test_app_base.py +++ b/dragonflow/tests/unit/test_app_base.py @@ -290,8 +290,8 @@ fake_local_port1 = make_fake_local_port( dhcp_params=fake_dhcp_params) -fake_ovs_port1 = switch.SwitchPort( - id='fake_ovs_port1', +fake_switch_port1 = switch.SwitchPort( + id='fake_switch_port1', port_num=2, name='tap-fake_port1', admin_state='up', @@ -308,8 +308,8 @@ fake_local_port2 = make_fake_local_port( subnets=['fake_subnet1']) -fake_ovs_port2 = switch.SwitchPort( - id='fake_ovs_port2', +fake_switch_port2 = switch.SwitchPort( + id='fake_switch_port2', port_num=3, name='tap-fake_port2', admin_state='up', diff --git a/dragonflow/tests/unit/test_classifier_app.py b/dragonflow/tests/unit/test_classifier_app.py index 24400c6a3..0d80bc448 100644 --- a/dragonflow/tests/unit/test_classifier_app.py +++ b/dragonflow/tests/unit/test_classifier_app.py @@ -26,7 +26,7 @@ make_fake_local_port = test_app_base.make_fake_local_port SCENARIO_ORDER_DELETE_LPORT_FIRST = 'delete_lport_first' -SCENARIO_ORDER_DELETE_OVS_PORT_FIRST = 'delete_ovs_port_first' +SCENARIO_ORDER_DELETE_SWITCH_PORT_FIRST = 'delete_switch_port_first' class TestClassifierAppForVlan(testscenarios.WithScenarios, @@ -35,8 +35,8 @@ class TestClassifierAppForVlan(testscenarios.WithScenarios, scenarios = [(SCENARIO_ORDER_DELETE_LPORT_FIRST, {'order': SCENARIO_ORDER_DELETE_LPORT_FIRST}), - (SCENARIO_ORDER_DELETE_OVS_PORT_FIRST, - {'order': SCENARIO_ORDER_DELETE_OVS_PORT_FIRST})] + (SCENARIO_ORDER_DELETE_SWITCH_PORT_FIRST, + {'order': SCENARIO_ORDER_DELETE_SWITCH_PORT_FIRST})] def setUp(self): super(TestClassifierAppForVlan, self).setUp() @@ -58,11 +58,11 @@ class TestClassifierAppForVlan(testscenarios.WithScenarios, lswitch='fake_vlan_switch1') self.controller.update(fake_local_vlan_port) self.app.mod_flow.assert_not_called() - ovs_port = switch.SwitchPort(id='fake_ovs_port', - lport=fake_local_vlan_port.id, - port_num=1, admin_state='up', - type=constants.SWITCH_COMPUTE_INTERFACE) - self.controller.update(ovs_port) + switch_port = switch.SwitchPort( + id='fake_switch_port', lport=fake_local_vlan_port.id, + port_num=1, admin_state='up', + type=constants.SWITCH_COMPUTE_INTERFACE) + self.controller.update(switch_port) port_key = fake_local_vlan_port.unique_key match = self.app.parser.OFPMatch(reg7=port_key) self.app.mod_flow.assert_called_with( @@ -71,13 +71,13 @@ class TestClassifierAppForVlan(testscenarios.WithScenarios, priority=const.PRIORITY_MEDIUM, match=match) self.app.mod_flow.reset_mock() - port_num = ovs_port.port_num + port_num = switch_port.port_num match = self.app.parser.OFPMatch(in_port=port_num) if self.order == SCENARIO_ORDER_DELETE_LPORT_FIRST: self.controller.delete(fake_local_vlan_port) - self.controller.delete(ovs_port) - elif self.order == SCENARIO_ORDER_DELETE_OVS_PORT_FIRST: - self.controller.delete(ovs_port) + self.controller.delete(switch_port) + elif self.order == SCENARIO_ORDER_DELETE_SWITCH_PORT_FIRST: + self.controller.delete(switch_port) self.controller.delete(fake_local_vlan_port) else: self.fail("Bad order") diff --git a/dragonflow/tests/unit/test_dnat_app.py b/dragonflow/tests/unit/test_dnat_app.py index dc7c4095e..86ae5d761 100644 --- a/dragonflow/tests/unit/test_dnat_app.py +++ b/dragonflow/tests/unit/test_dnat_app.py @@ -91,13 +91,14 @@ class TestDNATApp(test_app_base.DFAppTestBase): def test_floatingip_removed_only_once(self): self.controller.update(test_app_base.fake_local_port1) - self.controller.topology.ovs_port_updated(test_app_base.fake_ovs_port1) + self.controller.topology.switch_port_updated( + test_app_base.fake_switch_port1) self.controller.update(test_app_base.fake_floatingip1) self.controller.delete(test_app_base.fake_floatingip1) self.controller.delete(test_app_base.fake_local_port1) with mock.patch.object(self.controller, 'delete') as mock_func: - self.controller.topology.ovs_port_deleted( - test_app_base.fake_ovs_port1) + self.controller.topology.switch_port_deleted( + test_app_base.fake_switch_port1) mock_func.assert_not_called() @utils.add_objs_to_db_store(local_lport1, floating_lport) diff --git a/dragonflow/tests/unit/test_metadata_service_app.py b/dragonflow/tests/unit/test_metadata_service_app.py index bad8485af..5f496293e 100644 --- a/dragonflow/tests/unit/test_metadata_service_app.py +++ b/dragonflow/tests/unit/test_metadata_service_app.py @@ -37,7 +37,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase): # Device without mac will not trigger update flow self.controller.update( switch.SwitchPort( - id='fake_ovs_port', + id='fake_switch_port', port_num=1, name=self.meta_app._interface, ) @@ -48,7 +48,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase): # Other device update will not trigger update flow self.controller.update( switch.SwitchPort( - id='fake_ovs_port', + id='fake_switch_port', port_num=1, name='no-interface', mac_in_use='aa:bb:cc:dd:ee:ff', @@ -60,7 +60,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase): # Device with mac will trigger update flow self.controller.update( switch.SwitchPort( - id='fake_ovs_port', + id='fake_switch_port', port_num=1, name=self.meta_app._interface, mac_in_use='aa:bb:cc:dd:ee:ff', @@ -72,7 +72,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase): # Duplicated updated will not trigger update flow self.controller.update( switch.SwitchPort( - id='fake_ovs_port1', + id='fake_switch_port1', port_num=1, name=self.meta_app._interface, mac_in_use='aa:bb:cc:dd:ee:ff', diff --git a/dragonflow/tests/unit/test_topology.py b/dragonflow/tests/unit/test_topology.py index ca70db2bd..60614a5b7 100644 --- a/dragonflow/tests/unit/test_topology.py +++ b/dragonflow/tests/unit/test_topology.py @@ -61,8 +61,8 @@ class TestTopology(test_app_base.DFAppTestBase): # By default, return empty value for all resources, each case can # customize the return value on their own. self.nb_api.get_all.return_value = [] - self.fake_invalid_ovs_port = copy.deepcopy( - test_app_base.fake_ovs_port1) + self.fake_invalid_switch_port = copy.deepcopy( + test_app_base.fake_switch_port1) self.controller._register_models() @utils.with_nb_objects( @@ -86,7 +86,7 @@ class TestTopology(test_app_base.DFAppTestBase): self.controller.delete_by_id.side_effect = original_delete_by_id # Verify port online - self.topology.ovs_port_updated(test_app_base.fake_ovs_port1) + self.topology.switch_port_updated(test_app_base.fake_switch_port1) self.controller.update.assert_has_calls( (mock.call(test_app_base.fake_logic_switch1), mock.call(test_app_base.fake_local_port1)), @@ -98,7 +98,7 @@ class TestTopology(test_app_base.DFAppTestBase): self.controller.delete.reset_mock() self.controller.update.reset_mock() self.nb_api.get_all.return_value = [] - self.topology.ovs_port_deleted(test_app_base.fake_ovs_port1) + self.topology.switch_port_deleted(test_app_base.fake_switch_port1) self.controller.delete.assert_has_calls([ mock.call(test_app_base.fake_local_port1), mock.call(test_app_base.fake_logic_switch1), @@ -114,7 +114,7 @@ class TestTopology(test_app_base.DFAppTestBase): ) self.nb_api.get.return_value = test_app_base.fake_local_port1 # Pull topology by first ovs port online - self.topology.ovs_port_updated(test_app_base.fake_ovs_port1) + self.topology.switch_port_updated(test_app_base.fake_switch_port1) # Another port online self.nb_api.get_all.side_effect = nb_api_get_all_func( @@ -125,7 +125,7 @@ class TestTopology(test_app_base.DFAppTestBase): ) self.controller.update = mock.Mock() self.nb_api.get.return_value = test_app_base.fake_local_port2 - self.topology.ovs_port_updated(test_app_base.fake_ovs_port2) + self.topology.switch_port_updated(test_app_base.fake_switch_port2) self.controller.update.assert_called_once_with( test_app_base.fake_local_port2) self.nb_api.subscriber.register_topic.assert_called_once() @@ -152,8 +152,8 @@ class TestTopology(test_app_base.DFAppTestBase): self.controller._sync._update_cb = self.controller.update # The vm ports are online one by one - self.topology.ovs_port_updated(test_app_base.fake_ovs_port1) - self.topology.ovs_port_updated(test_app_base.fake_ovs_port2) + self.topology.switch_port_updated(test_app_base.fake_switch_port1) + self.topology.switch_port_updated(test_app_base.fake_switch_port2) calls = [mock.call(test_app_base.fake_chassis1), mock.call(test_app_base.fake_logic_switch1), @@ -164,20 +164,20 @@ class TestTopology(test_app_base.DFAppTestBase): self.assertEqual(4, self.controller.update.call_count) self.nb_api.subscriber.register_topic.assert_called_once() - @utils.with_local_objects(test_app_base.fake_ovs_port1) + @utils.with_local_objects(test_app_base.fake_switch_port1) def test_check_topology_info(self): topic = 'fake_tenant1' lport_id2 = '2' - ovs_port_id2 = 'ovs_port2' + switch_port_id2 = 'switch_port2' lport_id3 = '3' - ovs_port_id3 = 'ovs_port3' + switch_port_id3 = 'switch_port3' self.topology.ovs_to_lport_mapping = { - ovs_port_id2: topology.OvsLportMapping( + switch_port_id2: topology.OvsLportMapping( lport_id=lport_id2, topic=topic ), - ovs_port_id3: topology.OvsLportMapping( + switch_port_id3: topology.OvsLportMapping( lport_id=lport_id3, topic=topic )