本文整理汇总了Python中teuthology.misc.get_file函数的典型用法代码示例。如果您正苦于以下问题:Python get_file函数的具体用法?Python get_file怎么用?Python get_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_dnsmasq
def setup_dnsmasq(remote, cnames):
""" configure dnsmasq on the given remote, adding each cname given """
log.info('Configuring dnsmasq on remote %s..', remote.name)
# back up existing resolv.conf
resolv_conf = misc.get_file(remote, '/etc/resolv.conf')
# point resolv.conf to local dnsmasq
misc.sudo_write_file(remote, '/etc/resolv.conf',
"nameserver 127.0.0.1\n")
# add address entries to /etc/dnsmasq.d/ceph
dnsmasq = "server=8.8.8.8\nserver=8.8.4.4\n"
address_template = "address=/{cname}/{ip_address}\n"
for cname, ip_address in cnames.iteritems():
dnsmasq += address_template.format(cname=cname, ip_address=ip_address)
misc.sudo_write_file(remote, '/etc/dnsmasq.d/ceph', dnsmasq)
remote.run(args=['cat', '/etc/dnsmasq.d/ceph'])
# restart dnsmasq
remote.run(args=['sudo', 'systemctl', 'restart', 'dnsmasq'])
remote.run(args=['sudo', 'systemctl', 'status', 'dnsmasq'])
# verify dns name is set
remote.run(args=['ping', '-c', '4', cnames.keys()[0]])
yield
log.info('Removing dnsmasq configuration from remote %s..', remote.name)
# restore resolv.conf
misc.sudo_write_file(remote, '/etc/resolv.conf', resolv_conf)
# restart dnsmasq
remote.run(args=['sudo', 'systemctl', 'restart', 'dnsmasq'])
开发者ID:Carudy,项目名称:ceph,代码行数:31,代码来源:dnsmasq.py
示例2: _setup_mon
def _setup_mon(ctx, manager, remote, mon, name, data_path, conf_path):
# co-locate a new monitor on remote where an existing monitor is hosted
cluster = manager.cluster
remote.run(args=['sudo', 'mkdir', '-p', data_path])
keyring_path = '/etc/ceph/{cluster}.keyring'.format(
cluster=manager.cluster)
testdir = teuthology.get_testdir(ctx)
monmap_path = '{tdir}/{cluster}.monmap'.format(tdir=testdir,
cluster=cluster)
manager.raw_cluster_cmd('mon', 'getmap', '-o', monmap_path)
if manager.controller != remote:
monmap = teuthology.get_file(manager.controller, monmap_path)
teuthology.write_file(remote, monmap_path, StringIO(monmap))
remote.run(
args=[
'sudo',
'ceph-mon',
'--cluster', cluster,
'--mkfs',
'-i', mon,
'--monmap', monmap_path,
'--keyring', keyring_path])
if manager.controller != remote:
teuthology.delete_file(remote, monmap_path)
# raw_cluster_cmd() is performed using sudo, so sudo here also.
teuthology.delete_file(manager.controller, monmap_path, sudo=True)
# update ceph.conf so that the ceph CLI is able to connect to the cluster
if conf_path:
ip = remote.ip_address
port = _get_next_port(ctx, ip, cluster)
mon_addr = '{ip}:{port}'.format(ip=ip, port=port)
ctx.ceph[cluster].conf[name] = {'mon addr': mon_addr}
write_conf(ctx, conf_path, cluster)
开发者ID:Abhishekvrshny,项目名称:ceph,代码行数:33,代码来源:mon_seesaw.py
示例3: 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
开发者ID:LalatenduMohanty,项目名称:teuthology,代码行数:56,代码来源:kernel.py
示例4: generate_legacy_grub_entry
def generate_legacy_grub_entry(remote, newversion):
"""
This will likely need to be used for ceph kernels as well
as legacy grub rpm distros don't have an easy way of selecting
a kernel just via a command. This generates an entry in legacy
grub for a new kernel version using the existing entry as a base.
"""
grubconf = teuthology.get_file(remote, '/boot/grub/grub.conf', True)
titleline = ''
rootline = ''
kernelline = ''
initline = ''
kernelversion = ''
linenum = 0
titlelinenum = 0
#Grab first kernel entry (title/root/kernel/init lines)
for line in grubconf.split('\n'):
if re.match('^title', line):
titleline = line
titlelinenum = linenum
if re.match('(^\s+)root', line):
rootline = line
if re.match('(^\s+)kernel', line):
kernelline = line
for word in line.split(' '):
if 'vmlinuz' in word:
kernelversion = word.split('vmlinuz-')[-1]
if re.match('(^\s+)initrd', line):
initline = line
if (kernelline != '') and (initline != ''):
break
else:
linenum += 1
#insert new entry into grubconfnew list:
linenum = 0
newgrubconf = []
for line in grubconf.split('\n'):
line = line.rstrip('\n')
if linenum == titlelinenum:
newtitle = re.sub(kernelversion, newversion, titleline)
newroot = re.sub(kernelversion, newversion, rootline)
newkernel = re.sub(kernelversion, newversion, kernelline)
newinit = re.sub(kernelversion, newversion, initline)
newgrubconf.append(newtitle)
newgrubconf.append(newroot)
newgrubconf.append(newkernel)
newgrubconf.append(newinit)
newgrubconf.append('')
newgrubconf.append(line)
else:
newgrubconf.append(line)
linenum += 1
return newgrubconf
开发者ID:LiumxNL,项目名称:teuthology,代码行数:55,代码来源:kernel.py
示例5: run_tests
def run_tests(ctx, config):
assert isinstance(config, dict)
testdir = teuthology.get_testdir(ctx)
for client, client_config in config.iteritems():
(remote,) = ctx.cluster.only(client).remotes.keys()
conf = teuthology.get_file(
remote, "{tdir}/archive/s3readwrite.{client}.config.yaml".format(tdir=testdir, client=client)
)
args = ["{tdir}/s3-tests/virtualenv/bin/s3tests-test-readwrite".format(tdir=testdir)]
if client_config is not None and "extra_args" in client_config:
args.extend(client_config["extra_args"])
ctx.cluster.only(client).run(args=args, stdin=conf)
yield
开发者ID:athanatos,项目名称:teuthology,代码行数:14,代码来源:s3readwrite.py
示例6: run_tests
def run_tests(ctx, config):
assert isinstance(config, dict)
for client, client_config in config.iteritems():
(remote,) = ctx.cluster.only(client).remotes.keys()
conf = teuthology.get_file(remote, '/tmp/cephtest/archive/s3roundtrip.{client}.config.yaml'.format(client=client))
args = [
'/tmp/cephtest/s3-tests/virtualenv/bin/s3tests-test-roundtrip',
]
if client_config is not None and 'extra_args' in client_config:
args.extend(client_config['extra_args'])
ctx.cluster.only(client).run(
args=args,
stdin=conf,
)
yield
开发者ID:tv42,项目名称:teuthology,代码行数:16,代码来源:s3roundtrip.py
示例7: grub2_kernel_select_generic
def grub2_kernel_select_generic(remote, newversion, ostype):
"""
Can be used on DEB and RPM. Sets which entry should be boted by entrynum.
"""
if ostype == 'rpm':
grubset = 'grub2-set-default'
mkconfig = 'grub2-mkconfig'
grubconfig = '/boot/grub2/grub.cfg'
if ostype == 'deb':
grubset = 'grub-set-default'
grubconfig = '/boot/grub/grub.cfg'
mkconfig = 'grub-mkconfig'
remote.run(args=['sudo', mkconfig, '-o', grubconfig, ])
grub2conf = teuthology.get_file(remote, grubconfig, True)
entry_num = 0
for line in grub2conf.split('\n'):
if line.startswith('menuentry'):
if newversion in line:
break
entry_num =+ 1
remote.run(args=['sudo', grubset, str(entry_num), ])
开发者ID:jcsp,项目名称:teuthology,代码行数:21,代码来源:kernel.py
示例8: get_tests
def get_tests(ctx, config, role, remote, testdir):
"""Download restart tests"""
srcdir = '{tdir}/restart.{role}'.format(tdir=testdir, role=role)
refspec = config.get('branch')
if refspec is None:
refspec = config.get('sha1')
if refspec is None:
refspec = config.get('tag')
if refspec is None:
refspec = 'HEAD'
log.info('Pulling restart qa/workunits from ref %s', refspec)
remote.run(
logger=log.getChild(role),
args=[
'mkdir', '--', srcdir,
run.Raw('&&'),
'git',
'archive',
'--remote=git://ceph.com/git/ceph.git',
'%s:qa/workunits' % refspec,
run.Raw('|'),
'tar',
'-C', srcdir,
'-x',
'-f-',
run.Raw('&&'),
'cd', '--', srcdir,
run.Raw('&&'),
'if', 'test', '-e', 'Makefile', run.Raw(';'), 'then', 'make', run.Raw(';'), 'fi',
run.Raw('&&'),
'find', '-executable', '-type', 'f', '-printf', r'%P\0'.format(srcdir=srcdir),
run.Raw('>{tdir}/restarts.list'.format(tdir=testdir)),
],
)
restarts = sorted(teuthology.get_file(
remote,
'{tdir}/restarts.list'.format(tdir=testdir)).split('\0'))
return (srcdir, restarts)
开发者ID:yghannam,项目名称:ceph-qa-suite,代码行数:40,代码来源:restart.py
示例9: run_tests
def run_tests(ctx, config):
"""
Run the s3 roundtrip after everything is set up.
:param ctx: Context passed to task
:param config: specific configuration information
"""
assert isinstance(config, dict)
testdir = teuthology.get_testdir(ctx)
for client, client_config in config.iteritems():
(remote,) = ctx.cluster.only(client).remotes.keys()
conf = teuthology.get_file(remote, '{tdir}/archive/s3roundtrip.{client}.config.yaml'.format(tdir=testdir, client=client))
args = [
'{tdir}/s3-tests/virtualenv/bin/s3tests-test-roundtrip'.format(tdir=testdir),
]
if client_config is not None and 'extra_args' in client_config:
args.extend(client_config['extra_args'])
ctx.cluster.only(client).run(
args=args,
stdin=conf,
)
yield
开发者ID:LalatenduMohanty,项目名称:teuthology,代码行数:23,代码来源:s3roundtrip.py
示例10: build_ceph_cluster
#.........这里部分代码省略.........
mon_destroy_nodes = './ceph-deploy mon destroy' + \
" " + mon_node[d]
estatus_mon_d = execute_ceph_deploy(mon_destroy_nodes)
if estatus_mon_d != 0:
raise RuntimeError("ceph-deploy: Failed to delete monitor")
node_dev_list = get_dev_for_osd(ctx, config)
for d in node_dev_list:
node = d[0]
for disk in d[1:]:
zap = './ceph-deploy disk zap ' + node + ':' + disk
estatus = execute_ceph_deploy(zap)
if estatus != 0:
raise RuntimeError("ceph-deploy: Failed to zap osds")
osd_create_cmd = './ceph-deploy osd create '
if config.get('dmcrypt') is not None:
osd_create_cmd += '--dmcrypt '
osd_create_cmd += ":".join(d)
estatus_osd = execute_ceph_deploy(osd_create_cmd)
if estatus_osd == 0:
log.info('successfully created osd')
no_of_osds += 1
else:
raise RuntimeError("ceph-deploy: Failed to create osds")
if config.get('wait-for-healthy', True) and no_of_osds >= 2:
is_healthy(ctx=ctx, config=None)
log.info('Setting up client nodes...')
conf_path = '/etc/ceph/ceph.conf'
admin_keyring_path = '/etc/ceph/ceph.client.admin.keyring'
first_mon = teuthology.get_first_mon(ctx, config)
(mon0_remote,) = ctx.cluster.only(first_mon).remotes.keys()
conf_data = teuthology.get_file(
remote=mon0_remote,
path=conf_path,
sudo=True,
)
admin_keyring = teuthology.get_file(
remote=mon0_remote,
path=admin_keyring_path,
sudo=True,
)
clients = ctx.cluster.only(teuthology.is_type('client'))
for remot, roles_for_host in clients.remotes.iteritems():
for id_ in teuthology.roles_of_type(roles_for_host, 'client'):
client_keyring = \
'/etc/ceph/ceph.client.{id}.keyring'.format(id=id_)
mon0_remote.run(
args=[
'cd',
'{tdir}'.format(tdir=testdir),
run.Raw('&&'),
'sudo', 'bash', '-c',
run.Raw('"'), 'ceph',
'auth',
'get-or-create',
'client.{id}'.format(id=id_),
'mds', 'allow',
'mon', 'allow *',
'osd', 'allow *',
run.Raw('>'),
client_keyring,
run.Raw('"'),
],
开发者ID:bkmcfarland,项目名称:ceph,代码行数:67,代码来源:ceph_deploy.py
示例11: update_devstack_config_files
def update_devstack_config_files(devstack_node, secret_uuid):
log.info("Updating DevStack config files to use Ceph...")
def backup_config(node, file_name, backup_ext=".orig.teuth"):
node.run(args=["cp", "-f", file_name, file_name + backup_ext])
def update_config(config_name, config_stream, update_dict, section="DEFAULT"):
parser = ConfigParser()
parser.read_file(config_stream)
for (key, value) in update_dict.items():
parser.set(section, key, value)
out_stream = StringIO()
parser.write(out_stream)
out_stream.seek(0)
return out_stream
updates = [
dict(
name="/etc/glance/glance-api.conf",
options=dict(
default_store="rbd", rbd_store_user="glance", rbd_store_pool="images", show_image_direct_url="True"
),
),
dict(
name="/etc/cinder/cinder.conf",
options=dict(
volume_driver="cinder.volume.drivers.rbd.RBDDriver",
rbd_pool="volumes",
rbd_ceph_conf="/etc/ceph/ceph.conf",
rbd_flatten_volume_from_snapshot="false",
rbd_max_clone_depth="5",
glance_api_version="2",
rbd_user="cinder",
rbd_secret_uuid=secret_uuid,
backup_driver="cinder.backup.drivers.ceph",
backup_ceph_conf="/etc/ceph/ceph.conf",
backup_ceph_user="cinder-backup",
backup_ceph_chunk_size="134217728",
backup_ceph_pool="backups",
backup_ceph_stripe_unit="0",
backup_ceph_stripe_count="0",
restore_discard_excess_bytes="true",
),
),
dict(
name="/etc/nova/nova.conf",
options=dict(
libvirt_images_type="rbd",
libvirt_images_rbd_pool="volumes",
libvirt_images_rbd_ceph_conf="/etc/ceph/ceph.conf",
rbd_user="cinder",
rbd_secret_uuid=secret_uuid,
libvirt_inject_password="false",
libvirt_inject_key="false",
libvirt_inject_partition="-2",
),
),
]
for update in updates:
file_name = update["name"]
options = update["options"]
config_str = misc.get_file(devstack_node, file_name, sudo=True)
config_stream = StringIO(config_str)
backup_config(devstack_node, file_name)
new_config_stream = update_config(file_name, config_stream, options)
misc.sudo_write_file(devstack_node, file_name, new_config_stream)
开发者ID:tsg-,项目名称:ceph-qa-suite,代码行数:67,代码来源:devstack.py
示例12: cluster
def cluster(ctx, config):
log.info('Creating ceph cluster...')
run.wait(
ctx.cluster.run(
args=[
'install', '-d', '-m0755', '--',
'/tmp/cephtest/data',
],
wait=False,
)
)
log.info('Generating config...')
remotes_and_roles = ctx.cluster.remotes.items()
roles = [roles for (remote, roles) in remotes_and_roles]
ips = [host for (host, port) in (remote.ssh.get_transport().getpeername() for (remote, roles) in remotes_and_roles)]
conf = teuthology.skeleton_config(roles=roles, ips=ips)
for section, keys in config['conf'].iteritems():
for key, value in keys.iteritems():
log.info("[%s] %s = %s" % (section, key, value))
if section not in conf:
conf[section] = {}
conf[section][key] = value
ctx.ceph = argparse.Namespace()
ctx.ceph.conf = conf
log.info('Writing configs...')
conf_fp = StringIO()
conf.write(conf_fp)
conf_fp.seek(0)
writes = ctx.cluster.run(
args=[
'python',
'-c',
'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))',
'/tmp/cephtest/ceph.conf',
],
stdin=run.PIPE,
wait=False,
)
teuthology.feed_many_stdins_and_close(conf_fp, writes)
run.wait(writes)
coverage_dir = '/tmp/cephtest/archive/coverage'
firstmon = teuthology.get_first_mon(ctx, config)
log.info('Setting up %s...' % firstmon)
ctx.cluster.only(firstmon).run(
args=[
'/tmp/cephtest/enable-coredump',
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
coverage_dir,
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
'--create-keyring',
'/tmp/cephtest/ceph.keyring',
],
)
ctx.cluster.only(firstmon).run(
args=[
'/tmp/cephtest/enable-coredump',
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
coverage_dir,
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
'--gen-key',
'--name=mon.',
'/tmp/cephtest/ceph.keyring',
],
)
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
teuthology.create_simple_monmap(
remote=mon0_remote,
conf=conf,
)
log.info('Creating admin key on %s...' % firstmon)
ctx.cluster.only(firstmon).run(
args=[
'/tmp/cephtest/enable-coredump',
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
coverage_dir,
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
'--gen-key',
'--name=client.admin',
'--set-uid=0',
'--cap', 'mon', 'allow *',
'--cap', 'osd', 'allow *',
'--cap', 'mds', 'allow',
'/tmp/cephtest/ceph.keyring',
],
)
log.info('Copying monmap to all nodes...')
keyring = teuthology.get_file(
remote=mon0_remote,
path='/tmp/cephtest/ceph.keyring',
)
monmap = teuthology.get_file(
remote=mon0_remote,
#.........这里部分代码省略.........
开发者ID:tv42,项目名称:teuthology,代码行数:101,代码来源:ceph.py
示例13: install_kernel
def install_kernel(remote, path=None, version=None):
"""
A bit of misnomer perhaps - the actual kernel package is installed
elsewhere, this function deals with initrd and grub. Currently the
following cases are handled:
- local, gitbuilder, distro for rpm packages
- distro for deb packages - see TODO in install_and_reboot()
TODO: reboots should be issued from install_and_reboot()
:param path: package path (for local and gitbuilder cases)
:param version: for RPM distro kernels, pass this to update_grub_rpm
"""
templ = "install_kernel(remote={remote}, path={path}, version={version})"
log.debug(templ.format(remote=remote, path=path, version=version))
package_type = remote.os.package_type
if package_type == 'rpm':
if path:
version = get_image_version(remote, path)
# This is either a gitbuilder or a local package and both of these
# could have been built with upstream rpm targets with specs that
# don't have a %post section at all, which means no initrd.
maybe_generate_initrd_rpm(remote, path, version)
elif not version or version == 'distro':
version = get_latest_image_version_rpm(remote)
update_grub_rpm(remote, version)
remote.run( args=['sudo', 'shutdown', '-r', 'now'], wait=False )
return
if package_type == 'deb':
distribution = remote.os.name
newversion = get_latest_image_version_deb(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
开发者ID:LiumxNL,项目名称:teuthology,代码行数:66,代码来源:kernel.py
示例14: _run_tests
def _run_tests(ctx, refspec, role, tests, env, subdir=None, timeout=None):
"""
Run the individual test. Create a scratch directory and then extract the
workunits from git. Make the executables, and then run the tests.
Clean up (remove files created) after the tests are finished.
:param ctx: Context
:param refspec: branch, sha1, or version tag used to identify this
build
:param tests: specific tests specified.
:param env: environment set in yaml file. Could be None.
:param subdir: subdirectory set in yaml file. Could be None
:param timeout: If present, use the 'timeout' command on the remote host
to limit execution time. Must be specified by a number
followed by 's' for seconds, 'm' for minutes, 'h' for
hours, or 'd' for days. If '0' or anything that evaluates
to False is passed, the 'timeout' command is not used.
"""
testdir = misc.get_testdir(ctx)
assert isinstance(role, basestring)
cluster, type_, id_ = misc.split_role(role)
assert type_ == 'client'
remote = get_remote_for_role(ctx, role)
mnt = _client_mountpoint(ctx, cluster, id_)
# subdir so we can remove and recreate this a lot without sudo
if subdir is None:
scratch_tmp = os.path.join(mnt, 'client.{id}'.format(id=id_), 'tmp')
else:
scratch_tmp = os.path.join(mnt, subdir)
clonedir = '{tdir}/clone.{role}'.format(tdir=testdir, role=role)
srcdir = '{cdir}/qa/workunits'.format(cdir=clonedir)
git_url = teuth_config.get_ceph_git_url()
try:
remote.run(
logger=log.getChild(role),
args=[
'rm',
'-rf',
clonedir,
run.Raw('&&'),
'git',
'clone',
git_url,
clonedir,
run.Raw('&&'),
'cd', '--', clonedir,
run.Raw('&&'),
'git', 'checkout', refspec,
],
)
except CommandFailedError:
alt_git_url = git_url.replace('ceph-ci', 'ceph')
log.info(
"failed to check out '%s' from %s; will also try in %s",
refspec,
git_url,
alt_git_url,
)
remote.run(
logger=log.getChild(role),
args=[
'rm',
'-rf',
clonedir,
run.Raw('&&'),
'git',
'clone',
alt_git_url,
clonedir,
run.Raw('&&'),
'cd', '--', clonedir,
run.Raw('&&'),
'git', 'checkout', refspec,
],
)
remote.run(
logger=log.getChild(role),
args=[
'cd', '--', srcdir,
run.Raw('&&'),
'if', 'test', '-e', 'Makefile', run.Raw(';'), 'then', 'make', run.Raw(';'), 'fi',
run.Raw('&&'),
'find', '-executable', '-type', 'f', '-printf', r'%P\0'.format(srcdir=srcdir),
run.Raw('>{tdir}/workunits.list.{role}'.format(tdir=testdir, role=role)),
],
)
workunits_file = '{tdir}/workunits.list.{role}'.format(tdir=testdir, role=role)
workunits = sorted(misc.get_file(remote, workunits_file).split('\0'))
assert workunits
try:
assert isinstance(tests, list)
for spec in tests:
log.info('Running workunits matching %s on %s...', spec, role)
prefix = '{spec}/'.format(spec=spec)
to_run = [w for w in workunits if w == spec or w.startswith(prefix)]
if not to_run:
#.........这里部分代码省略.........
开发者ID:beess,项目名称:ceph,代码行数:101,代码来源:workunit.py
示例15: cluster
#.........这里部分代码省略.........
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
fsid = teuthology.create_simple_monmap(
ctx,
remote=mon0_remote,
conf=conf,
)
if not 'global' in conf:
conf['global'] = {}
conf['global']['fsid'] = fsid
log.info('Writing ceph.conf for FSID %s...' % fsid)
conf_path = config.get('conf_path', DEFAULT_CONF_PATH)
write_conf(ctx, conf_path)
log.info('Creating admin key on %s...' % firstmon)
ctx.cluster.only(firstmon).run(
args=[
'sudo',
'adjust-ulimits',
'ceph-coverage',
coverage_dir,
'ceph-authtool',
'--gen-key',
'--name=client.admin',
'--set-uid=0',
'--cap', 'mon', 'allow *',
'--cap', 'osd', 'allow *',
'--cap', 'mds', 'allow *',
keyring_path,
],
)
log.info('Copying monmap to all nodes...')
keyring = teuthology.get_file(
remote=mon0_remote,
path=keyring_path,
)
monmap = teuthology.get_file(
remote=mon0_remote,
path='{tdir}/monmap'.format(tdir=testdir),
)
for rem in ctx.cluster.remotes.iterkeys():
# copy mon key and initial monmap
log.info('Sending monmap to node {remote}'.format(remote=rem))
teuthology.sudo_write_file(
remote=rem,
path=keyring_path,
data=keyring,
perms='0644'
)
teuthology.write_file(
remote=rem,
path='{tdir}/monmap'.format(tdir=testdir),
data=monmap,
)
log.info('Setting up mon nodes...')
mons = ctx.cluster.only(teuthology.is_type('mon'))
run.wait(
mons.run(
args=[
'adjust-ulimits',
'ceph-coverage',
coverage_dir,
'osdmaptool',
开发者ID:kawaguchi-s,项目名称:ceph-qa-suite,代码行数:67,代码来源:ceph.py
示例16: _run_tests
def _run_tests(ctx, refspec, role, tests, env, subdir=None, timeout=None):
"""
Run the individual test. Create a scratch directory and then extract the
workunits from git. Make the executables, and then run the tests.
Clean up (remove files created) after the tests are finished.
:param ctx: Context
:param refspec: branch, sha1, or version tag used to identify this
build
:param tests: specific tests specified.
:param env: environment set in yaml file. Could be None.
:param subdir: subdirectory set in yaml file. Could be None
:param timeout: If present, use the 'timeout' command on the remote host
to limit execution time. Must be specified by a number
followed by 's' for seconds, 'm' for minutes, 'h' for
hours, or 'd' for days. If '0' or anything that evaluates
to False is passed, the 'timeout' command is not used.
"""
testdir = teuthology.get_testdir(ctx)
assert isinstance(role, basestring)
PREFIX = 'client.'
assert role.startswith(PREFIX)
id_ = role[len(PREFIX):]
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
# subdir so we can remove and recreate this a lot without sudo
if subdir is None:
scratch_tmp = os.path.join(mnt, 'client.{id}'.format(id=id_), 'tmp')
else:
scratch_tmp = os.path.join(mnt, subdir)
srcdir = '{tdir}/workunit.{role}'.format(tdir=testdir, role=role)
remote.run(
logger=log.getChild(role),
args=[
'mkdir', '--', srcdir,
run.Raw('&&'),
'git',
'archive',
'--remote=git://ceph.newdream.net/git/ceph.git',
'%s:qa/workunits' % refspec,
run.Raw('|'),
'tar',
'-C', srcdir,
'-x',
'-f-',
run.Raw('&&'),
'cd', '--', srcdir,
run.Raw('&&'),
'if', 'test', '-e', 'Makefile', run.Raw(';'), 'then', 'make', run.Raw(';'), 'fi',
run.Raw('&&'),
'find', '-executable', '-type', 'f', '-printf', r'%P\0'.format(srcdir=srcdir),
run.Raw('>{tdir}/workunits.list'.format(tdir=testdir)),
],
)
workunits = sorted(teuthology.get_file(
remote,
'{tdir}/workunits.list'.format(tdir=testdir)).split('\0'))
assert workunits
try:
assert isinstance(tests, list)
for spec in tests:
log.info('Running workunits matching %s on %s...', spec, role)
prefix = '{spec}/'.format(spec=spec)
to_run = [w for w in workunits if w == spec or w.startswith(prefix)]
if not to_run:
raise RuntimeError('Spec did not match any workunits: {spec!r}'.format(spec=spec))
for workunit in to_run:
log.info('Running workunit %s...', workunit)
args = [
'mkdir', '-p', '--', scratch_tmp,
run.Raw('&&'),
'cd', '--', scratch_tmp,
run.Raw('&&'),
run.Raw('CEPH_CLI_TEST_DUP_COMMAND=1'),
run.Raw('CEPH_REF={ref}'.format(ref=refspec)),
run.Raw('TESTDIR="{tdir}"'.format(tdir=testdir)),
run.Raw('CEPH_ID="{id}"'.format(id=id_)),
]
if env is not None:
for var, val in env.iteritems():
quoted_val = pipes.quote(val)
env_arg = '{var}={val}'.format(var=var, val=quoted_val)
args.append(run.Raw(env_arg))
args.extend([
'adjust-ulimits',
'ceph-coverage',
'{tdir}/archive/coverage'.format(tdir=testdir)])
if timeout and timeout != '0':
args.extend(['timeout', timeout])
args.extend([
'{srcdir}/{workunit}'.format(
srcdir=srcdir,
workunit=workunit,
),
])
remote.run(
logger=log.getChild(role),
#.........这里部分代码省略.........
开发者ID:LalatenduMohanty,项目名称:teuthology,代码行数:101,代码来源:workunit.py
示例17: _run_tests
def _run_tests(ctx, refspec, role, tests, env, subdir=None):
testdir = teuthology.get_testdir(ctx)
assert isinstance(role, basestring)
PREFIX = 'client.'
assert role.startswith(PREFIX)
id_ = role[len(PREFIX):]
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
# subdir so we can remove and recreate this a lot without sudo
if subdir is None:
scratch_tmp = os.path.join(mnt, 'client.{id}'.format(id=id_), 'tmp')
else:
scratch_tmp = os.path.join(mnt, subdir)
srcdir = '{tdir}/workunit.{role}'.format(tdir=testdir, role=role)
remote.run(
logger=log.getChild(role),
args=[
'mkdir', '--', srcdir,
run.Raw('&&'),
'git',
'archive',
'--remote=git://ceph.newdream.net/git/ceph.git',
'%s:qa/workunits' % refspec,
run.Raw('|'),
'tar',
'-C', srcdir,
'-x',
'-f-',
run.Raw('&&'),
'cd', '--', srcdir,
run.Raw('&&'),
'if', 'test', '-e', 'Makefile', run.Raw(';'), 'then', 'make', run.Raw(';'), 'fi',
run.Raw('&&'),
'find', '-executable', '-type', 'f', '-printf', r'%P\0'.format(srcdir=srcdir),
run.Raw('>{tdir}/workunits.list'.format(tdir=testdir)),
],
)
workunits = sorted(teuthology.get_file(
remote,
'{tdir}/workunits.list'.format(tdir=testdir)).split('\0'))
assert workunits
try:
assert isinstance(tests, list)
for spec in tests:
log.info('Running workunits matching %s on %s...', spec, role)
prefix = '{spec}/'.format(spec=spec)
to_run = [w for w in workunits if w == spec or w.startswith(prefix)]
if not to_run:
raise RuntimeError('Spec did not match any workunits: {spec!r}'.format(spec=spec))
for workunit in to_run:
log.info('Running workunit %s...', workunit)
args = [
'mkdir', '-p', '--', scratch_tmp,
run.Raw('&&'),
'cd', '--', scratch_tmp,
run.Raw('&&'),
run.Raw('CEPH_CLI_TEST_DUP_COMMAND=1'),
run.Raw('CEPH_REF={ref}'.format(ref=refspec)),
run.Raw('TESTDIR="{tdir}"'.format(tdir=testdir)),
run.Raw('CEPH_ID="{id}"'.format(id=id_)),
]
if env is not None:
for var, val in env.iteritems():
quoted_val = pipes.quote(val)
env_arg = '{var}={val}'.format(var=var, val=quoted_val)
args.append(run.Raw(env_arg))
args.extend([
'adjust-ulimits',
'ceph-coverage',
'{tdir}/archive/coverage'.format(tdir=testdir),
'{srcdir}/{workunit}'.format(
srcdir=srcdir,
workunit=workunit,
),
])
remote.run(
logger=log.getChild(role),
args=args,
)
remote.run(
logger=log.getChild(role),
args=['sudo', 'rm', '-rf', '--', scratch_tmp],
)
finally:
log.info('Stopping %s on %s...', spec, role)
remote.run(
logger=log.getChild(role),
args=[
'rm', '-rf', '--', '{tdir}/workunits.list'.format(tdir=testdir), srcdir,
],
)
开发者ID:AsherBond,项目名称:teuthology,代码行数:94,代码来源:workunit.py
示例18: cluster
#.........这里部分代码省略.........
conf["global"] = {}
conf["global"]["fsid&qu
|
请发表评论