• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.configure_db函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.db.api.configure_db函数的典型用法代码示例。如果您正苦于以下问题:Python configure_db函数的具体用法?Python configure_db怎么用?Python configure_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了configure_db函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

 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)
开发者ID:ArifovicH,项目名称:neutron,代码行数:7,代码来源:test_dhcp_scheduler.py


示例2: setUp

 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)
开发者ID:NKSG,项目名称:neutron,代码行数:7,代码来源:test_type_flat.py


示例3: __init__

    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'))
开发者ID:bmadabus,项目名称:neutron,代码行数:31,代码来源:plumgrid_plugin.py


示例4: setUp

    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)
开发者ID:blamarvt,项目名称:quark,代码行数:7,代码来源:test_ports.py


示例5: setUp

 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)
开发者ID:PFZheng,项目名称:neutron,代码行数:7,代码来源:test_n1kv_db.py


示例6: new_nexus_init

 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': 'admin',
             'password': 'pass1234'
         },
         NEXUS_PC_IP_ADDRESS: {
             'username': 'admin',
             'password': 'password'
         },
     }
     db.configure_db()
开发者ID:50infivedays,项目名称:neutron,代码行数:31,代码来源:test_nexus_plugin.py


示例7: __init__

    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()
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:34,代码来源:plugin.py


示例8: setUp

    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)
开发者ID:Doude,项目名称:neutron,代码行数:33,代码来源:test_quota_ext.py


示例9: setUp

    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')
开发者ID:50infivedays,项目名称:neutron,代码行数:28,代码来源:test_cisco_ipsec.py


示例10: __init__

    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__})
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:32,代码来源:virt_phy_sw_v2.py


示例11: setUp

    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()
开发者ID:mohanraj1311,项目名称:quark,代码行数:7,代码来源:test_quark_plugin.py


示例12: setUp

    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)
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:33,代码来源:test_metaplugin.py


示例13: __init__

    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
开发者ID:CampHarmony,项目名称:neutron,代码行数:60,代码来源:meta_neutron_plugin.py


示例14: __init__

    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()
开发者ID:av-mido,项目名称:neutron,代码行数:25,代码来源:plugin.py


示例15: setUp

    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()
开发者ID:kilogram,项目名称:quark,代码行数:7,代码来源:test_ipam.py


示例16: setUp

    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)
开发者ID:mohanraj1311,项目名称:quark,代码行数:7,代码来源:test_ip_addresses.py


示例17: setUp

    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)
开发者ID:mohanraj1311,项目名称:quark,代码行数:7,代码来源:test_db_api.py


示例18: setUp

    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)
开发者ID:aaronknister,项目名称:neutron,代码行数:35,代码来源:test_metaplugin.py


示例19: __init__

    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()
开发者ID:noxhana,项目名称:neutron,代码行数:27,代码来源:NeutronPlugin.py


示例20: setUp

    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)
开发者ID:blamarvt,项目名称:quark-1,代码行数:7,代码来源:test_ipam.py



注:本文中的neutron.db.api.configure_db函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.get_engine函数代码示例发布时间:2022-05-27
下一篇:
Python api.autonested_transaction函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap