tasks/ceph-deploy: Install appropriate Python version before running

Related to RM-15016

Signed-off-by: Oleh Prypin <oleh@pryp.in>
This commit is contained in:
Oleh Prypin 2016-06-22 19:19:12 +03:00
parent 9c1a28210e
commit c5dbbfc545

View File

@ -27,9 +27,38 @@ def download_ceph_deploy(ctx, config):
will use that instead. The `bootstrap` script is ran, with the argument
obtained from `python_version`, if specified.
"""
ceph_admin = ctx.cluster.only(teuthology.get_first_mon(ctx, config))
try:
py_ver = str(config['python_version'])
except KeyError:
pass
else:
supported_versions = ['2', '3']
if py_ver not in supported_versions:
raise ValueError("python_version must be: {}, not {}".format(
' or '.join(supported_versions), py_ver
))
log.info("Installing Python")
for admin in ceph_admin.remotes:
system_type = teuthology.get_system_type(admin)
if system_type == 'rpm':
package = 'python34' if py_ver == '3' else 'python'
ctx.cluster.run(args=[
'sudo', 'yum', '-y', 'install',
package, 'python-virtualenv'
])
else:
package = 'python3' if py_ver == '3' else 'python'
ctx.cluster.run(args=[
'sudo', 'apt-get', '-y', '--force-yes', 'install',
package, 'python-virtualenv'
])
log.info('Downloading ceph-deploy...')
testdir = teuthology.get_testdir(ctx)
ceph_admin = ctx.cluster.only(teuthology.get_first_mon(ctx, config))
ceph_deploy_branch = config.get('ceph-deploy-branch', 'master')
ceph_admin.run(