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