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

Python api.configure_db函数代码示例

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

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



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

示例1: __init__

    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)
        ofp_con_host = cfg.CONF.OVS.openflow_controller
        ofp_api_host = cfg.CONF.OVS.openflow_rest_api

        if ofp_con_host is None or ofp_api_host is None:
            raise q_exc.Invalid(_('Invalid configuration. check ryu.ini'))

        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER),
                 (ofp_api_host, ofp_service_type.REST_API)]
        db_api_v2.set_ofp_servers(hosts)

        self.client = client.OFPClient(ofp_api_host)
        self.tun_client = client.TunnelClient(ofp_api_host)
        self.iface_client = client.QuantumIfaceClient(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()
开发者ID:abhiraut,项目名称:quantum,代码行数:25,代码来源:ryu_quantum_plugin.py


示例2: __init__

    def __init__(self):
        LOG.info(_('QuantumPluginPLUMgrid 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
        nos_username = cfg.CONF.PLUMgridNOS.username
        nos_password = cfg.CONF.PLUMgridNOS.password
        self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
                                                        nos_port, timeout)
        if self.rest_conn is None:
            raise SystemExit(_('QuantumPluginPLUMgrid Status: '
                               'Aborting Plugin'))

        else:
            # Plugin DB initialization
            db.configure_db()

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

            LOG.debug(_('QuantumPluginPLUMgrid Status: Quantum server with '
                        'PLUMgrid Plugin has started'))
开发者ID:wdec,项目名称:quantum,代码行数:31,代码来源:plumgrid_plugin.py


示例3: __init__

    def __init__(self, configfile=None):
        if configfile is None:
            if os.path.exists(CONF_FILE):
                configfile = CONF_FILE
            else:
                configfile = find_config(os.path.abspath(
                    os.path.dirname(__file__)))
        if configfile is None:
            raise Exception("Configuration file \"%s\" doesn't exist" %
                            (configfile))
        LOG.debug("Using configuration file: %s" % configfile)
        conf = config.parse(configfile)
        options = {"sql_connection": conf.DATABASE.sql_connection}
        reconnect_interval = conf.DATABASE.reconnect_interval
        options.update({"reconnect_interval": reconnect_interval})
        db.configure_db(options)

        self.vmap = VlanMap()
        # Populate the map with anything that is already present in the
        # database
        vlans = ovs_db.get_vlans()
        for x in vlans:
            vlan_id, network_id = x
            LOG.debug("Adding already populated vlan %s -> %s" %
                      (vlan_id, network_id))
            self.vmap.already_used(vlan_id, network_id)
开发者ID:jkoelker,项目名称:quantum,代码行数:26,代码来源:ovs_quantum_plugin.py


示例4: __init__

 def __init__(self):
     # NOTE(jkoelker) This is an incomlete implementation. Subclasses
     #                must override __init__ and setup the database
     #                and not call into this class's __init__.
     #                This connection is setup as memory for the tests.
     sql_connection = "sqlite:///:memory:"
     db.configure_db({"sql_connection": sql_connection, "base": models_v2.model_base.BASEV2})
开发者ID:xchenum,项目名称:quantum-bug,代码行数:7,代码来源:db_base_plugin_v2.py


示例5: __init__

    def __init__(self, configfile=None):
        options = {"sql_connection": cfg.CONF.DATABASE.sql_connection}
        options.update({"base": models_v2.model_base.BASEV2})
        reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
        options.update({"reconnect_interval": reconnect_interval})
        db.configure_db(options)

        self.tunnel_key = db_api_v2.TunnelKey(cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max)
        ofp_con_host = cfg.CONF.OVS.openflow_controller
        ofp_api_host = cfg.CONF.OVS.openflow_rest_api

        if ofp_con_host is None or ofp_api_host is None:
            raise q_exc.Invalid(_("invalid configuration. check ryu.ini"))

        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER), (ofp_api_host, ofp_service_type.REST_API)]
        db_api_v2.set_ofp_servers(hosts)

        self.client = client.OFPClient(ofp_api_host)
        self.tun_client = client.TunnelClient(ofp_api_host)
        self.iface_client = client.QuantumIfaceClient(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()
开发者ID:dani4571,项目名称:quantum,代码行数:27,代码来源:ryu_quantum_plugin.py


示例6: setUp

    def setUp(self):
        super(QuarkIpamBaseTest, self).setUp()

        cfg.CONF.set_override("sql_connection", "sqlite://", "DATABASE")
        quantum_db_api.configure_db()
        models.BASEV2.metadata.create_all(quantum_db_api._ENGINE)
        self.ipam = quark.ipam.QuarkIpam()
开发者ID:ugoring,项目名称:quark,代码行数:7,代码来源:test_ipam.py


示例7: __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:DestinyOneSystems,项目名称:quantum,代码行数:32,代码来源:virt_phy_sw_v2.py


示例8: initialize

def initialize():
    options = {"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection}
    options.update({"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries})
    options.update({"reconnect_interval":cfg.CONF.DATABASE.reconnect_interval})
    options.update({"base": HW_BASE})
    options.update({"sql_dbpool_enable":cfg.CONF.DATABASE.sql_dbpool_enable})
    db.configure_db(options)
开发者ID:wangchang,项目名称:OpenStack-MPLS-FOR-WAN,代码行数:7,代码来源:huawei_db_base.py


示例9: setUp

    def setUp(self):
        super(MetaQuantumPluginV2Test, 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()
        args = ['--config-file', etcdir('quantum.conf.test')]
        self.client_cls_p = mock.patch('quantumclient.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:abhiraut,项目名称:quantum,代码行数:34,代码来源:test_metaplugin.py


示例10: __init__

    def __init__(self, configfile=None):
        config = ConfigParser.ConfigParser()
        if configfile is None:
            if os.path.exists(CONF_FILE):
                configfile = CONF_FILE
            else:
                configfile = find_config(os.path.abspath(
                        os.path.dirname(__file__)))
        if configfile is None:
            raise Exception("Configuration file \"%s\" doesn't exist" %
              (configfile))
        LOG.debug("Using configuration file: %s" % configfile)
        config.read(configfile)
        LOG.debug("Config: %s" % config)

        options = {"sql_connection": config.get("DATABASE", "sql_connection")}
        db.configure_db(options)

        self.vmap = VlanMap()
        # Populate the map with anything that is already present in the
        # database
        vlans = ovs_db.get_vlans()
        for x in vlans:
            vlan_id, network_id = x
            # LOG.debug("Adding already populated vlan %s -> %s"
            #                                   % (vlan_id, network_id))
            self.vmap.set_vlan(vlan_id, network_id)
开发者ID:OpenStack-Kha,项目名称:quantum,代码行数:27,代码来源:ovs_quantum_plugin.py


示例11: initialize

def initialize():
    options = {"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection}
    options.update({"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries})
    options.update({"reconnect_interval":
                   cfg.CONF.DATABASE.reconnect_interval})
    options.update({"base": models_v2.model_base.BASEV2})
    db.configure_db(options)
开发者ID:bestsharp,项目名称:rgos_quantum_plugin,代码行数:7,代码来源:vlan_mgr.py


示例12: setUp

    def setUp(self):
        super(VPNTestCase, self).setUp()
        plugin = ("quantum.tests.unit.test_vpn.VPNTestPlugin")

        # point config file to: quantum/tests/etc/quantum.conf.test
        args = ['--config-file', test_api_v2.etcdir('quantum.conf.test')]
        config.parse(args=args)

        #just stubbing core plugin with VPN plugin
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('service_plugins', [plugin])
        self.addCleanup(cfg.CONF.reset)

        # Ensure 'stale' patched copies of the plugin are never returned
        quantum.manager.QuantumManager._instance = None

        # Ensure the database is reset between tests
        db._ENGINE = None
        db._MAKER = None
        db.configure_db()
        # Ensure existing ExtensionManager is not used

        ext_mgr = extensions.PluginAwareExtensionManager(
            extensions_path,
            {constants.VPN: VPNTestPlugin()}
        )
        extensions.PluginAwareExtensionManager._instance = ext_mgr
        router.APIRouter()

        app = config.load_paste_app('extensions_test_app')
        self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)

        self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1"
        self._subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14"
开发者ID:liqin75,项目名称:vse-vpnaas-plugin,代码行数:34,代码来源:test_vpn.py


示例13: __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:Apsu,项目名称:quantum,代码行数:34,代码来源:plugin.py


示例14: setUp

    def setUp(self):
        config = utils.get_config()
        options = {"sql_connection": config.get("DATABASE", "sql_connection")}
        db.configure_db(options)

        self.config = config
        self.mox = mox.Mox()
        self.stubs = stubout.StubOutForTesting()
开发者ID:LuizOz,项目名称:quantum,代码行数:8,代码来源:basetest.py


示例15: __init__

    def __init__(self, loglevel=None):
        if loglevel:
            logging.basicConfig(level=loglevel)
            nvplib.LOG.setLevel(loglevel)
            NvpApiClient.LOG.setLevel(loglevel)

        self.db_opts, self.nvp_opts, self.clusters_opts = parse_config()
        self.clusters = []
        for c_opts in self.clusters_opts:
            # Password is guaranteed to be the same across all controllers
            # in the same NVP cluster.
            cluster = NVPCluster(c_opts["name"])
            for controller_connection in c_opts["nvp_controller_connection"]:
                args = controller_connection.split(":")
                try:
                    args.extend([c_opts["default_tz_uuid"], c_opts["nvp_cluster_uuid"], c_opts["nova_zone_id"]])
                    cluster.add_controller(*args)
                except Exception:
                    LOG.exception(
                        "Invalid connection parameters for " "controller %s in cluster %s",
                        controller_connection,
                        c_opts["name"],
                    )
                    raise

            api_providers = [(x["ip"], x["port"], True) for x in cluster.controllers]
            cluster.api_client = NvpApiClient.NVPApiHelper(
                api_providers,
                cluster.user,
                cluster.password,
                request_timeout=cluster.request_timeout,
                http_timeout=cluster.http_timeout,
                retries=cluster.retries,
                redirects=cluster.redirects,
                failover_time=self.nvp_opts["failover_time"],
                concurrent_connections=self.nvp_opts["concurrent_connections"],
            )

            # TODO(salvatore-orlando): do login at first request,
            # not when plugin, is instantiated
            cluster.api_client.login()

            # TODO(pjb): What if the cluster isn't reachable this
            # instant?  It isn't good to fall back to invalid cluster
            # strings.
            # Default for future-versions
            self.clusters.append(cluster)

        # Connect and configure ovs_quantum db
        options = {
            "sql_connection": self.db_opts["sql_connection"],
            "sql_max_retries": self.db_opts["sql_max_retries"],
            "reconnect_interval": self.db_opts["reconnect_interval"],
            "base": models_v2.model_base.BASEV2,
        }
        db.configure_db(options)
        self.setup_rpc()
开发者ID:carriercomm,项目名称:quantum-7,代码行数:57,代码来源:QuantumPlugin.py


示例16: setUp

    def setUp(self):
        config = utils.get_config()
        options = {"sql_connection": config.get("DATABASE", "sql_connection")}
        options.update({'base': models_v2.model_base.BASEV2})
        db.configure_db(options)

        self.config = config
        self.mox = mox.Mox()
        self.stubs = stubout.StubOutForTesting()
开发者ID:t-lin,项目名称:quantum,代码行数:9,代码来源:basetest.py


示例17: test_warn_when_no_connection

 def test_warn_when_no_connection(self):
     with mock.patch.object(db, 'register_models') as mock_register:
         mock_register.return_value = False
         with mock.patch.object(db.LOG, 'warn') as mock_log:
             mock_log.return_value = False
             db.configure_db()
             self.assertEqual(mock_log.call_count, 1)
             args = mock_log.call_args
             self.assertNotEqual(args.find('sql_connection'), -1)
开发者ID:ericwanghp,项目名称:quantum,代码行数:9,代码来源:test_db.py


示例18: new_nexus_init

 def new_nexus_init(self):
     self._client = importutils.import_object(NEXUS_DRIVER)
     self._nexus_ip = NEXUS_IP_ADDRESS
     self._nexus_username = NEXUS_USERNAME
     self._nexus_password = NEXUS_PASSWORD
     self._nexus_ports = NEXUS_PORTS
     self._nexus_ssh_port = NEXUS_SSH_PORT
     self.credentials = {self._nexus_ip: {"username": self._nexus_username, "password": self._nexus_password}}
     db.configure_db()
开发者ID:NCU-PDCLAB,项目名称:quantum,代码行数:9,代码来源:test_nexus_plugin.py


示例19: initialize

def initialize(base=None):
    global L2_MODEL
    options = {"sql_connection": "%s" % CONF.DATABASE.sql_connection}
    options.update({"reconnect_interval": CONF.DATABASE.reconnect_interval})
    if base:
        options.update({"base": base})
        L2_MODEL = l2network_models_v2
    db.configure_db(options)
    create_vlanids()
开发者ID:danhan,项目名称:quantum,代码行数:9,代码来源:l2network_db.py


示例20: initialize

def initialize():
    options = {"sql_connection": "%s" % config.DATABASE.sql_connection,
               "sql_max_retries": config.DATABASE.sql_max_retries,
               "reconnect_interval": config.DATABASE.reconnect_interval,
               "base": model_base.BASEV2,
               "sql_min_pool_size": config.CONF.DATABASE.sql_min_pool_size,
               "sql_max_pool_size": config.CONF.DATABASE.sql_max_pool_size,
               "sql_idle_timeout": config.CONF.DATABASE.sql_idle_timeout,
               "sql_dbpool_enable": config.CONF.DATABASE.sql_dbpool_enable}
    db.configure_db(options)
开发者ID:alexpilotti,项目名称:quantum,代码行数:10,代码来源:api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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