当前位置: 首页>>代码示例>>Python>>正文


Python context.PostgresqlDBContext方法代码示例

本文整理汇总了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) 
开发者ID:juju,项目名称:charm-helpers,代码行数:17,代码来源:test_os_contexts.py

示例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, {}) 
开发者ID:juju,项目名称:charm-helpers,代码行数:12,代码来源:test_os_contexts.py

示例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) 
开发者ID:juju,项目名称:charm-helpers,代码行数:12,代码来源:test_os_contexts.py

示例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') 
开发者ID:juju,项目名称:charm-helpers,代码行数:7,代码来源:test_os_contexts.py

示例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 
开发者ID:openstack,项目名称:charm-neutron-api,代码行数:54,代码来源:neutron_api_utils.py


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