本文整理匯總了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'
示例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
示例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
示例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)
示例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
示例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')
示例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)
示例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'])
示例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'))
示例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'))
示例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')