示例#1
0
    def __init__(self, server_timeout=None):
        LOG.info(_("NeutronRestProxy: Starting plugin. Version=%s"), version_string_with_vcs())

        # init DB, proxy's persistent store defaults to in-memory sql-lite DB
        db.configure_db()

        # Include the BigSwitch Extensions path in the api_extensions
        neutron_extensions.append_api_extensions_path(extensions.__path__)

        self.add_meta_server_route = cfg.CONF.RESTPROXY.add_meta_server_route

        # init network ctrl connections
        self.servers = ServerPool(server_timeout, BASE_URI)

        # init dhcp support
        self.topic = topics.PLUGIN
        self.network_scheduler = importutils.import_object(cfg.CONF.network_scheduler_driver)
        self._dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
        self.agent_notifiers[const.AGENT_TYPE_DHCP] = self._dhcp_agent_notifier
        self.conn = rpc.create_connection(new=True)
        self.callbacks = RpcProxy()
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
        self.conn.create_consumer(self.topic, self.dispatcher, fanout=False)
        # Consume from all consumers in a thread
        self.conn.consume_in_thread()
        if cfg.CONF.RESTPROXY.sync_data:
            self._send_all_data()

        LOG.debug(_("NeutronRestProxyV2: initialization done"))
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        for key in conf.CISCO_PLUGINS.keys():
            plugin_obj = conf.CISCO_PLUGINS[key]
            self._plugins[key] = importutils.import_object(plugin_obj)
            LOG.debug(_("Loaded device plugin %s\n"),
                      conf.CISCO_PLUGINS[key])

        if ((const.VSWITCH_PLUGIN in self._plugins) and
            hasattr(self._plugins[const.VSWITCH_PLUGIN],
                    "supported_extension_aliases")):
            self.supported_extension_aliases.extend(
                self._plugins[const.VSWITCH_PLUGIN].
                supported_extension_aliases)

        # At this point, all the database models should have been loaded. It's
        # possible that configure_db() may have been called by one of the
        # plugins loaded in above. Otherwise, this call is to make sure that
        # the database is initialized
        db_api.configure_db()

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug(_("%(module)s.%(name)s init done"),
                  {'module': __name__,
                   'name': self.__class__.__name__})
示例#3
0
    def setUp(self):
        super(TestDBAPI, self).setUp()

        configure_mappers()
        cfg.CONF.set_override('connection', 'sqlite://', 'database')
        neutron_db_api.configure_db()
        neutron_db_api.register_models(models.BASEV2)
示例#4
0
 def setUp(self):
     super(VlanAllocationsTest, self).setUp()
     db.configure_db()
     self.session = db.get_session()
     self.net_p = _create_test_network_profile_if_not_there(self.session)
     n1kv_db_v2.sync_vlan_allocations(self.session, self.net_p)
     self.addCleanup(db.clear_db)
    def __init__(self):

        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        provider_router_id = midonet_conf.provider_router_id
        metadata_router_id = midonet_conf.metadata_router_id
        mode = midonet_conf.mode

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        if provider_router_id and metadata_router_id:
            # get MidoNet provider router and metadata router
            self.provider_router = self.client.get_router(provider_router_id)
            self.metadata_router = self.client.get_router(metadata_router_id)

        elif not provider_router_id or not metadata_router_id:
            if mode == 'dev':
                msg = _('No provider router and metadata device ids found. '
                        'But skipping because running in dev env.')
                LOG.debug(msg)
            else:
                msg = _('provider_router_id and metadata_router_id '
                        'should be configured in the plugin config file')
                LOG.exception(msg)
                raise MidonetPluginException(msg=msg)

        db.configure_db()
示例#6
0
    def __init__(self):
        LOG.info(_('NeutronPluginPLUMgrid Status: Starting Plugin'))

        # PLUMgrid NOS configuration
        nos_plumgrid = cfg.CONF.PLUMgridNOS.nos_server
        nos_port = cfg.CONF.PLUMgridNOS.nos_server_port
        timeout = cfg.CONF.PLUMgridNOS.servertimeout
        self.topology_name = cfg.CONF.PLUMgridNOS.topologyname
        self.snippets = plumgrid_nos_snippets.DataNOSPLUMgrid()

        # TODO(Edgar) These are placeholders for next PLUMgrid release
        cfg.CONF.PLUMgridNOS.username
        cfg.CONF.PLUMgridNOS.password
        self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
                                                        nos_port, timeout)
        if self.rest_conn is None:
            raise SystemExit(_('NeutronPluginPLUMgrid Status: '
                               'Aborting Plugin'))

        else:
            # Plugin DB initialization
            db.configure_db()

            # PLUMgrid NOS info validation
            LOG.info(_('NeutronPluginPLUMgrid NOS: %s'), nos_plumgrid)
            if not nos_plumgrid:
                raise SystemExit(_('NeutronPluginPLUMgrid Status: '
                                   'NOS value is missing in config file'))

            LOG.debug(_('NeutronPluginPLUMgrid Status: Neutron server with '
                        'PLUMgrid Plugin has started'))
示例#7
0
    def setUp(self):
        self.context = context.Context("fake", "fake", is_admin=False)
        super(QuarkNetworkFunctionalTest, self).setUp()

        cfg.CONF.set_override("connection", "sqlite://", "database")
        neutron_db_api.configure_db()
        models.BASEV2.metadata.create_all(neutron_session._ENGINE)
    def __init__(self, configfile=None):
        LOG.debug(_("Start initializing metaplugin"))
        self.supported_extension_aliases = \
            cfg.CONF.META.supported_extension_aliases.split(',')
        self.supported_extension_aliases += ['flavor', 'external-net',
                                             'router', 'ext-gw-mode',
                                             'extraroute']

        # Ignore config option overapping
        def _is_opt_registered(opts, opt):
            if opt.dest in opts:
                return True
            else:
                return False

        cfg._is_opt_registered = _is_opt_registered

        # Keep existing tables if multiple plugin use same table name.
        db.model_base.NeutronBase.__table_args__ = {'keep_existing': True}

        self.plugins = {}

        plugin_list = [plugin_set.split(':')
                       for plugin_set
                       in cfg.CONF.META.plugin_list.split(',')]
        for flavor, plugin_provider in plugin_list:
            self.plugins[flavor] = self._load_plugin(plugin_provider)

        self.l3_plugins = {}
        l3_plugin_list = [plugin_set.split(':')
                          for plugin_set
                          in cfg.CONF.META.l3_plugin_list.split(',')]
        for flavor, plugin_provider in l3_plugin_list:
            if flavor in self.plugins:
                self.l3_plugins[flavor] = self.plugins[flavor]
            else:
                # For l3 only plugin
                self.l3_plugins[flavor] = self._load_plugin(plugin_provider)

        self.default_flavor = cfg.CONF.META.default_flavor
        if self.default_flavor not in self.plugins:
            raise exc.Invalid(_('default_flavor %s is not plugin list') %
                              self.default_flavor)

        self.default_l3_flavor = cfg.CONF.META.default_l3_flavor
        if self.default_l3_flavor not in self.l3_plugins:
            raise exc.Invalid(_('default_l3_flavor %s is not plugin list') %
                              self.default_l3_flavor)

        db.configure_db()

        self.extension_map = {}
        if not cfg.CONF.META.extension_map == '':
            extension_list = [method_set.split(':')
                              for method_set
                              in cfg.CONF.META.extension_map.split(',')]
            for method_name, flavor in extension_list:
                self.extension_map[method_name] = flavor

        self.default_flavor = cfg.CONF.META.default_flavor
示例#9
0
 def setUp(self):
     super(MetaNeutronPluginV2TestRpcFlavor, self).setUp()
     db._ENGINE = None
     db._MAKER = None
     db.configure_db()
     self.addCleanup(db.clear_db)
     self.addCleanup(unregister_meta_hooks)
示例#10
0
    def setUp(self):
        super(QuotaExtensionTestCase, self).setUp()
        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Create the default configurations
        args = ['--config-file', test_extensions.etcdir('neutron.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        self.setup_coreplugin(TARGET_PLUGIN)
        cfg.CONF.set_override(
            'quota_items',
            ['network', 'subnet', 'port', 'extra1'],
            group='QUOTAS')
        quota.QUOTAS = quota.QuotaEngine()
        quota.register_resources_from_config()
        self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
        self.plugin = self._plugin_patcher.start()
        self.plugin.return_value.supported_extension_aliases = ['quotas']
        # QUOTAS will register the items in conf when starting
        # extra1 here is added later, so have to do it manually
        quota.QUOTAS.register_resource_by_name('extra1')
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        db.configure_db()
        app = config.load_paste_app('extensions_test_app')
        ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)
        self.api = webtest.TestApp(ext_middleware)
示例#11
0
文件: plugin.py 项目: av-mido/neutron
    def __init__(self):

        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        provider_router_id = midonet_conf.provider_router_id
        mode = midonet_conf.mode

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        if provider_router_id:
            self.provider_router = self.client.get_router(provider_router_id)
        else:
            msg = _('provider_router_id should be configured in the plugin '
                    'config file')
            LOG.exception(msg)
            raise MidonetPluginException(msg=msg)

        db.configure_db()
示例#12
0
    def setUp(self):
        super(TestCiscoIPsecDriver, self).setUp()
        dbapi.configure_db()
        self.addCleanup(dbapi.clear_db)
        mock.patch('neutron.openstack.common.rpc.create_connection').start()

        l3_agent = mock.Mock()
        l3_agent.host = FAKE_HOST
        plugin = mock.Mock()
        plugin.get_l3_agents_hosting_routers.return_value = [l3_agent]
        plugin_p = mock.patch('neutron.manager.NeutronManager.get_plugin')
        get_plugin = plugin_p.start()
        get_plugin.return_value = plugin
        service_plugin_p = mock.patch(
            'neutron.manager.NeutronManager.get_service_plugins')
        get_service_plugin = service_plugin_p.start()
        get_service_plugin.return_value = {constants.L3_ROUTER_NAT: plugin}

        service_plugin = mock.Mock()
        service_plugin.get_l3_agents_hosting_routers.return_value = [l3_agent]
        service_plugin._get_vpnservice.return_value = {
            'router_id': _uuid()
        }
        self.db_update_mock = service_plugin.update_ipsec_site_conn_status
        self.driver = ipsec_driver.CiscoCsrIPsecVPNDriver(service_plugin)
        self.driver.validate_ipsec_connection = mock.Mock()
        mock.patch.object(csr_db, 'create_tunnel_mapping').start()
        self.context = n_ctx.Context('some_user', 'some_tenant')
示例#13
0
    def setUp(self):
        super(QuarkIpamBaseTest, self).setUp()

        cfg.CONF.set_override('connection', 'sqlite://', 'database')
        neutron_db_api.configure_db()
        models.BASEV2.metadata.create_all(neutron_session._ENGINE)
        self.ipam = quark.ipam.QuarkIpam()
示例#14
0
    def setUp(self):
        self.context = context.Context('fake', 'fake', is_admin=False)
        super(QuarkIpamBaseFunctionalTest, self).setUp()

        cfg.CONF.set_override('connection', 'sqlite://', 'database')
        neutron_db_api.configure_db()
        models.BASEV2.metadata.create_all(neutron_session._ENGINE)
示例#15
0
    def __init__(self):
        """Initialize Brocade Plugin.

        Specify switch address and db configuration.
        """

        self.supported_extension_aliases = ["binding", "security-group",
                                            "router", "extraroute",
                                            "agent", "l3_agent_scheduler",
                                            "dhcp_agent_scheduler"]

        self.physical_interface = (cfg.CONF.PHYSICAL_INTERFACE.
                                   physical_interface)
        self.base_binding_dict = self._get_base_binding_dict()
        portbindings_base.register_port_dict_function()
        db.configure_db()
        self.ctxt = context.get_admin_context()
        self.ctxt.session = db.get_session()
        self._vlan_bitmap = vbm.VlanBitmap(self.ctxt)
        self._setup_rpc()
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver
        )
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver
        )
        self.brocade_init()
    def setUp(self):
        super(MetaNeutronPluginV2Test, self).setUp()
        db._ENGINE = None
        db._MAKER = None
        self.fake_tenant_id = uuidutils.generate_uuid()
        self.context = context.get_admin_context()

        db.configure_db()

        setup_metaplugin_conf()

        self.mox = mox.Mox()
        self.stubs = stubout.StubOutForTesting()
        self.client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
        client_cls = self.client_cls_p.start()
        self.client_inst = mock.Mock()
        client_cls.return_value = self.client_inst
        self.client_inst.create_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.delete_network.return_value = True
        self.client_inst.delete_port.return_value = True
        self.client_inst.delete_subnet.return_value = True
        self.plugin = MetaPluginV2(configfile=None)
示例#17
0
 def new_nexus_init(self):
     self._client = importutils.import_object(NEXUS_DRIVER)
     self._client.nexus_switches = {
         (NEXUS_IP_ADDRESS, HOSTNAME1): NEXUS_PORT1,
         (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
         (NEXUS_IP_ADDRESS, HOSTNAME2): NEXUS_PORT2,
         (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
         (NEXUS_PC_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
     }
     self._nexus_switches = {
         ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME1): NEXUS_PORT1,
         ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME2): NEXUS_PORT2,
         ('NEXUS_SWITCH', NEXUS_PC_IP_ADDRESS, HOSTNAME3):
         NEXUS_PORTCHANNELS,
         ('NEXUS_SWITCH', NEXUS_PC_IP_ADDRESS, 'ssh_port'):
         NEXUS_SSH_PORT,
         ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME3):
         NEXUS_PORTCHANNELS,
         ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
     }
     self._client.credentials = {
         NEXUS_IP_ADDRESS: {
             'username': '******',
             'password': '******'
         },
         NEXUS_PC_IP_ADDRESS: {
             'username': '******',
             'password': '******'
         },
     }
     db.configure_db()
示例#18
0
    def setUp(self):
        super(TestQuarkPlugin, self).setUp()

        cfg.CONF.set_override('quota_ports_per_network', 1, 'QUOTAS')
        cfg.CONF.set_override('connection', 'sqlite://', 'database')
        db_api.configure_db()
        self.plugin = quark.plugin.Plugin()
示例#19
0
    def setUp(self):
        super(MetaNeutronPluginV2Test, self).setUp()
        db._ENGINE = None
        db._MAKER = None
        self.fake_tenant_id = uuidutils.generate_uuid()
        self.context = context.get_admin_context()

        db.configure_db()
        self.addCleanup(db.clear_db)
        self.addCleanup(unregister_meta_hooks)

        setup_metaplugin_conf(self.has_l3)

        self.client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
        client_cls = self.client_cls_p.start()
        self.client_inst = mock.Mock()
        client_cls.return_value = self.client_inst
        self.client_inst.create_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.delete_network.return_value = True
        self.client_inst.delete_port.return_value = True
        self.client_inst.delete_subnet.return_value = True
        plugin = MetaPluginV2.__module__ + '.' + MetaPluginV2.__name__
        self.setup_coreplugin(plugin)
        self.plugin = MetaPluginV2(configfile=None)
示例#20
0
 def setUp(self):
     super(FlatTypeTest, self).setUp()
     db.configure_db()
     self.driver = type_flat.FlatTypeDriver()
     self.driver._parse_networks(FLAT_NETWORKS)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#21
0
    def setUp(self):
        self.context = context.Context('fake', 'fake', is_admin=False)
        super(QuarkIPAddressFunctionalTest, self).setUp()

        cfg.CONF.set_override('connection', 'sqlite://', 'database')
        neutron_db_api.configure_db()
        neutron_db_api.register_models(models.BASEV2)
示例#22
0
 def setUp(self):
     super(DhcpSchedulerTestCase, self).setUp()
     db.configure_db()
     self.ctx = context.get_admin_context()
     self.network_id = 'foo_network_id'
     self._save_networks([self.network_id])
     self.addCleanup(db.clear_db)
示例#23
0
 def setUp(self):
     super(VxlanAllocationsTest, self).setUp()
     db.configure_db()
     self.session = db.get_session()
     self.net_p = _create_test_network_profile_if_not_there(
         self.session, TEST_NETWORK_PROFILE_VXLAN)
     n1kv_db_v2.sync_vxlan_allocations(self.session, self.net_p)
     self.addCleanup(db.clear_db)
示例#24
0
 def setUp(self):
     super(GreTypeMultiRangeTest, self).setUp()
     db.configure_db()
     self.driver = type_gre.GreTypeDriver()
     self.driver.gre_id_ranges = self.TUNNEL_MULTI_RANGES
     self.driver._sync_gre_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#25
0
 def setUp(self):
     super(GreTypeTest, self).setUp()
     db.configure_db()
     self.driver = type_gre.GreTypeDriver()
     self.driver.gre_id_ranges = TUNNEL_RANGES
     self.driver._sync_gre_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#26
0
 def setUp(self):
     super(VxlanTypeMultiRangeTest, self).setUp()
     db.configure_db()
     self.driver = type_vxlan.VxlanTypeDriver()
     self.driver.vxlan_vni_ranges = self.TUNNEL_MULTI_RANGES
     self.driver._sync_vxlan_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#27
0
 def setUp(self):
     super(VlanTypeTest, self).setUp()
     db.configure_db()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.network_vlan_ranges = NETWORK_VLAN_RANGES
     self.driver._sync_vlan_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#28
0
 def setUp(self):
     super(FlatTypeTest, self).setUp()
     db.configure_db()
     cfg.CONF.set_override('flat_networks', FLAT_NETWORKS,
                           group='ml2_type_flat')
     self.driver = type_flat.FlatTypeDriver()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#29
0
 def setUp(self):
     super(VxlanTypeMultiRangeTest, self).setUp()
     db.configure_db()
     self.driver = type_vxlan.VxlanTypeDriver()
     self.driver.vxlan_vni_ranges = self.TUNNEL_MULTI_RANGES
     self.driver._sync_vxlan_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#30
0
    def __init__(self):
        LOG.info(_("Neutron PLUMgrid Director: Starting Plugin"))

        # Plugin DB initialization
        db.configure_db()

        self.plumgrid_init()

        LOG.debug(_("Neutron PLUMgrid Director: Neutron server with " "PLUMgrid Plugin has started"))
示例#31
0
 def __init__(self, configfile=None):
     db.configure_db()
     self.neutron = client.Client(
         username=cfg.CONF.PROXY.admin_user,
         password=cfg.CONF.PROXY.admin_password,
         tenant_name=cfg.CONF.PROXY.admin_tenant_name,
         auth_url=cfg.CONF.PROXY.auth_url,
         auth_strategy=cfg.CONF.PROXY.auth_strategy,
         auth_region=cfg.CONF.PROXY.auth_region)
示例#32
0
 def setUp(self):
     super(FlatTypeTest, self).setUp()
     db.configure_db()
     cfg.CONF.set_override('flat_networks',
                           FLAT_NETWORKS,
                           group='ml2_type_flat')
     self.driver = type_flat.FlatTypeDriver()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#33
0
 def setUp(self):
     super(LSNTestCase, self).setUp()
     db.configure_db()
     self.ctx = context.get_admin_context()
     self.addCleanup(db.clear_db)
     self.net_id = 'foo_network_id'
     self.lsn_id = 'foo_lsn_id'
     self.lsn_port_id = 'foo_port_id'
     self.subnet_id = 'foo_subnet_id'
     self.mac_addr = 'aa:bb:cc:dd:ee:ff'
示例#34
0
 def __init__(self, configfile=None):
     db.configure_db()
     self.neutron = client.Client(
         username=cfg.CONF.PROXY.admin_user,
         password=cfg.CONF.PROXY.admin_password,
         tenant_name=cfg.CONF.PROXY.admin_tenant_name,
         auth_url=cfg.CONF.PROXY.auth_url,
         auth_strategy=cfg.CONF.PROXY.auth_strategy,
         auth_region=cfg.CONF.PROXY.auth_region
     )
示例#35
0
 def setUp(self):
     super(LSNTestCase, self).setUp()
     db.configure_db()
     self.ctx = context.get_admin_context()
     self.addCleanup(db.clear_db)
     self.net_id = 'foo_network_id'
     self.lsn_id = 'foo_lsn_id'
     self.lsn_port_id = 'foo_port_id'
     self.subnet_id = 'foo_subnet_id'
     self.mac_addr = 'aa:bb:cc:dd:ee:ff'
 def setUp(self):
     super(BindingDBTestCase, self).setUp()
     db_api.configure_db()
     self.addCleanup(db_api.clear_db)
     self.context = context.get_admin_context()
     resource = {'object_id': 'fake-object-id',
                 'resource_type': 'fake-resource-type',
                 'resource_id': 'fake-resource-id',
                 'resource_descriptor': 'com.vyatta.vm'}
     self.obj = dict(api.binding_add(self.context, resource))
示例#37
0
    def __init__(self):
        LOG.info(_('Neutron PLUMgrid Director: Starting Plugin'))

        # Plugin DB initialization
        db.configure_db()

        self.plumgrid_init()

        LOG.debug(_('Neutron PLUMgrid Director: Neutron server with '
                    'PLUMgrid Plugin has started'))
示例#38
0
 def setUp(self):
     super(OFCManagerTestBase, self).setUp()
     db.configure_db()
     driver = "neutron.tests.unit.nec.stub_ofc_driver.StubOFCDriver"
     config.CONF.set_override('driver', driver, 'OFC')
     self.addCleanup(ndb.clear_db)
     self.ofc = ofc_manager.OFCManager()
     # NOTE: enable_autocheck() is a feature of StubOFCDriver
     self.ofc.driver.enable_autocheck()
     self.ctx = context.get_admin_context()
     self.addCleanup(mock.patch.stopall)
示例#39
0
 def setUp(self):
     super(VxlanTypeTest, self).setUp()
     db.configure_db()
     cfg.CONF.set_override('vni_ranges', [TUNNEL_RANGES],
                           group='ml2_type_vxlan')
     cfg.CONF.set_override('vxlan_group', MULTICAST_GROUP,
                           group='ml2_type_vxlan')
     self.driver = type_vxlan.VxlanTypeDriver()
     self.driver.vxlan_vni_ranges = TUNNEL_RANGES
     self.driver._sync_vxlan_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#40
0
 def setUp(self):
     super(OFCManagerTestBase, self).setUp()
     db.configure_db()
     driver = "neutron.tests.unit.nec.stub_ofc_driver.StubOFCDriver"
     config.CONF.set_override('driver', driver, 'OFC')
     self.addCleanup(ndb.clear_db)
     self.plugin = mock.Mock()
     self.plugin.get_packet_filters_for_port.return_value = None
     self.ofc = ofc_manager.OFCManager(self.plugin)
     # NOTE: enable_autocheck() is a feature of StubOFCDriver
     self.ofc.driver.enable_autocheck()
     self.ctx = context.get_admin_context()
示例#41
0
 def initialize(self, sql_conn, sql_retries, interval, db_option):
     if db_option == omni_const.OMNI_TABLES:
         self.use_omni_tables = True
     elif db_option == omni_const.OVS_TABLES:
         self.use_omni_tables = False
     """
     options = {"sql_connection": "%s" % sql_conn }
     options.update({"sql_max_retries": sql_retries})
     options.update({"reconnect_interval": interval})
     options.update({"base": models_v2.model_base.BASEV2})
     db.configure_db(options)
     """
     db.configure_db()
示例#42
0
 def new_nexus_init(self):
     self._client = importutils.import_object(NEXUS_DRIVER)
     self._client.nexus_switches = {
         (NEXUS_IP_ADDRESS, HOSTNAME1): NEXUS_PORT1,
         (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
         (NEXUS_IP_ADDRESS, HOSTNAME2): NEXUS_PORT2,
         (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT,
     }
     self._client.credentials = {
         NEXUS_IP_ADDRESS: {
             'username': '******',
             'password': '******'
         },
     }
     db.configure_db()
示例#43
0
    def setUp(self):
        super(CiscoNetworkDbTest, self).setUp()
        db.configure_db()

        # The Cisco network plugin includes a thin layer of QoS and
        # credential API methods which indirectly call Cisco QoS and
        # credential database access methods. For better code coverage,
        # this test suite will make calls to the QoS and credential database
        # access methods indirectly through the network plugin. The network
        # plugin's init function can be mocked out for this purpose.
        def new_network_plugin_init(instance):
            pass
        with mock.patch.object(network_plugin.PluginV2,
                               '__init__', new=new_network_plugin_init):
            self._network_plugin = network_plugin.PluginV2()

        self.addCleanup(db.clear_db)
示例#44
0
    def __init__(self, configfile=None):
        db.configure_db()
        self.tunnel_key = db_api_v2.TunnelKey(cfg.CONF.OVS.tunnel_key_min,
                                              cfg.CONF.OVS.tunnel_key_max)
        self.ofp_api_host = cfg.CONF.OVS.openflow_rest_api
        if not self.ofp_api_host:
            raise q_exc.Invalid(_('Invalid configuration. check ryu.ini'))

        self.client = client.OFPClient(self.ofp_api_host)
        self.tun_client = client.TunnelClient(self.ofp_api_host)
        self.iface_client = client.NeutronIfaceClient(self.ofp_api_host)
        for nw_id in rest_nw_id.RESERVED_NETWORK_IDS:
            if nw_id != rest_nw_id.NW_ID_UNKNOWN:
                self.client.update_network(nw_id)
        self._setup_rpc()

        # register known all network list on startup
        self._create_all_tenant_network()
        def new_nexus_init(mech_instance):
            mech_instance.driver = importutils.import_object(NEXUS_DRIVER)

            mech_instance._nexus_switches = {}
            for name, config in TestCiscoNexusDevice.test_configs.items():
                ip_addr = config.nexus_ip_addr
                host_name = config.host_name
                nexus_port = config.nexus_port
                mech_instance._nexus_switches[(ip_addr,
                                               host_name)] = nexus_port
                mech_instance._nexus_switches[(ip_addr,
                                               'ssh_port')] = NEXUS_SSH_PORT
            mech_instance.driver.nexus_switches = (
                mech_instance._nexus_switches)

            mech_instance.driver.credentials = (
                TestCiscoNexusDevice.test_credentials)

            db.configure_db()
示例#46
0
        def new_nexus_init(mech_instance):
            mech_instance.driver = importutils.import_object(NEXUS_DRIVER)

            mech_instance._nexus_switches = {}
            for name, config in TestCiscoNexusDevice.test_configs.items():
                ip_addr = config.nexus_ip_addr
                host_name = config.host_name
                nexus_port = config.nexus_port
                mech_instance._nexus_switches[(ip_addr,
                                               host_name)] = nexus_port
                mech_instance._nexus_switches[(ip_addr,
                                               'ssh_port')] = NEXUS_SSH_PORT
                mech_instance._nexus_switches[(ip_addr,
                                               constants.USERNAME)] = 'admin'
                mech_instance._nexus_switches[(
                    ip_addr, constants.PASSWORD)] = 'password'
            mech_instance.driver.nexus_switches = (
                mech_instance._nexus_switches)

            db.configure_db()
示例#47
0
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        self._plugins = {}
        for key in conf.CISCO_PLUGINS.keys():
            plugin_obj = conf.CISCO_PLUGINS[key]
            if plugin_obj is not None:
                self._plugins[key] = importutils.import_object(plugin_obj)
                LOG.debug(_("Loaded device plugin %s"),
                          conf.CISCO_PLUGINS[key])

        if ((const.VSWITCH_PLUGIN in self._plugins)
                and hasattr(self._plugins[const.VSWITCH_PLUGIN],
                            "supported_extension_aliases")):
            self.supported_extension_aliases.extend(self._plugins[
                const.VSWITCH_PLUGIN].supported_extension_aliases)
        # At this point, all the database models should have been loaded. It's
        # possible that configure_db() may have been called by one of the
        # plugins loaded in above. Otherwise, this call is to make sure that
        # the database is initialized
        db_api.configure_db()

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug(_("%(module)s.%(name)s init done"), {
            'module': __name__,
            'name': self.__class__.__name__
        })

        # Check whether we have a valid Nexus driver loaded
        self.is_nexus_plugin = False
        nexus_driver = conf.CISCO.nexus_driver
        if nexus_driver.endswith('CiscoNEXUSDriver'):
            self.is_nexus_plugin = True
示例#48
0
    def __init__(self):
        """Initialize Brocade Plugin.

        Specify switch address and db configuration.
        """

        self.supported_extension_aliases = [
            "binding", "security-group", "router", "extraroute", "agent",
            "l3_agent_scheduler", "dhcp_agent_scheduler"
        ]

        self.physical_interface = (
            cfg.CONF.PHYSICAL_INTERFACE.physical_interface)
        db.configure_db()
        self.ctxt = context.get_admin_context()
        self.ctxt.session = db.get_session()
        self._vlan_bitmap = vbm.VlanBitmap(self.ctxt)
        self._setup_rpc()
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver)
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver)
        self.brocade_init()
示例#49
0
文件: plugin.py 项目: zioc/neutron
    def __init__(self):
        # Read config values
        midonet_conf = cfg.CONF.MIDONET
        midonet_uri = midonet_conf.midonet_uri
        admin_user = midonet_conf.username
        admin_pass = midonet_conf.password
        admin_project_id = midonet_conf.project_id
        self.provider_router_id = midonet_conf.provider_router_id
        self.provider_router = None

        self.mido_api = api.MidonetApi(midonet_uri, admin_user,
                                       admin_pass,
                                       project_id=admin_project_id)
        self.client = midonet_lib.MidoClient(self.mido_api)

        # self.provider_router_id should have been set.
        if self.provider_router_id is None:
            msg = _('provider_router_id should be configured in the plugin '
                    'config file')
            LOG.exception(msg)
            raise MidonetPluginException(msg=msg)

        self.setup_rpc()
        db.configure_db()
示例#50
0
    def __init__(self, configfile=None):
        self.base_binding_dict = {
            portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
            portbindings.CAPABILITIES: {
                portbindings.CAP_PORT_FILTER:
                'security-group' in self.supported_extension_aliases}}
        portbindings_base.register_port_dict_function()
        db.configure_db()
        self.tunnel_key = db_api_v2.TunnelKey(
            cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max)
        self.ofp_api_host = cfg.CONF.OVS.openflow_rest_api
        if not self.ofp_api_host:
            raise q_exc.Invalid(_('Invalid configuration. check ryu.ini'))

        self.client = client.OFPClient(self.ofp_api_host)
        self.tun_client = client.TunnelClient(self.ofp_api_host)
        self.iface_client = client.NeutronIfaceClient(self.ofp_api_host)
        for nw_id in rest_nw_id.RESERVED_NETWORK_IDS:
            if nw_id != rest_nw_id.NW_ID_UNKNOWN:
                self.client.update_network(nw_id)
        self._setup_rpc()

        # register known all network list on startup
        self._create_all_tenant_network()
示例#51
0
    def setUp(self):
        super(MetaNeutronPluginV2Test, self).setUp()
        db._ENGINE = None
        db._MAKER = None
        self.fake_tenant_id = uuidutils.generate_uuid()
        self.context = context.get_admin_context()

        db.configure_db()
        self.addCleanup(db.clear_db)
        self.addCleanup(unregister_meta_hooks)

        setup_metaplugin_conf(self.has_l3)

        self.client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
        client_cls = self.client_cls_p.start()
        self.client_inst = mock.Mock()
        client_cls.return_value = self.client_inst
        self.client_inst.create_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.create_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_network.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_port.return_value = \
            {'id': 'fake_id'}
        self.client_inst.update_subnet.return_value = \
            {'id': 'fake_id'}
        self.client_inst.delete_network.return_value = True
        self.client_inst.delete_port.return_value = True
        self.client_inst.delete_subnet.return_value = True
        plugin = (meta_neutron_plugin.MetaPluginV2.__module__ + '.' +
                  meta_neutron_plugin.MetaPluginV2.__name__)
        self.setup_coreplugin(plugin)
        self.plugin = meta_neutron_plugin.MetaPluginV2(configfile=None)
示例#52
0
 def setUp(self):
     super(VlanAllocationsTest, self).setUp()
     db.configure_db()
     ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#53
0
    def __init__(self, configfile=None):
        LOG.debug(_("Start initializing metaplugin"))
        self.supported_extension_aliases = \
            cfg.CONF.META.supported_extension_aliases.split(',')
        self.supported_extension_aliases += ['flavor', 'router',
                                             'ext-gw-mode', 'extraroute']

        # Ignore config option overapping
        def _is_opt_registered(opts, opt):
            if opt.dest in opts:
                return True
            else:
                return False

        cfg._is_opt_registered = _is_opt_registered

        # Keep existing tables if multiple plugin use same table name.
        db.model_base.NeutronBase.__table_args__ = {'keep_existing': True}

        self.plugins = {}

        plugin_list = [plugin_set.split(':')
                       for plugin_set
                       in cfg.CONF.META.plugin_list.split(',')]
        for flavor, plugin_provider in plugin_list:
            self.plugins[flavor] = self._load_plugin(plugin_provider)
            # Needed to clear _DB_ENGINE for each plugin
            db._DB_ENGINE = None

        self.l3_plugins = {}
        l3_plugin_list = [plugin_set.split(':')
                          for plugin_set
                          in cfg.CONF.META.l3_plugin_list.split(',')]
        for flavor, plugin_provider in l3_plugin_list:
            if flavor in self.plugins:
                self.l3_plugins[flavor] = self.plugins[flavor]
            else:
                # For l3 only plugin
                self.l3_plugins[flavor] = self._load_plugin(plugin_provider)
                db._DB_ENGINE = None

        self.default_flavor = cfg.CONF.META.default_flavor
        if self.default_flavor not in self.plugins:
            raise exc.Invalid(_('default_flavor %s is not plugin list') %
                              self.default_flavor)

        self.default_l3_flavor = cfg.CONF.META.default_l3_flavor
        if self.default_l3_flavor not in self.l3_plugins:
            raise exc.Invalid(_('default_l3_flavor %s is not plugin list') %
                              self.default_l3_flavor)

        db.configure_db()

        self.extension_map = {}
        if not cfg.CONF.META.extension_map == '':
            extension_list = [method_set.split(':')
                              for method_set
                              in cfg.CONF.META.extension_map.split(',')]
            for method_name, flavor in extension_list:
                self.extension_map[method_name] = flavor

        self.default_flavor = cfg.CONF.META.default_flavor
示例#54
0
文件: db.py 项目: wputra/MOS-centos
def initialize():
    db.configure_db()
示例#55
0
 def setUp(self):
     super(NetworkBindingsTest, self).setUp()
     db.configure_db()
     self.session = db.get_session()
示例#56
0
 def setUp(self):
     super(NetworkStatesTest, self).setUp()
     db.configure_db()
     lb_db.sync_network_states(VLAN_RANGES)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#57
0
 def setUp(self):
     cfg.CONF.set_override('network_vlan_ranges', ['physnet1:1000:2999'],
                           group='VLANS')
     super(NetworkBindingsTest, self).setUp(plugin=PLUGIN_NAME)
     db.configure_db()
     self.session = db.get_session()
示例#58
0
 def setUp(self):
     super(NsxDBTestCase, self).setUp()
     db.configure_db()
     self.ctx = context.get_admin_context()
     self.addCleanup(db.clear_db)
示例#59
0
 def setUp(self):
     super(SegmentationIdAllocationTest, self).setUp()
     db.configure_db()
     mlnx_db.sync_network_states(VLAN_RANGES)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
示例#60
0
文件: db.py 项目: nabilmaad/neutron
 def initialize(self):
     db_api.configure_db()