Fix and tidy backup action

During refactoring of the actions codebase, the backup
action managed to miss getting the default 'args' parameter.

Add args parameter so the the backup action is functional again.

Enable pep8 checking of actions, tidy up issues.

Use boolean action options as real booleans, not as strings.

Change-Id: Ia75dd90ac31dce4009fd44f8c1d582814134e3d9
Closes-Bug: 1583898
This commit is contained in:
James Page 2016-05-20 09:48:08 +01:00
parent 3ce2fa3e40
commit 094873d629
2 changed files with 8 additions and 9 deletions

View File

@ -8,12 +8,10 @@ from time import gmtime, strftime
sys.path.append('hooks')
from charmhelpers.core.host import service_pause, service_resume
from charmhelpers.core.hookenv import (
action_get,
action_set,
action_fail,
status_set,
config,
)
@ -44,10 +42,10 @@ def resume(args):
config_changed()
def backup():
def backup(args):
basedir = (action_get("basedir")).lower()
compress = (action_get("compress"))
incremental = (action_get("incremental"))
compress = action_get("compress")
incremental = action_get("incremental")
sstpw = config("sst-password")
optionlist = []
@ -57,16 +55,17 @@ def backup():
os.makedirs(basedir)
# Build a list of options to pass to innobackupex
if compress is "true":
if compress:
optionlist.append("--compress")
if incremental is "true":
if incremental:
optionlist.append("--incremental")
try:
subprocess.check_call(
['innobackupex', '--compact', '--galera-info', '--rsync',
basedir, '--user=sstuser', '--password=' + sstpw] + optionlist)
basedir, '--user=sstuser',
'--password={}'.format(sstpw)] + optionlist)
action_set({
'time-completed': (strftime("%Y-%m-%d %H:%M:%S", gmtime())),
'outcome': 'Success'}

View File

@ -18,7 +18,7 @@ deps = -r{toxinidir}/requirements.txt
basepython = python2.7
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} hooks unit_tests tests
commands = flake8 {posargs} hooks unit_tests tests actions
charm-proof
[testenv:venv]