本文整理汇总了Python中teuthology.misc.get_system_type函数的典型用法代码示例。如果您正苦于以下问题:Python get_system_type函数的具体用法?Python get_system_type怎么用?Python get_system_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_system_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: need_to_install_distro
def need_to_install_distro(ctx, role):
"""
Installing kernels on rpm won't setup grub/boot into them.
This installs the newest kernel package and checks its version
and compares against current (uname -r) and returns true if newest != current.
Similar check for deb.
"""
(role_remote,) = ctx.cluster.only(role).remotes.keys()
system_type = teuthology.get_system_type(role_remote)
output, err_mess = StringIO(), StringIO()
role_remote.run(args=['uname', '-r' ], stdout=output, stderr=err_mess )
current = output.getvalue().strip()
if system_type == 'rpm':
role_remote.run(args=['sudo', 'yum', 'install', '-y', 'kernel' ], stdout=output, stderr=err_mess )
#reset stringIO output.
output, err_mess = StringIO(), StringIO()
role_remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
newest=output.getvalue().split()[0]
if system_type == 'deb':
distribution = teuthology.get_system_type(role_remote, distro=True)
newest = get_version_from_pkg(role_remote, distribution)
output.close()
err_mess.close()
if current in newest:
return False
log.info('Not newest distro kernel. Curent: {cur} Expected: {new}'.format(cur=current, new=newest))
return True
示例2: install_distro_kernel
def install_distro_kernel(remote):
"""
RPM: Find newest kernel on the machine and update grub to use kernel + reboot.
DEB: Find newest kernel. Parse grub.cfg to figure out the entryname/subentry.
then modify 01_ceph_kernel to have correct entry + updategrub + reboot.
"""
system_type = teuthology.get_system_type(remote)
distribution = ''
if system_type == 'rpm':
output, err_mess = StringIO(), StringIO()
remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
newest=output.getvalue().split()[0].split('kernel-')[1]
log.info('Distro Kernel Version: {version}'.format(version=newest))
update_grub_rpm(remote, newest)
remote.run( args=['sudo', 'shutdown', '-r', 'now'], wait=False )
output.close()
err_mess.close()
return
if system_type == 'deb':
distribution = teuthology.get_system_type(remote, distro=True)
newversion = get_version_from_pkg(remote, distribution)
if 'ubuntu' in distribution:
grub2conf = teuthology.get_file(remote, '/boot/grub/grub.cfg', True)
submenu = ''
menuentry = ''
for line in grub2conf.split('\n'):
if 'submenu' in line:
submenu = line.split('submenu ')[1]
# Ubuntu likes to be sneaky and change formatting of
# grub.cfg between quotes/doublequotes between versions
if submenu.startswith("'"):
submenu = submenu.split("'")[1]
if submenu.startswith('"'):
submenu = submenu.split('"')[1]
if 'menuentry' in line:
if newversion in line and 'recovery' not in line:
menuentry = line.split('\'')[1]
break
if submenu:
grubvalue = submenu + '>' + menuentry
else:
grubvalue = menuentry
grubfile = 'cat <<EOF\nset default="' + grubvalue + '"\nEOF'
teuthology.delete_file(remote, '/etc/grub.d/01_ceph_kernel', sudo=True, force=True)
teuthology.sudo_write_file(remote, '/etc/grub.d/01_ceph_kernel', StringIO(grubfile), '755')
log.info('Distro Kernel Version: {version}'.format(version=newversion))
remote.run(args=['sudo', 'update-grub'])
remote.run(args=['sudo', 'shutdown', '-r', 'now'], wait=False )
return
if 'debian' in distribution:
grub2_kernel_select_generic(remote, newversion, 'deb')
log.info('Distro Kernel Version: {version}'.format(version=newversion))
remote.run( args=['sudo', 'shutdown', '-r', 'now'], wait=False )
return
示例3: upgrade_common
def upgrade_common(ctx, config, deploy_style):
"""
Common code for upgrading
"""
remotes = upgrade_remote_to_config(ctx, config)
project = config.get('project', 'ceph')
# FIXME: extra_pkgs is not distro-agnostic
extra_pkgs = config.get('extra_packages', [])
log.info('extra packages: {packages}'.format(packages=extra_pkgs))
for remote, node in remotes.iteritems():
system_type = teuthology.get_system_type(remote)
assert system_type in ('deb', 'rpm')
pkgs = get_package_list(ctx, config)[system_type]
excluded_packages = config.get('exclude_packages', list())
pkgs = list(set(pkgs).difference(set(excluded_packages)))
log.info("Upgrading {proj} {system_type} packages: {pkgs}".format(
proj=project, system_type=system_type, pkgs=', '.join(pkgs)))
# FIXME: again, make extra_pkgs distro-agnostic
pkgs += extra_pkgs
deploy_style(ctx, node, remote, pkgs, system_type)
verify_package_version(ctx, node, remote)
return len(remotes)
示例4: remove_sources
def remove_sources(ctx, config):
remove_sources_pkgs = {"deb": _remove_sources_list_deb, "rpm": _remove_sources_list_rpm}
log.info("Removing {proj} sources lists".format(proj=config.get("project", "ceph")))
with parallel() as p:
for remote in ctx.cluster.remotes.iterkeys():
system_type = teuthology.get_system_type(remote)
p.spawn(remove_sources_pkgs[system_type], remote, config.get("project", "ceph"))
示例5: install_package
def install_package(package, remote):
"""
Install 'package' on 'remote'
Assumes repo has already been set up (perhaps with install_repo)
"""
log.info('Installing package %s on %s', package, remote)
flavor = misc.get_system_type(remote)
if flavor == 'deb':
pkgcmd = ['DEBIAN_FRONTEND=noninteractive',
'sudo',
'-E',
'apt-get',
'-y',
'install',
'{package}'.format(package=package)]
elif flavor == 'rpm':
pkgcmd = ['sudo',
'yum',
'-y',
'install',
'{package}'.format(package=package)]
else:
log.error('install_package: bad flavor ' + flavor + '\n')
return False
return remote.run(args=pkgcmd)
示例6: get_version_from_rpm
def get_version_from_rpm(remote, sha1):
"""
Get Actual version string from kernel file RPM URL.
"""
system_type, system_ver = teuthology.get_system_type(remote, distro=True, version=True)
if '.' in system_ver:
system_ver = system_ver.split('.')[0]
ldist = '{system_type}{system_ver}'.format(system_type=system_type, system_ver=system_ver)
_, rpm_url = teuthology.get_ceph_binary_url(
package='kernel',
sha1=sha1,
format='rpm',
flavor='basic',
arch='x86_64',
dist=ldist,
)
kernel_url = urlparse.urljoin(rpm_url, 'kernel.x86_64.rpm')
kerninfo, kern_err = StringIO(), StringIO()
remote.run(args=['rpm', '-qp', kernel_url ], stdout=kerninfo, stderr=kern_err)
kernelstring = ''
if '\n' in kerninfo.getvalue():
kernelstring = kerninfo.getvalue().split('\n')[0]
else:
kernelstring = kerninfo.getvalue()
return kernelstring, kernel_url
示例7: install_dependencies
def install_dependencies(self):
system_type = misc.get_system_type(self.first_mon)
if system_type == 'rpm':
install_cmd = ['sudo', 'yum', '-y', 'install']
cbt_depends = ['python-yaml', 'python-lxml', 'librbd-devel', 'pdsh']
else:
install_cmd = ['sudo', 'apt-get', '-y', '--force-yes', 'install']
cbt_depends = ['python-yaml', 'python-lxml', 'librbd-dev']
self.first_mon.run(args=install_cmd + cbt_depends)
# install fio
testdir = misc.get_testdir(self.ctx)
self.first_mon.run(
args=[
'git', 'clone', '-b', 'master',
'https://github.com/axboe/fio.git',
'{tdir}/fio'.format(tdir=testdir)
]
)
self.first_mon.run(
args=[
'cd', os.path.join(testdir, 'fio'), run.Raw('&&'),
'./configure', run.Raw('&&'),
'make'
]
)
示例8: upgrade_common
def upgrade_common(ctx, config, deploy_style):
"""
Common code for upgrading
"""
assert config is None or isinstance(config, dict), \
"install.upgrade only supports a dictionary for configuration"
for i in config.keys():
assert config.get(i) is None or isinstance(
config.get(i), dict), 'host supports dictionary'
project = config.get('project', 'ceph')
# use 'install' overrides here, in case the upgrade target is left
# unspecified/implicit.
install_overrides = ctx.config.get(
'overrides', {}).get('install', {}).get(project, {})
log.info('project %s config %s overrides %s', project, config, install_overrides)
# FIXME: extra_pkgs is not distro-agnostic
extra_pkgs = config.get('extra_packages', [])
log.info('extra packages: {packages}'.format(packages=extra_pkgs))
# build a normalized remote -> config dict
remotes = {}
if 'all' in config:
for remote in ctx.cluster.remotes.iterkeys():
remotes[remote] = config.get('all')
else:
for role in config.keys():
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
if remote in remotes:
log.warn('remote %s came up twice (role %s)', remote, role)
continue
remotes[remote] = config.get(role)
for remote, node in remotes.iteritems():
if not node:
node = {}
this_overrides = copy.deepcopy(install_overrides)
if 'sha1' in node or 'tag' in node or 'branch' in node:
log.info('config contains sha1|tag|branch, removing those keys from override')
this_overrides.pop('sha1', None)
this_overrides.pop('tag', None)
this_overrides.pop('branch', None)
teuthology.deep_merge(node, this_overrides)
log.info('remote %s config %s', remote, node)
system_type = teuthology.get_system_type(remote)
assert system_type in ('deb', 'rpm')
pkgs = PACKAGES[project][system_type]
log.info("Upgrading {proj} {system_type} packages: {pkgs}".format(
proj=project, system_type=system_type, pkgs=', '.join(pkgs)))
# FIXME: again, make extra_pkgs distro-agnostic
pkgs += extra_pkgs
node['project'] = project
deploy_style(ctx, node, remote, pkgs, system_type)
示例9: get_ioengine_package_name
def get_ioengine_package_name(ioengine, remote):
system_type = teuthology.get_system_type(remote)
if ioengine == 'rbd':
return 'librbd1-devel' if system_type == 'rpm' else 'librbd-dev'
elif ioengine == 'libaio':
return 'libaio-devel' if system_type == 'rpm' else 'libaio-dev'
else:
return None
示例10: install_packages
def install_packages(ctx, pkgs, config):
"""
installs Debian packages.
"""
install_pkgs = {"deb": _update_deb_package_list_and_install, "rpm": _update_rpm_package_list_and_install}
with parallel() as p:
for remote in ctx.cluster.remotes.iterkeys():
system_type = teuthology.get_system_type(remote)
p.spawn(install_pkgs[system_type], ctx, remote, pkgs[system_type], config)
示例11: install_firmware
def install_firmware(ctx, config):
"""
Go to the github to get the latest firmware.
:param ctx: Context
:param config: Configuration
"""
linux_firmware_git_upstream = 'git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git'
uri = teuth_config.linux_firmware_git_url or linux_firmware_git_upstream
fw_dir = '/lib/firmware/updates'
for role in config.iterkeys():
if config[role].find('distro') >= 0:
log.info('Skipping firmware on distro kernel');
return
(role_remote,) = ctx.cluster.only(role).remotes.keys()
package_type = teuthology.get_system_type(role_remote)
if package_type == 'rpm':
return
log.info('Installing linux-firmware on {role}...'.format(role=role))
role_remote.run(
args=[
# kludge around mysterious 0-byte .git/HEAD files
'cd', fw_dir,
run.Raw('&&'),
'test', '-d', '.git',
run.Raw('&&'),
'test', '!', '-s', '.git/HEAD',
run.Raw('&&'),
'sudo', 'rm', '-rf', '.git',
run.Raw(';'),
# init
'sudo', 'install', '-d', '-m0755', fw_dir,
run.Raw('&&'),
'cd', fw_dir,
run.Raw('&&'),
'sudo', 'git', 'init',
],
)
role_remote.run(
args=[
'sudo', 'git', '--git-dir=%s/.git' % fw_dir, 'config',
'--get', 'remote.origin.url', run.Raw('>/dev/null'),
run.Raw('||'),
'sudo', 'git', '--git-dir=%s/.git' % fw_dir,
'remote', 'add', 'origin', uri,
],
)
role_remote.run(
args=[
'cd', fw_dir,
run.Raw('&&'),
'sudo', 'git', 'fetch', 'origin',
run.Raw('&&'),
'sudo', 'git', 'reset', '--hard', 'origin/master'
],
)
示例12: remove_packages
def remove_packages(ctx, config, pkgs):
remove_pkgs = {
"deb": _remove_deb,
"rpm": _remove_rpm,
}
with parallel() as p:
for remote in ctx.cluster.remotes.iterkeys():
system_type = teuthology.get_system_type(remote)
p.spawn(remove_pkgs[system_type], ctx, config, remote, pkgs[system_type])
示例13: get_service_name
def get_service_name(service, rem):
"""
Find the remote-specific name of the generic 'service'
"""
flavor = misc.get_system_type(rem)
try:
return _SERVICE_MAP[service][flavor]
except KeyError:
return None
示例14: start_apache
def start_apache(ctx, config, on_client = None, except_client = None):
"""
Start apache on remote sites.
"""
log.info('Starting apache...')
testdir = teuthology.get_testdir(ctx)
apaches = {}
clients_to_run = [on_client]
if on_client is None:
clients_to_run = config.keys()
for client in clients_to_run:
cluster_name, daemon_type, client_id = teuthology.split_role(client)
client_with_cluster = cluster_name + '.' + daemon_type + '.' + client_id
if client == except_client:
continue
(remote,) = ctx.cluster.only(client).remotes.keys()
system_type = teuthology.get_system_type(remote)
if system_type == 'deb':
apache_name = 'apache2'
else:
try:
remote.run(
args=[
'stat',
'/usr/sbin/httpd.worker',
],
)
apache_name = '/usr/sbin/httpd.worker'
except CommandFailedError:
apache_name = '/usr/sbin/httpd'
proc = remote.run(
args=[
'adjust-ulimits',
'daemon-helper',
'kill',
apache_name,
'-X',
'-f',
'{tdir}/apache/apache.{client_with_cluster}.conf'.format(tdir=testdir,
client_with_cluster=client_with_cluster),
],
logger=log.getChild(client),
stdin=run.PIPE,
wait=False,
)
apaches[client_with_cluster] = proc
try:
yield
finally:
log.info('Stopping apache...')
for client, proc in apaches.iteritems():
proc.stdin.close()
run.wait(apaches.itervalues())
示例15: need_to_install_distro
def need_to_install_distro(ctx, role):
"""
Installing kernels on rpm won't setup grub/boot into them.
This installs the newest kernel package and checks its version
and compares against current (uname -r) and returns true if newest != current.
Similar check for deb.
"""
(role_remote,) = ctx.cluster.only(role).remotes.keys()
system_type = teuthology.get_system_type(role_remote)
output, err_mess = StringIO(), StringIO()
role_remote.run(args=['uname', '-r' ], stdout=output, stderr=err_mess )
current = output.getvalue().strip()
if system_type == 'rpm':
role_remote.run(args=['sudo', 'yum', 'install', '-y', 'kernel'], stdout=output, stderr=err_mess )
if 'Nothing to do' in output.getvalue():
output.truncate(0), err_mess.truncate(0)
role_remote.run(args=['echo', 'no', run.Raw('|'), 'sudo', 'yum', 'reinstall', 'kernel', run.Raw('||'), 'true'], stdout=output, stderr=err_mess )
if 'Skipping the running kernel' in err_mess.getvalue():
# Current running kernel is already newest and updated
log.info('Newest distro kernel already installed/running')
return False
else:
output.truncate(0), err_mess.truncate(0)
role_remote.run(args=['sudo', 'yum', 'reinstall', '-y', 'kernel', run.Raw('||'), 'true'], stdout=output, stderr=err_mess )
#reset stringIO output.
output.truncate(0), err_mess.truncate(0)
role_remote.run(args=['rpm', '-q', 'kernel', '--last' ], stdout=output, stderr=err_mess )
for kernel in output.getvalue().split():
if kernel.startswith('kernel'):
if 'ceph' not in kernel:
newest = kernel.split('kernel-')[1]
break
if system_type == 'deb':
distribution = teuthology.get_system_type(role_remote, distro=True)
newest = get_version_from_pkg(role_remote, distribution)
output.close()
err_mess.close()
if current in newest:
return False
log.info('Not newest distro kernel. Curent: {cur} Expected: {new}'.format(cur=current, new=newest))
return True