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


Python host.CompareHostReleases方法代码示例

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


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

示例1: memcache

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import CompareHostReleases [as 别名]
def memcache(self):
        ctxt = {}
        ctxt['use_memcache'] = False
        if self.charm_instance:
            if (ch_utils.OPENSTACK_RELEASES.index(
                    self.charm_instance.release) >=
                    ch_utils.OPENSTACK_RELEASES.index('mitaka')):
                ctxt['use_memcache'] = True

        if ctxt['use_memcache']:
            # Trusty version of memcached does not support ::1 as a listen
            # address so use host file entry instead
            release = ch_host.lsb_release()['DISTRIB_CODENAME'].lower()
            if ch_ip.is_ipv6_disabled():
                if ch_host.CompareHostReleases(release) > 'trusty':
                    ctxt['memcache_server'] = '127.0.0.1'
                else:
                    ctxt['memcache_server'] = 'localhost'
                ctxt['memcache_server_formatted'] = '127.0.0.1'
                ctxt['memcache_port'] = '11211'
                ctxt['memcache_url'] = '{}:{}'.format(
                    ctxt['memcache_server_formatted'],
                    ctxt['memcache_port'])
            else:
                if ch_host.CompareHostReleases(release) > 'trusty':
                    ctxt['memcache_server'] = '::1'
                else:
                    ctxt['memcache_server'] = 'ip6-localhost'
                ctxt['memcache_server_formatted'] = '[::1]'
                ctxt['memcache_port'] = '11211'
                ctxt['memcache_url'] = 'inet6:{}:{}'.format(
                    ctxt['memcache_server_formatted'],
                    ctxt['memcache_port'])
        return ctxt 
开发者ID:openstack,项目名称:charms.openstack,代码行数:36,代码来源:adapters.py

示例2: test_compare_ubuntu_releases

# 需要导入模块: from charmhelpers.core import host [as 别名]
# 或者: from charmhelpers.core.host import CompareHostReleases [as 别名]
def test_compare_ubuntu_releases(self):
        from charmhelpers.osplatform import get_platform
        if get_platform() == 'ubuntu':
            self.assertTrue(host.CompareHostReleases('yakkety') < 'zesty') 
开发者ID:juju,项目名称:charm-helpers,代码行数:6,代码来源:test_host.py


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