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


Python context.IdentityServiceContext方法代码示例

本文整理汇总了Python中charmhelpers.contrib.openstack.context.IdentityServiceContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.IdentityServiceContext方法的具体用法?Python context.IdentityServiceContext怎么用?Python context.IdentityServiceContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charmhelpers.contrib.openstack.context的用法示例。


在下文中一共展示了context.IdentityServiceContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_keystone_manager_from_identity_service_context

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def get_keystone_manager_from_identity_service_context():
    """Return a keystonmanager generated from a
    instance of charmhelpers.contrib.openstack.context.IdentityServiceContext
    @returns keystonamenager instance
   """
    context = IdentityServiceContext()()
    if not context:
        msg = "Identity service context cannot be generated"
        log(msg, level=ERROR)
        raise ValueError(msg)

    endpoint = format_endpoint(context['service_protocol'],
                               context['service_host'],
                               context['service_port'],
                               context['api_version'])

    if context['api_version'] in (2, "2.0"):
        api_version = 2
    else:
        api_version = 3

    return get_keystone_manager(endpoint, api_version,
                                username=context['admin_user'],
                                password=context['admin_password'],
                                tenant_name=context['admin_tenant_name']) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:27,代码来源:keystone.py

示例2: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def __call__(self):
        ctxt = super(IdentityServiceContext, self).__call__()
        if not ctxt:
            return

        ctxt['admin_token'] = None
        for relid in relation_ids('identity-service'):
            for unit in related_units(relid):
                if not ctxt.get('admin_token'):
                    ctxt['admin_token'] = \
                        relation_get('admin_token', unit, relid)

        if cmp_pkgrevno('radosgw', "10.2.0") >= 0:
            ctxt['auth_keystone_v3_supported'] = True
        ctxt['auth_type'] = 'keystone'
        ctxt['user_roles'] = config('operator-roles')
        ctxt['cache_size'] = config('cache-size')
        ctxt['revocation_check_interval'] = config('revocation-check-interval')
        if self.context_complete(ctxt):
            return ctxt

        return {} 
开发者ID:openstack,项目名称:charm-ceph-radosgw,代码行数:24,代码来源:ceph_radosgw_context.py

示例3: test_identity_service_context_with_data

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_data(self):
        '''Test shared-db context with all required data'''
        relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_UNSET)
        self.relation_get.side_effect = relation.get
        identity_service = context.IdentityServiceContext()
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': None,
            'admin_user': 'adam',
            'auth_host': 'keystone-host.local',
            'auth_port': '35357',
            'auth_protocol': 'http',
            'service_host': 'keystonehost.local',
            'service_port': '5000',
            'service_protocol': 'http',
            'api_version': '2.0',
        }
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:22,代码来源:test_os_contexts.py

示例4: test_identity_service_context_with_cache

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_cache(self):
        '''Test shared-db context with signing cache info'''
        relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_UNSET)
        self.relation_get.side_effect = relation.get
        svc = 'cinder'
        identity_service = context.IdentityServiceContext(service=svc,
                                                          service_user=svc)
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': None,
            'admin_user': 'adam',
            'auth_host': 'keystone-host.local',
            'auth_port': '35357',
            'auth_protocol': 'http',
            'service_host': 'keystonehost.local',
            'service_port': '5000',
            'service_protocol': 'http',
            'signing_dir': '/var/cache/cinder',
            'api_version': '2.0',
        }
        self.assertTrue(self.mkdir.called)
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:26,代码来源:test_os_contexts.py

示例5: test_identity_service_context_with_data_http

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_data_http(self):
        '''Test shared-db context with all required data'''
        relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_HTTP)
        self.relation_get.side_effect = relation.get
        identity_service = context.IdentityServiceContext()
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': '123456',
            'admin_user': 'adam',
            'auth_host': 'keystone-host.local',
            'auth_port': '35357',
            'auth_protocol': 'http',
            'service_host': 'keystonehost.local',
            'service_port': '5000',
            'service_protocol': 'http',
            'api_version': '2.0',
        }
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:22,代码来源:test_os_contexts.py

示例6: test_identity_service_context_with_data_https

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_data_https(self):
        '''Test shared-db context with all required data'''
        relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_HTTPS)
        self.relation_get.side_effect = relation.get
        identity_service = context.IdentityServiceContext()
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': None,
            'admin_user': 'adam',
            'auth_host': 'keystone-host.local',
            'auth_port': '35357',
            'auth_protocol': 'https',
            'service_host': 'keystonehost.local',
            'service_port': '5000',
            'service_protocol': 'https',
            'api_version': '2.0',
        }
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:22,代码来源:test_os_contexts.py

示例7: test_identity_service_context_with_ipv6

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_ipv6(self, format_ipv6_addr):
        '''Test identity-service context with ipv6'''
        relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_HTTP)
        self.relation_get.side_effect = relation.get
        format_ipv6_addr.return_value = '[2001:db8:1::1]'
        identity_service = context.IdentityServiceContext()
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': '123456',
            'admin_user': 'adam',
            'auth_host': '[2001:db8:1::1]',
            'auth_port': '35357',
            'auth_protocol': 'http',
            'service_host': '[2001:db8:1::1]',
            'service_port': '5000',
            'service_protocol': 'http',
            'api_version': '2.0',
        }
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:23,代码来源:test_os_contexts.py

示例8: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def __call__(self):
        ctxt = super(IdentityServiceContext, self).__call__()
        if not ctxt:
            return
        ctxt['region'] = config('region')
        return ctxt 
开发者ID:openstack,项目名称:charm-neutron-api,代码行数:8,代码来源:neutron_api_context.py

示例9: test_identity_service_context_with_altname

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_altname(self):
        '''Test identity context when using an explicit relation name'''
        relation = FakeRelation(
            relation_data=APIIDENTITY_SERVICE_RELATION_UNSET
        )
        self.relation_get.side_effect = relation.get
        self.relation_ids.return_value = ['neutron-plugin-api:0']
        self.related_units.return_value = ['neutron-api/0']
        identity_service = context.IdentityServiceContext(
            rel_name='neutron-plugin-api'
        )
        result = identity_service()
        expected = {
            'admin_password': 'foo',
            'admin_tenant_name': 'admin',
            'admin_tenant_id': None,
            'admin_user': 'adam',
            'auth_host': 'keystone-host.local',
            'auth_port': '35357',
            'auth_protocol': 'http',
            'service_host': 'keystonehost.local',
            'service_port': '5000',
            'service_protocol': 'http',
            'api_version': '2.0',
        }
        self.assertEquals(result, expected) 
开发者ID:juju,项目名称:charm-helpers,代码行数:28,代码来源:test_os_contexts.py

示例10: test_identity_service_context_with_missing_relation

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import IdentityServiceContext [as 别名]
def test_identity_service_context_with_missing_relation(self):
        '''Test shared-db context missing relation data'''
        incomplete_relation = copy(IDENTITY_SERVICE_RELATION_UNSET)
        incomplete_relation['service_password'] = None
        relation = FakeRelation(relation_data=incomplete_relation)
        self.relation_get.side_effect = relation.get
        identity_service = context.IdentityServiceContext()
        result = identity_service()
        self.assertEquals(result, {}) 
开发者ID:juju,项目名称:charm-helpers,代码行数:11,代码来源:test_os_contexts.py


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