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