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


Python context.MemcacheContext方法代码示例

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


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

示例1: test_memcache_context_ipv6

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import MemcacheContext [as 别名]
def test_memcache_context_ipv6(self, _is_ipv6_disabled, _enable_memcache):
        self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
        _enable_memcache.return_value = True
        _is_ipv6_disabled.return_value = False
        config = {
            'openstack-origin': 'distro',
        }
        self.config.side_effect = fake_config(config)
        ctxt = context.MemcacheContext()
        self.assertTrue(ctxt()['use_memcache'])
        expect = {
            'memcache_port': '11211',
            'memcache_server': '::1',
            'memcache_server_formatted': '[::1]',
            'memcache_url': 'inet6:[::1]:11211',
            'use_memcache': True}
        self.assertEqual(ctxt(), expect)
        self.lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
        expect['memcache_server'] = 'ip6-localhost'
        ctxt = context.MemcacheContext()
        self.assertEqual(ctxt(), expect) 
开发者ID:juju,项目名称:charm-helpers,代码行数:23,代码来源:test_os_contexts.py

示例2: test_memcache_context_ipv4

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import MemcacheContext [as 别名]
def test_memcache_context_ipv4(self, _is_ipv6_disabled, _enable_memcache):
        self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
        _enable_memcache.return_value = True
        _is_ipv6_disabled.return_value = True
        config = {
            'openstack-origin': 'distro',
        }
        self.config.side_effect = fake_config(config)
        ctxt = context.MemcacheContext()
        self.assertTrue(ctxt()['use_memcache'])
        expect = {
            'memcache_port': '11211',
            'memcache_server': '127.0.0.1',
            'memcache_server_formatted': '127.0.0.1',
            'memcache_url': '127.0.0.1:11211',
            'use_memcache': True}
        self.assertEqual(ctxt(), expect)
        self.lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
        expect['memcache_server'] = 'localhost'
        ctxt = context.MemcacheContext()
        self.assertEqual(ctxt(), expect) 
开发者ID:juju,项目名称:charm-helpers,代码行数:23,代码来源:test_os_contexts.py

示例3: test_memcache_off_context

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import MemcacheContext [as 别名]
def test_memcache_off_context(self, _enable_memcache):
        _enable_memcache.return_value = False
        config = {'openstack-origin': 'distro'}
        self.config.side_effect = fake_config(config)
        ctxt = context.MemcacheContext()
        self.assertFalse(ctxt()['use_memcache'])
        self.assertEqual(ctxt(), {'use_memcache': False}) 
开发者ID:juju,项目名称:charm-helpers,代码行数:9,代码来源:test_os_contexts.py

示例4: resource_map

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import MemcacheContext [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.MemcacheContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。