Esempio n. 1
0
    def setUp(self):
        super(TestCiscoApicL3Plugin, self).setUp()
        mock.patch('neutron.plugins.ml2.drivers.cisco.apic.apic_model.'
                   'ApicDbModel').start()
        mocked.ControllerMixin.set_up_mocks(self)
        mocked.ConfigMixin.set_up_mocks(self)
        self.plugin = l3_apic.ApicL3ServicePlugin()
        md.APICMechanismDriver.get_router_synchronizer = mock.Mock()
        self.context = FakeContext()
        self.context.tenant_id = TENANT
        self.interface_info = {
            'subnet': {
                'subnet_id': SUBNET
            },
            'port': {
                'port_id': PORT
            }
        }
        self.subnet = {'network_id': NETWORK, 'tenant_id': TENANT}
        self.port = {
            'tenant_id': TENANT,
            'network_id': NETWORK,
            'fixed_ips': [{
                'subnet_id': SUBNET
            }]
        }
        self.plugin.name_mapper = mock.Mock()
        l3_apic.apic_mapper.mapper_context = self.fake_transaction
        self.plugin.name_mapper.tenant.return_value = mocked.APIC_TENANT
        self.plugin.name_mapper.network.return_value = mocked.APIC_NETWORK
        self.plugin.name_mapper.subnet.return_value = mocked.APIC_SUBNET
        self.plugin.name_mapper.port.return_value = mocked.APIC_PORT
        self.plugin.name_mapper.router.return_value = mocked.APIC_ROUTER
        self.plugin.name_mapper.app_profile.return_value = mocked.APIC_AP

        self.contract = FakeContract()
        self.plugin.get_router = mock.Mock(return_value={
            'id': ROUTER,
            'admin_state_up': True
        })
        self.plugin.manager = mock.Mock()
        self.plugin.manager.apic.transaction = self.fake_transaction

        self.plugin.get_subnet = mock.Mock(return_value=self.subnet)
        self.plugin.get_network = mock.Mock(return_value=self.interface_info)
        self.plugin.get_port = mock.Mock(return_value=self.port)
        mock.patch('neutron.db.l3_dvr_db.L3_NAT_with_dvr_db_mixin.'
                   '_core_plugin').start()
        mock.patch('neutron.db.l3_dvr_db.L3_NAT_with_dvr_db_mixin.'
                   'add_router_interface').start()
        mock.patch('neutron.db.l3_dvr_db.L3_NAT_with_dvr_db_mixin.'
                   'remove_router_interface').start()
        mock.patch('neutron.openstack.common.excutils.'
                   'save_and_reraise_exception').start()
Esempio n. 2
0
    def setUp(self):
        super(TestCiscoApicL3Plugin, self).setUp()
        mock.patch('neutron.plugins.ml2.drivers.cisco.apic.apic_manager.'
                   'APICManager').start()
        self.plugin = l3_apic.ApicL3ServicePlugin()
        self.context = FakeContext()
        self.context.tenant_id = TENANT
        self.interface_info = {
            'subnet_id': SUBNET,
            'network_id': NETWORK,
            'name': NETWORK_NAME
        }

        self.contract = FakeContract()
        self.plugin.manager.create_tenant_contract = mock.Mock()
        ctmk = mock.PropertyMock(return_value=self.contract.contract_id)
        type(self.plugin.manager.create_tenant_contract).contract_id = ctmk
        self.epg = FakeEpg()
        self.plugin.manager.ensure_epg_created_for_network = mock.Mock()
        epmk = mock.PropertyMock(return_value=self.epg.epg_id)
        type(self.plugin.manager.ensure_epg_created_for_network).epg_id = epmk

        self.plugin.manager.db.get_provider_contract = mock.Mock(
            return_value=None)
        self.plugin.manager.set_contract_for_epg = mock.Mock(return_value=True)

        self.plugin.get_subnet = mock.Mock(return_value=self.interface_info)
        self.plugin.get_network = mock.Mock(return_value=self.interface_info)
        mock.patch('neutron.db.l3_gwmode_db.L3_NAT_db_mixin.'
                   '_core_plugin').start()
        mock.patch('neutron.db.l3_gwmode_db.L3_NAT_db_mixin.'
                   'add_router_interface').start()
        mock.patch('neutron.db.l3_gwmode_db.L3_NAT_db_mixin.'
                   'remove_router_interface').start()
        mock.patch('neutron.openstack.common.excutils.'
                   'save_and_reraise_exception').start()