本文整理汇总了Python中charmhelpers.contrib.openstack.context.PostgresqlDBContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.PostgresqlDBContext方法的具体用法?Python context.PostgresqlDBContext怎么用?Python context.PostgresqlDBContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.openstack.context
的用法示例。
在下文中一共展示了context.PostgresqlDBContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_postgresql_db_context_with_data
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import PostgresqlDBContext [as 别名]
def test_postgresql_db_context_with_data(self):
'''Test postgresql-db context with all required data'''
relation = FakeRelation(relation_data=POSTGRESQL_DB_RELATION)
self.relation_get.side_effect = relation.get
self.config.side_effect = fake_config(POSTGRESQL_DB_CONFIG)
postgresql_db = context.PostgresqlDBContext()
result = postgresql_db()
expected = {
'database_host': 'dbserver.local',
'database': 'foodb',
'database_user': 'adam',
'database_password': 'foo',
'database_type': 'postgresql',
}
self.assertEquals(result, expected)
示例2: test_postgresql_db_context_with_missing_relation
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import PostgresqlDBContext [as 别名]
def test_postgresql_db_context_with_missing_relation(self):
'''Test postgresql-db context missing relation data'''
incomplete_relation = copy(POSTGRESQL_DB_RELATION)
incomplete_relation['password'] = None
relation = FakeRelation(relation_data=incomplete_relation)
self.relation_get.side_effect = relation.get
self.config.return_value = POSTGRESQL_DB_CONFIG
postgresql_db = context.PostgresqlDBContext()
result = postgresql_db()
self.assertEquals(result, {})
示例3: test_postgresql_db_context_with_missing_config
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import PostgresqlDBContext [as 别名]
def test_postgresql_db_context_with_missing_config(self):
'''Test postgresql-db context missing relation data'''
incomplete_config = copy(POSTGRESQL_DB_CONFIG)
del incomplete_config['database']
self.config.side_effect = fake_config(incomplete_config)
relation = FakeRelation(relation_data=POSTGRESQL_DB_RELATION)
self.relation_get.side_effect = relation.get
self.config.return_value = incomplete_config
postgresql_db = context.PostgresqlDBContext()
self.assertRaises(context.OSContextError, postgresql_db)
示例4: test_postgresql_db_context_with_params
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import PostgresqlDBContext [as 别名]
def test_postgresql_db_context_with_params(self):
'''Test postgresql-db context with object parameters'''
postgresql_db = context.PostgresqlDBContext(database='quantum')
result = postgresql_db()
self.assertEquals(result['database'], 'quantum')
示例5: resource_map
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import PostgresqlDBContext [as 别名]
def resource_map(release=None):
'''
Dynamically generate a map of resources that will be managed for a single
hook execution.
'''
release = release or os_release('neutron-common')
resource_map = deepcopy(BASE_RESOURCE_MAP)
if CompareOpenStackReleases(release) >= 'liberty':
resource_map.update(LIBERTY_RESOURCE_MAP)
if os.path.exists('/etc/apache2/conf-available'):
resource_map.pop(APACHE_CONF)
else:
resource_map.pop(APACHE_24_CONF)
if manage_plugin():
# add neutron plugin requirements. nova-c-c only needs the
# neutron-server associated with configs, not the plugin agent.
plugin = config('neutron-plugin')
conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
[])
services = neutron_plugin_attribute(plugin, 'server_services',
'neutron')
resource_map[conf] = {}
resource_map[conf]['services'] = services
resource_map[conf]['contexts'] = ctxts
resource_map[conf]['contexts'].append(
neutron_api_context.NeutronCCContext())
# update for postgres
resource_map[conf]['contexts'].append(
context.PostgresqlDBContext(database=config('database')))
if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and
config('enable-sriov')):
resource_map[ML2_SRIOV_INI] = {}
resource_map[ML2_SRIOV_INI]['services'] = services
resource_map[ML2_SRIOV_INI]['contexts'] = []
else:
resource_map[NEUTRON_CONF]['contexts'].append(
neutron_api_context.NeutronApiSDNContext()
)
resource_map[NEUTRON_DEFAULT]['contexts'] = \
[neutron_api_context.NeutronApiSDNConfigFileContext()]
if enable_memcache(release=release):
resource_map[MEMCACHED_CONF] = {
'contexts': [context.MemcacheContext()],
'services': ['memcached']}
return resource_map