fix: skip virsh calls when only backup is requested

This commit is contained in:
2023-01-14 04:03:46 +01:00
parent 62f97ebd75
commit 317f7c397e
2 changed files with 6 additions and 3 deletions

View File

@@ -24,11 +24,14 @@ if __name__ == "__main__":
FILE = "./config/vms.json" FILE = "./config/vms.json"
vmList = [] vmList = []
skipVirsh = not any([args.skip_ansible, args.skip_nginx,
args.skip_icinga, args.skip_ssh_config])
with open(FILE) as f: with open(FILE) as f:
jsonList = json.load(f) jsonList = json.load(f)
for obj in jsonList: for obj in jsonList:
try: try:
vmo = vm.VM(obj) vmo = vm.VM(obj, skipVirsh)
vmList.append(vmo) vmList.append(vmo)
except ValueError as e: except ValueError as e:
print(e, file=sys.stderr) print(e, file=sys.stderr)

4
vm.py
View File

@@ -5,7 +5,7 @@ class VM:
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates")) environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
def __init__(self, args): def __init__(self, args, skipVirsh):
self.hostname = args.get("hostname") self.hostname = args.get("hostname")
self.subdomains = args.get("subdomains") self.subdomains = args.get("subdomains")
@@ -18,7 +18,7 @@ class VM:
self.ansible = not args.get("noansible") self.ansible = not args.get("noansible")
self.sshOutsidePort = None self.sshOutsidePort = None
if self.isExternal: if self.isExternal or skipVirsh:
self.lease = None self.lease = None
self.ip = None self.ip = None
else: else: