mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 05:41:35 +01:00
fix: checks for return codes
This commit is contained in:
15
backup.py
15
backup.py
@@ -146,15 +146,22 @@ def noHighData(hostname, pathsToOptions, path):
|
|||||||
|
|
||||||
def sizeChanged(hostname, pathsToOptions, path):
|
def sizeChanged(hostname, pathsToOptions, path):
|
||||||
|
|
||||||
|
# keep all generated paths #
|
||||||
if "*" in path:
|
if "*" in path:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# if there are no options keep it #
|
||||||
options = pathsToOptions[path]
|
options = pathsToOptions[path]
|
||||||
if not options:
|
if not options or not "onlyifchanged" in options:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# check server #
|
||||||
cmd = ["ssh", hostname, "-t", "/opt/check_dir_size_for_backup.py", path ]
|
cmd = ["ssh", hostname, "-t", "/opt/check_dir_size_for_backup.py", path ]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding="utf-8")
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding="utf-8")
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
result = json.loads(p.stdout)
|
if p.wait() != 0:
|
||||||
return result.changed
|
raise OSError("ssh commmand for backup size info failed '{}' - '{}'".format(stderr, stdout))
|
||||||
|
|
||||||
|
# parse response #
|
||||||
|
result = json.loads(stdout)
|
||||||
|
return result["changed"]
|
||||||
|
|||||||
Reference in New Issue
Block a user