當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。