Convert the charm to Python3
Change-Id: Ibdb9e582d75fd0c7cd130dddae9966aac5da3279
This commit is contained in:
parent
98a5f35b1d
commit
a53b14a19b
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ bin
|
||||
*.py[oc]
|
||||
*.pyc
|
||||
func-results.json
|
||||
.stestr
|
||||
|
@ -1,4 +1,3 @@
|
||||
- project:
|
||||
templates:
|
||||
- python-charm-jobs
|
||||
- openstack-python35-jobs-nonvoting
|
||||
- python35-charm-jobs
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2016 Canonical Ltd
|
||||
#
|
||||
|
@ -99,7 +99,7 @@ def restart_map():
|
||||
that should be restarted when file changes.
|
||||
"""
|
||||
_map = []
|
||||
for f, ctxt in CONFIG_FILES.iteritems():
|
||||
for f, ctxt in CONFIG_FILES.items():
|
||||
svcs = []
|
||||
for svc in ctxt['services']:
|
||||
svcs.append(svc)
|
||||
@ -111,9 +111,10 @@ def restart_map():
|
||||
def set_ceph_env_variables(service):
|
||||
# XXX: Horrid kludge to make cinder-backup use
|
||||
# a different ceph username than admin
|
||||
env = open('/etc/environment', 'r').read()
|
||||
with open('/etc/environment', 'rt') as f:
|
||||
env = f.read()
|
||||
if 'CEPH_ARGS' not in env:
|
||||
with open('/etc/environment', 'a') as out:
|
||||
with open('/etc/environment', 'at') as out:
|
||||
out.write('CEPH_ARGS="--id %s"\n' % service)
|
||||
with open('/etc/init/cinder-backup.override', 'w') as out:
|
||||
with open('/etc/init/cinder-backup.override', 'wt') as out:
|
||||
out.write('env CEPH_ARGS="--id %s"\n' % service)
|
||||
|
@ -745,7 +745,7 @@ class CinderBackupBasicDeployment(OpenStackAmuletDeployment):
|
||||
# NOTE(hopem): it appears that at some point cinder-backup stopped
|
||||
# restoring volume metadata properly so revert to default name if
|
||||
# original is not found
|
||||
name = "restore_backup_%s" % (vol_backup.id)
|
||||
name = "restore_backup_{}".format(vol_backup.id)
|
||||
try:
|
||||
cinder_vols = [v for v in vols if v.name == name]
|
||||
except AttributeError:
|
||||
@ -753,11 +753,11 @@ class CinderBackupBasicDeployment(OpenStackAmuletDeployment):
|
||||
|
||||
if not cinder_vols:
|
||||
try:
|
||||
msg = ("Could not find restore vol '%s' in %s" %
|
||||
(name, [v.name for v in vols]))
|
||||
msg = ("Could not find restore vol '{}' in {}"
|
||||
.format(name, [v.name for v in vols]))
|
||||
except AttributeError:
|
||||
msg = ("Could not find restore vol '%s' in %s" %
|
||||
(name, [v.display_name for v in vols]))
|
||||
msg = ("Could not find restore vol '{}' in {}"
|
||||
.format(name, [v.display_name for v in vols]))
|
||||
u.log.error(msg)
|
||||
amulet.raise_status(amulet.FAIL, msg=msg)
|
||||
|
||||
|
3
tox.ini
3
tox.ini
@ -2,7 +2,7 @@
|
||||
# This file is managed centrally by release-tools and should not be modified
|
||||
# within individual charm repos.
|
||||
[tox]
|
||||
envlist = pep8,py27
|
||||
envlist = pep8,py3{5,6}
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
@ -20,6 +20,7 @@ passenv = HOME TERM AMULET_* CS_API_*
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = /bin/true
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
|
@ -14,3 +14,4 @@
|
||||
|
||||
import sys
|
||||
sys.path.append('hooks')
|
||||
sys.path.append('unit_tests')
|
||||
|
@ -35,7 +35,7 @@ def load_config():
|
||||
|
||||
if not config:
|
||||
logging.error('Could not find config.yaml in any parent directory '
|
||||
'of %s. ' % __file__)
|
||||
'of %s.'.format(__file__))
|
||||
raise Exception
|
||||
|
||||
return yaml.safe_load(open(config).read())['options']
|
||||
@ -47,7 +47,7 @@ def get_default_config():
|
||||
"""
|
||||
default_config = {}
|
||||
config = load_config()
|
||||
for k, v in config.iteritems():
|
||||
for k, v in config.items():
|
||||
if 'default' in v:
|
||||
default_config[k] = v['default']
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user