Esempio n. 1
0
    def setUp(self):
        impl_idl_ovn.OvsdbNbOvnIdl = fakes.FakeOvsdbNbOvnIdl()
        impl_idl_ovn.OvsdbSbOvnIdl = fakes.FakeOvsdbSbOvnIdl()
        config.cfg.CONF.set_override('extension_drivers',
                                     self._extension_drivers,
                                     group='ml2')
        config.cfg.CONF.set_override('tenant_network_types', ['geneve'],
                                     group='ml2')
        config.cfg.CONF.set_override('vni_ranges', ['1:65536'],
                                     group='ml2_type_geneve')
        super(TestOVNMechanismDriver, self).setUp()
        mm = manager.NeutronManager.get_plugin().mechanism_manager
        self.mech_driver = mm.mech_drivers['ovn'].obj
        self.mech_driver._nb_ovn = fakes.FakeOvsdbNbOvnIdl()
        self.mech_driver._sb_ovn = fakes.FakeOvsdbSbOvnIdl()
        self.nb_ovn = self.mech_driver._nb_ovn

        self.fake_subnet = fakes.FakeSubnet.create_one_subnet().info()
        self.fake_port_no_sg = fakes.FakePort.create_one_port().info()

        self.fake_sg_rule = \
            fakes.FakeSecurityGroupRule.create_one_security_group_rule().info()
        self.fake_sg = fakes.FakeSecurityGroup.create_one_security_group(
            attrs={
                'security_group_rules': [self.fake_sg_rule]
            }).info()

        self.sg_cache = {self.fake_sg['id']: self.fake_sg}
        self.subnet_cache = {self.fake_subnet['id']: self.fake_subnet}
 def setUp(self):
     plugin = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
     l3_plugin = ('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin')
     service_plugins = {'l3_plugin_name': l3_plugin}
     # For these tests we need to enable overlapping ips
     cfg.CONF.set_default('allow_overlapping_ips', True)
     cfg.CONF.set_default('max_routes', 3)
     ext_mgr = test_extraroute.ExtraRouteTestExtensionManager()
     super(test_l3.L3BaseForIntTests,
           self).setUp(plugin=plugin,
                       ext_mgr=ext_mgr,
                       service_plugins=service_plugins)
     l3_gw_mgr = test_l3_gw.TestExtensionManager()
     test_extensions.setup_extensions_middleware(l3_gw_mgr)
     self.l3_inst = directory.get_plugin(plugin_constants.L3)
     self._start_mock('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._ovn',
                      new_callable=mock.PropertyMock,
                      return_value=fakes.FakeOvsdbNbOvnIdl())
     self._start_mock('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._sb_ovn',
                      new_callable=mock.PropertyMock,
                      return_value=fakes.FakeOvsdbSbOvnIdl())
     self._start_mock(
         'networking_ovn.l3.l3_ovn_scheduler.'
         'OVNGatewayScheduler._schedule_gateway',
         return_value='hv1')
     self._start_mock(
         'networking_ovn.l3.l3_ovn.OVNL3RouterPlugin.'
         '_get_v4_network_of_all_router_ports',
         return_value=[])
     self.setup_notification_driver()
Esempio n. 3
0
 def setUp(self):
     impl_idl_ovn.OvsdbNbOvnIdl = fakes.FakeOvsdbNbOvnIdl()
     config.cfg.CONF.set_override('tenant_network_types', ['geneve'],
                                  group='ml2')
     config.cfg.CONF.set_override('vni_ranges', ['1:65536'],
                                  group='ml2_type_geneve')
     super(OVNMechanismDriverTestCase, self).setUp()
     mm = manager.NeutronManager.get_plugin().mechanism_manager
     self.mech_driver = mm.mech_drivers['ovn'].obj
     self.mech_driver._nb_ovn = fakes.FakeOvsdbNbOvnIdl()
     self.mech_driver._sb_ovn = fakes.FakeOvsdbSbOvnIdl()
     self.mech_driver._insert_port_provisioning_block = mock.Mock()
     self.mech_driver.vif_type = portbindings.VIF_TYPE_OVS
Esempio n. 4
0
 def setUp(self):
     super(OVNL3RouterPlugin, self).setUp()
     self.fake_router_port = {
         'device_id': '',
         'mac_address': 'aa:aa:aa:aa:aa:aa',
         'fixed_ips': [{
             'ip_address': '10.0.0.100',
             'subnet_id': 'subnet-id'
         }],
         'id': 'router-port-id'
     }
     self.fake_subnet = {'id': 'subnet-id', 'cidr': '10.0.0.1/24'}
     self.fake_router = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': False,
         'routes': [{
             'destination': '1.1.1.0/24',
             'nexthop': '2.2.2.3'
         }]
     }
     mgr = manager.NeutronManager.get_instance()
     self.l3_plugin = mgr.get_service_plugins().get(
         service_constants.L3_ROUTER_NAT)
     mock.patch('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._ovn',
                new_callable=mock.PropertyMock,
                return_value=fakes.FakeOvsdbNbOvnIdl()).start()
     mock.patch('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._sb_ovn',
                new_callable=mock.PropertyMock,
                return_value=fakes.FakeOvsdbSbOvnIdl()).start()
     mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_port',
                return_value=self.fake_router_port).start()
     mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_subnet',
                return_value=self.fake_subnet).start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.get_router',
                return_value=self.fake_router).start()
     mock.patch(
         'neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.update_router',
         return_value=self.fake_router).start()
 def setUp(self):
     super(OVNL3RouterPlugin, self).setUp()
     network_attrs = {'router:external': True}
     self.fake_network = \
         fakes.FakeNetwork.create_one_network(attrs=network_attrs).info()
     self.fake_router_port = {
         'device_id': '',
         'device_owner': 'network:router_interface',
         'mac_address': 'aa:aa:aa:aa:aa:aa',
         'fixed_ips': [{
             'ip_address': '10.0.0.100',
             'subnet_id': 'subnet-id'
         }],
         'id': 'router-port-id'
     }
     self.fake_router_port_assert = {
         'lrouter': 'neutron-router-id',
         'mac': 'aa:aa:aa:aa:aa:aa',
         'name': 'lrp-router-port-id',
         'networks': ['10.0.0.100/24']
     }
     self.fake_router_ports = [self.fake_router_port]
     self.fake_subnet = {
         'id': 'subnet-id',
         'ip_version': 4,
         'cidr': '10.0.0.0/24'
     }
     self.fake_router = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': False,
         'routes': [{
             'destination': '1.1.1.0/24',
             'nexthop': '10.0.0.2'
         }]
     }
     self.fake_router_interface_info = {
         'port_id': 'router-port-id',
         'device_id': '',
         'mac_address': 'aa:aa:aa:aa:aa:aa',
         'subnet_id': 'subnet-id',
         'subnet_ids': ['subnet-id'],
         'fixed_ips': [{
             'ip_address': '10.0.0.100',
             'subnet_id': 'subnet-id'
         }],
         'id': 'router-port-id'
     }
     self.fake_external_fixed_ips = {
         'network_id':
         'ext-network-id',
         'external_fixed_ips': [{
             'ip_address': '192.168.1.1',
             'subnet_id': 'ext-subnet-id'
         }]
     }
     self.fake_router_with_ext_gw = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': True,
         'external_gateway_info': self.fake_external_fixed_ips,
         'gw_port_id': 'gw-port-id'
     }
     self.fake_router_without_ext_gw = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': True,
     }
     self.fake_ext_subnet = {
         'id': 'ext-subnet-id',
         'ip_version': 4,
         'cidr': '192.168.1.0/24',
         'gateway_ip': '192.168.1.254'
     }
     self.fake_ext_gw_port = {
         'device_id':
         '',
         'device_owner':
         'network:router_gateway',
         'fixed_ips': [{
             'ip_address': '192.168.1.1',
             'subnet_id': 'ext-subnet-id'
         }],
         'mac_address':
         '00:00:00:02:04:06',
         'network_id':
         self.fake_network['id'],
         'id':
         'gw-port-id'
     }
     self.fake_ext_gw_port_assert = {
         'lrouter': 'neutron-router-id',
         'mac': '00:00:00:02:04:06',
         'name': 'lrp-gw-port-id',
         'networks': ['192.168.1.1/24'],
         'gateway_chassis': ['hv1']
     }
     self.fake_floating_ip_attrs = {
         'floating_ip_address': '192.168.0.10',
         'fixed_ip_address': '10.0.0.10'
     }
     self.fake_floating_ip = fakes.FakeFloatingIp.create_one_fip(
         attrs=self.fake_floating_ip_attrs)
     self.fake_floating_ip_new_attrs = {
         'router_id': 'new-router-id',
         'floating_ip_address': '192.168.0.10',
         'fixed_ip_address': '10.10.10.10'
     }
     self.fake_floating_ip_new = fakes.FakeFloatingIp.create_one_fip(
         attrs=self.fake_floating_ip_new_attrs)
     self.l3_inst = directory.get_plugin(plugin_constants.L3)
     self._start_mock('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._ovn',
                      new_callable=mock.PropertyMock,
                      return_value=fakes.FakeOvsdbNbOvnIdl())
     self._start_mock('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._sb_ovn',
                      new_callable=mock.PropertyMock,
                      return_value=fakes.FakeOvsdbSbOvnIdl())
     self._start_mock('neutron.plugins.ml2.plugin.Ml2Plugin.get_network',
                      return_value=self.fake_network)
     self._start_mock(
         'neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_port',
         return_value=self.fake_router_port)
     self._start_mock(
         'neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_subnet',
         return_value=self.fake_subnet)
     self._start_mock('neutron.db.l3_db.L3_NAT_dbonly_mixin.get_router',
                      return_value=self.fake_router)
     self._start_mock(
         'neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.update_router',
         return_value=self.fake_router)
     self._start_mock(
         'neutron.db.l3_db.L3_NAT_dbonly_mixin.remove_router_interface',
         return_value=self.fake_router_interface_info)
     self._start_mock('neutron.db.l3_db.L3_NAT_dbonly_mixin.create_router',
                      return_value=self.fake_router_with_ext_gw)
     self._start_mock('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_router',
                      return_value={})
     self._start_mock(
         'networking_ovn.common.ovn_client.'
         'OVNClient.get_candidates_for_scheduling',
         return_value=[])
     self._start_mock(
         'networking_ovn.l3.l3_ovn_scheduler.'
         'OVNGatewayLeastLoadedScheduler._schedule_gateway',
         return_value=['hv1'])
     self._start_mock(
         'neutron.db.l3_db.L3_NAT_dbonly_mixin.create_floatingip',
         return_value=self.fake_floating_ip)
     self._start_mock(
         'neutron.db.l3_db.L3_NAT_dbonly_mixin._get_floatingip',
         return_value=self.fake_floating_ip)
Esempio n. 6
0
 def setUp(self):
     super(OVNL3RouterPlugin, self).setUp()
     self.fake_router_port = {
         'device_id': '',
         'device_owner': 'network:router_interface',
         'mac_address': 'aa:aa:aa:aa:aa:aa',
         'fixed_ips': [{
             'ip_address': '10.0.0.100',
             'subnet_id': 'subnet-id'
         }],
         'id': 'router-port-id'
     }
     self.fake_router_port_assert = {
         'lrouter': 'neutron-router-id',
         'mac': 'aa:aa:aa:aa:aa:aa',
         'name': 'lrp-router-port-id',
         'networks': ['10.0.0.100/24']
     }
     self.fake_router_ports = [self.fake_router_port]
     self.fake_subnet = {
         'id': 'subnet-id',
         'ip_version': 4,
         'cidr': '10.0.0.0/24'
     }
     self.fake_router = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': False,
         'routes': [{
             'destination': '1.1.1.0/24',
             'nexthop': '10.0.0.2'
         }]
     }
     self.fake_router_interface_info = {
         'port_id': 'router-port-id',
         'device_id': '',
         'mac_address': 'aa:aa:aa:aa:aa:aa',
         'subnet_id': 'subnet-id',
         'subnet_ids': ['subnet-id'],
         'fixed_ips': [{
             'ip_address': '10.0.0.100',
             'subnet_id': 'subnet-id'
         }],
         'id': 'router-port-id'
     }
     self.fake_external_fixed_ips = {
         'network_id':
         'ext-network-id',
         'external_fixed_ips': [{
             'ip_address': '192.168.1.1',
             'subnet_id': 'ext-subnet-id'
         }]
     }
     self.fake_router_with_ext_gw = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': True,
         'external_gateway_info': self.fake_external_fixed_ips,
         'gw_port_id': 'gw-port-id'
     }
     self.fake_router_without_ext_gw = {
         'id': 'router-id',
         'name': 'router',
         'admin_state_up': True,
     }
     self.fake_ext_subnet = {
         'id': 'ext-subnet-id',
         'ip_version': 4,
         'cidr': '192.168.1.0/24',
         'gateway_ip': '192.168.1.254'
     }
     self.fake_ext_gw_port = {
         'device_id':
         '',
         'device_owner':
         'network:router_gateway',
         'fixed_ips': [{
             'ip_address': '192.168.1.1',
             'subnet_id': 'ext-subnet-id'
         }],
         'mac_address':
         '00:00:00:02:04:06',
         'id':
         'gw-port-id'
     }
     self.fake_ext_gw_port_assert = {
         'lrouter': 'neutron-router-id',
         'mac': '00:00:00:02:04:06',
         'name': 'lrp-gw-port-id',
         'networks': ['192.168.1.1/24'],
         'options': {
             'redirect-chassis': 'hv1'
         }
     }
     self.fake_floating_ip = {
         'id': 'fip-id',
         'tenant_id': '',
         'floating_ip_address': '192.168.0.10',
         'floating_network_id': 'fip-net-id',
         'router_id': 'router-id',
         'fixed_port_id': 'port_id',
         'floating_port_id': 'fip-port-id',
         'fixed_ip_address': '10.0.0.10',
         'status': 'Active'
     }
     self.fake_floating_ip_new = {
         'id': 'fip-id',
         'tenant_id': '',
         'floating_ip_address': '192.168.0.10',
         'floating_network_id': 'fip-net-id',
         'router_id': 'new-router-id',
         'fixed_port_id': 'new-port_id',
         'floating_port_id': 'fip-port-id',
         'fixed_ip_address': '10.10.10.10',
         'status': 'Active'
     }
     self.l3_plugin = directory.get_plugin(constants.L3)
     mock.patch('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._ovn',
                new_callable=mock.PropertyMock,
                return_value=fakes.FakeOvsdbNbOvnIdl()).start()
     mock.patch('networking_ovn.l3.l3_ovn.OVNL3RouterPlugin._sb_ovn',
                new_callable=mock.PropertyMock,
                return_value=fakes.FakeOvsdbSbOvnIdl()).start()
     mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_port',
                return_value=self.fake_router_port).start()
     mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_subnet',
                return_value=self.fake_subnet).start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.get_router',
                return_value=self.fake_router).start()
     mock.patch(
         'neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.update_router',
         return_value=self.fake_router).start()
     mock.patch(
         'neutron.db.l3_db.L3_NAT_dbonly_mixin.remove_router_interface',
         return_value=self.fake_router_interface_info).start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.create_router',
                return_value=self.fake_router_with_ext_gw).start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_router',
                return_value={}).start()
     mock.patch(
         'networking_ovn.l3.l3_ovn_scheduler.'
         'OVNGatewayLeastLoadedScheduler._schedule_gateway',
         return_value='hv1').start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.create_floatingip',
                return_value=self.fake_floating_ip).start()
     mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin._get_floatingip',
                return_value=self.fake_floating_ip).start()
Esempio n. 7
0
 def setUp(self):
     super(TestOVNMechansimDriverSegment, self).setUp()
     mm = manager.NeutronManager.get_plugin().mechanism_manager
     self.mech_driver = mm.mech_drivers['ovn'].obj
     self.mech_driver._nb_ovn = fakes.FakeOvsdbNbOvnIdl()
     self.mech_driver._sb_ovn = fakes.FakeOvsdbSbOvnIdl()