當前位置: 首頁>>代碼示例>>Python>>正文


Python context.SharedDBContext方法代碼示例

本文整理匯總了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) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:18,代碼來源:test_os_contexts.py

示例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) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:19,代碼來源:test_os_contexts.py

示例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'}) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:19,代碼來源:test_os_contexts.py

示例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']
        }
    } 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:38,代碼來源:neutron.py

示例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'}) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:16,代碼來源:test_os_contexts.py

示例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, {}) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:12,代碼來源:test_os_contexts.py

示例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) 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:12,代碼來源:test_os_contexts.py

示例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 
開發者ID:openstack,項目名稱:charm-openstack-dashboard,代碼行數:48,代碼來源:horizon_utils.py


注:本文中的charmhelpers.contrib.openstack.context.SharedDBContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。