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


Python utils.os_release方法代码示例

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


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

示例1: network_manager

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def network_manager():
    '''
    Deals with the renaming of Quantum to Neutron in H and any situations
    that require compatability (eg, deploying H with network-manager=quantum,
    upgrading from G).
    '''
    release = os_release('nova-common')
    manager = config('network-manager').lower()

    if manager not in ['quantum', 'neutron']:
        return manager

    if release in ['essex']:
        # E does not support neutron
        log('Neutron networking not supported in Essex.', level=ERROR)
        raise Exception
    elif release in ['folsom', 'grizzly']:
        # neutron is named quantum in F and G
        return 'quantum'
    else:
        # ensure accurate naming for all releases post-H
        return 'neutron' 
开发者ID:openstack,项目名称:charm-plumgrid-gateway,代码行数:24,代码来源:neutron.py

示例2: make_default_select_release_handler

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def make_default_select_release_handler():
    """This handler is a bit more unusual, as it just sets the release selector
    using the @register_os_release_selector decorator
    """

    @register_os_release_selector
    def default_select_release():
        """Determine the release based on the python-keystonemiddleware that is
        installed.

        Note that this function caches the release after the first install so
        that it doesn't need to keep going and getting it from the package
        information.
        """
        release_version = unitdata.kv().get(OPENSTACK_RELEASE_KEY, None)
        if release_version is None:
            release_version = os_utils.os_release('python-keystonemiddleware')
            unitdata.kv().set(OPENSTACK_RELEASE_KEY, release_version)
        return release_version 
开发者ID:openstack,项目名称:charms.openstack,代码行数:21,代码来源:defaults.py

示例3: application_version

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def application_version(self):
        """Return the current version of the application being deployed by
        the charm, as indicated by the version_package or version_snap
        attribute
        """
        if os_utils.snap_install_requested():
            if not self.version_snap:
                self.version_snap = self.snaps[0]
            version = get_snap_version(self.version_snap,
                                       fatal=False)
            if not version:
                version = os_utils.get_os_codename_install_source(
                    self.config['openstack-origin']
                )
        else:
            if not self.version_package:
                self.version_package = self.packages[0]
            version = get_upstream_version(
                self.version_package
            )
            if not version:
                version = os_utils.os_release(self.version_package)
        return version 
开发者ID:openstack,项目名称:charms.openstack,代码行数:25,代码来源:classes.py

示例4: __init__

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def __init__(self, release=None, **kwargs):
        """Custom initialiser for class
        If no release is passed, then the charm determines the release from the
        ch_utils.os_release() function.
        """
        if release is None:
            release = ch_utils.os_release('python-keystonemiddleware')
        super().__init__(release=release, **kwargs) 
开发者ID:openstack,项目名称:charm-murano,代码行数:10,代码来源:murano.py

示例5: select_release

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def select_release():
    """Determine the release based on the python-keystonemiddleware that is
    installed.

    Note that this function caches the release after the first install so that
    it doesn't need to keep going and getting it from the package information.
    """
    release_version = unitdata.kv().get(OPENSTACK_RELEASE_KEY, None)
    if release_version is None:
        release_version = ch_utils.os_release('python-keystonemiddleware')
        unitdata.kv().set(OPENSTACK_RELEASE_KEY, release_version)
    return release_version 
开发者ID:openstack,项目名称:charm-trove,代码行数:14,代码来源:trove.py

示例6: choose_charm_class

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def choose_charm_class():
    """Choose the charm class based on the neutron-common package installed"""
    return ch_utils.os_release('neutron-common') 
开发者ID:openstack,项目名称:charm-neutron-api-odl,代码行数:5,代码来源:neutron_api_odl.py

示例7: __init__

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def __init__(self, release=None, **kwargs):
        """Custom initialiser for class
        If no release is passed, then the charm determines the release from the
        ch_utils.os_release() function.
        """
        if release is None:
            release = ch_utils.os_release('python-keystonemiddleware')
        super(DesignateCharm, self).__init__(release=release, **kwargs) 
开发者ID:openstack,项目名称:charm-designate,代码行数:10,代码来源:designate.py

示例8: test_os_codename_from_package

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def test_os_codename_from_package(self, mock_snap_install_requested):
        """Test deriving OpenStack codename from an installed package"""
        mock_snap_install_requested.return_value = False
        with patch('apt_pkg.Cache') as cache:
            cache.return_value = self._apt_cache()
            for pkg, vers in six.iteritems(FAKE_REPO):
                # test fake repo for all "installed" packages
                if pkg.startswith('bad-'):
                    continue
                if 'pkg_vers' not in vers:
                    continue
                self.assertEquals(openstack.get_os_codename_package(pkg),
                                  vers['os_release']) 
开发者ID:juju,项目名称:charm-helpers,代码行数:15,代码来源:test_openstack_utils.py

示例9: test_os_release_uncached

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def test_os_release_uncached(self, config, git_cn, get_cn):
        openstack._os_rel = None
        get_cn.return_value = 'folsom'
        git_cn.return_value = None

        # openstack-origin-git=None
        config.side_effect = [None]

        self.assertEquals('folsom', openstack.os_release('nova-common')) 
开发者ID:juju,项目名称:charm-helpers,代码行数:11,代码来源:test_openstack_utils.py

示例10: test_os_release_cached

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def test_os_release_cached(self):
        openstack._os_rel = 'foo'
        self.assertEquals('foo', openstack.os_release('nova-common')) 
开发者ID:juju,项目名称:charm-helpers,代码行数:5,代码来源:test_openstack_utils.py

示例11: test_os_release

# 需要导入模块: from charmhelpers.contrib.openstack import utils [as 别名]
# 或者: from charmhelpers.contrib.openstack.utils import os_release [as 别名]
def test_os_release(self, mock_get_os_codename_install_source,
                        mock_get_os_codename_package,
                        mock_git_os_codename_install_source,
                        mock_config):
        # Wipe the modules cached os_rel
        utils._os_rel = None
        mock_get_os_codename_install_source.return_value = None
        mock_get_os_codename_package.return_value = None
        mock_git_os_codename_install_source.return_value = None
        mock_config.return_value = 'cloud-pocket'
        self.assertEqual(utils.os_release('my-pkg'), 'essex')
        mock_get_os_codename_install_source.assert_called_once_with(
            'cloud-pocket')
        mock_get_os_codename_package.assert_called_once_with(
            'my-pkg', fatal=False)
        mock_git_os_codename_install_source.assert_called_once_with(
            'cloud-pocket')
        # Next call to os_release should pickup cached version
        mock_get_os_codename_install_source.reset_mock()
        mock_get_os_codename_package.reset_mock()
        mock_git_os_codename_install_source.reset_mock()
        self.assertEqual(utils.os_release('my-pkg'), 'essex')
        self.assertFalse(mock_get_os_codename_install_source.called)
        self.assertFalse(mock_get_os_codename_package.called)
        self.assertFalse(mock_git_os_codename_install_source.called)
        # Call os_release and bypass cache
        mock_get_os_codename_install_source.reset_mock()
        mock_get_os_codename_package.reset_mock()
        mock_git_os_codename_install_source.reset_mock()
        self.assertEqual(utils.os_release('my-pkg', reset_cache=True),
                         'essex')
        mock_get_os_codename_install_source.assert_called_once_with(
            'cloud-pocket')
        mock_get_os_codename_package.assert_called_once_with(
            'my-pkg', fatal=False)
        mock_git_os_codename_install_source.assert_called_once_with(
            'cloud-pocket') 
开发者ID:juju,项目名称:charm-helpers,代码行数:39,代码来源:test_os_utils.py


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