本文整理汇总了Python中charmhelpers.contrib.openstack.context.SharedDBContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.SharedDBContext方法的具体用法?Python context.SharedDBContext怎么用?Python context.SharedDBContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.openstack.context
的用法示例。
在下文中一共展示了context.SharedDBContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shared_db_context_with_data
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_data(self):
'''Test shared-db context with all required data'''
relation = FakeRelation(relation_data=SHARED_DB_RELATION)
self.relation_get.side_effect = relation.get
self.get_address_in_network.return_value = ''
self.config.side_effect = fake_config(SHARED_DB_CONFIG)
shared_db = context.SharedDBContext()
result = shared_db()
expected = {
'database_host': 'dbserver.local',
'database': 'foodb',
'database_user': 'adam',
'database_password': 'foo',
'database_type': 'mysql',
}
self.assertEquals(result, expected)
示例2: test_shared_db_context_with_data_and_access_net_match
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_data_and_access_net_match(self):
"""Correctly set hostname for access net returns complete context"""
relation = FakeRelation(
relation_data=SHARED_DB_RELATION_ACCESS_NETWORK)
self.relation_get.side_effect = relation.get
self.get_address_in_network.return_value = 'bar'
self.config.side_effect = fake_config(SHARED_DB_CONFIG)
shared_db = context.SharedDBContext()
result = shared_db()
expected = {
'database_host': 'dbserver.local',
'database': 'foodb',
'database_user': 'adam',
'database_password': 'foo',
'database_type': 'mysql',
}
self.assertEquals(result, expected)
示例3: test_shared_db_context_with_ipv6
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_ipv6(self, format_ipv6_addr):
'''Test shared-db context with ipv6'''
shared_db = context.SharedDBContext(
database='quantum', user='quantum', relation_prefix='quantum')
relation = FakeRelation(relation_data=SHARED_DB_RELATION_NAMESPACED)
self.relation_get.side_effect = relation.get
format_ipv6_addr.return_value = '[2001:db8:1::1]'
result = shared_db()
self.assertIn(
call(rid='foo:0', unit='foo/0'),
self.relation_get.call_args_list)
self.assertEquals(
result, {'database': 'quantum',
'database_user': 'quantum',
'database_password': 'bar2',
'database_host': '[2001:db8:1::1]',
'database_type': 'mysql'})
示例4: quantum_plugins
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def quantum_plugins():
from charmhelpers.contrib.openstack import context
return {
'ovs': {
'config': '/etc/quantum/plugins/openvswitch/'
'ovs_quantum_plugin.ini',
'driver': 'quantum.plugins.openvswitch.ovs_quantum_plugin.'
'OVSQuantumPluginV2',
'contexts': [
context.SharedDBContext(user=config('neutron-database-user'),
database=config('neutron-database'),
relation_prefix='neutron',
ssl_dir=QUANTUM_CONF_DIR)],
'services': ['quantum-plugin-openvswitch-agent'],
'packages': [determine_dkms_package(),
['quantum-plugin-openvswitch-agent']],
'server_packages': ['quantum-server',
'quantum-plugin-openvswitch'],
'server_services': ['quantum-server']
},
'nvp': {
'config': '/etc/quantum/plugins/nicira/nvp.ini',
'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'
'QuantumPlugin.NvpPluginV2',
'contexts': [
context.SharedDBContext(user=config('neutron-database-user'),
database=config('neutron-database'),
relation_prefix='neutron',
ssl_dir=QUANTUM_CONF_DIR)],
'services': [],
'packages': [],
'server_packages': ['quantum-server',
'quantum-plugin-nicira'],
'server_services': ['quantum-server']
}
}
示例5: test_shared_db_context_with_data_and_access_net_mismatch
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_data_and_access_net_mismatch(self):
"""Mismatch between hostname and hostname for access net - defers
execution"""
relation = FakeRelation(
relation_data=SHARED_DB_RELATION_ACCESS_NETWORK)
self.relation_get.side_effect = relation.get
self.get_address_in_network.return_value = '10.5.5.1'
self.config.side_effect = fake_config(SHARED_DB_CONFIG)
shared_db = context.SharedDBContext()
result = shared_db()
self.assertEquals(result, None)
self.relation_set.assert_called_with(
relation_settings={
'hostname': '10.5.5.1'})
示例6: test_shared_db_context_with_missing_relation
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_missing_relation(self):
'''Test shared-db context missing relation data'''
incomplete_relation = copy(SHARED_DB_RELATION)
incomplete_relation['password'] = None
relation = FakeRelation(relation_data=incomplete_relation)
self.relation_get.side_effect = relation.get
self.config.return_value = SHARED_DB_CONFIG
shared_db = context.SharedDBContext()
result = shared_db()
self.assertEquals(result, {})
示例7: test_shared_db_context_with_missing_config
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def test_shared_db_context_with_missing_config(self):
'''Test shared-db context missing relation data'''
incomplete_config = copy(SHARED_DB_CONFIG)
del incomplete_config['database-user']
self.config.side_effect = fake_config(incomplete_config)
relation = FakeRelation(relation_data=SHARED_DB_RELATION)
self.relation_get.side_effect = relation.get
self.config.return_value = incomplete_config
shared_db = context.SharedDBContext()
self.assertRaises(context.OSContextError, shared_db)
示例8: register_configs
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import SharedDBContext [as 别名]
def register_configs():
''' Register config files with their respective contexts. '''
release = os_release('openstack-dashboard')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
confs = [LOCAL_SETTINGS,
HAPROXY_CONF,
PORTS_CONF]
if CompareOpenStackReleases(release) >= 'mitaka':
configs.register(KEYSTONEV3_POLICY,
CONFIG_FILES[KEYSTONEV3_POLICY]['hook_contexts'])
CONFIG_FILES[LOCAL_SETTINGS]['hook_contexts'].append(
context.SharedDBContext(
user=config('database-user'),
database=config('database'),
ssl_dir=DASHBOARD_CONF_DIR))
for conf in confs:
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
if os.path.isdir(APACHE_CONF_DIR) and cmp_pkgrevno('apache2', '2.4') >= 0:
for conf in [APACHE_CONF, APACHE_SSL, APACHE_DEFAULT]:
if os.path.isfile(conf):
log('Removing old config %s' % (conf))
os.remove(conf)
configs.register(APACHE_24_DEFAULT,
CONFIG_FILES[APACHE_24_DEFAULT]['hook_contexts'])
configs.register(APACHE_24_CONF,
CONFIG_FILES[APACHE_24_CONF]['hook_contexts'])
configs.register(APACHE_24_SSL,
CONFIG_FILES[APACHE_24_SSL]['hook_contexts'])
else:
configs.register(APACHE_DEFAULT,
CONFIG_FILES[APACHE_DEFAULT]['hook_contexts'])
configs.register(APACHE_CONF,
CONFIG_FILES[APACHE_CONF]['hook_contexts'])
configs.register(APACHE_SSL,
CONFIG_FILES[APACHE_SSL]['hook_contexts'])
if os.path.exists(os.path.dirname(ROUTER_SETTING)):
configs.register(ROUTER_SETTING,
CONFIG_FILES[ROUTER_SETTING]['hook_contexts'])
return configs