本文整理汇总了Python中quantum.db.api.configure_db函数的典型用法代码示例。如果您正苦于以下问题:Python configure_db函数的具体用法?Python configure_db怎么用?Python configure_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了configure_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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'))
示例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)
示例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})
示例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()
示例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()
示例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__})
示例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)
示例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)
示例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)
示例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)
示例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"
示例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()
示例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()
示例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()