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