From 618a1c1c103f740baae22fd0535d4ceadf085082 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 16 Nov 2023 16:17:17 -0500 Subject: [PATCH] Add helper functions to VMBuilder instances --- api-daemon/pvcapid/vmbuilder.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/api-daemon/pvcapid/vmbuilder.py b/api-daemon/pvcapid/vmbuilder.py index 2ae2aece..bc1e90df 100755 --- a/api-daemon/pvcapid/vmbuilder.py +++ b/api-daemon/pvcapid/vmbuilder.py @@ -34,7 +34,7 @@ from contextlib import contextmanager from pvcapid.Daemon import config from daemon_lib.zkhandler import ZKHandler -from daemon_lib.celery import start, fail, log_info, log_warn, update, finish +from daemon_lib.celery import start, fail, log_info, log_warn, log_err, update, finish import daemon_lib.common as pvc_common import daemon_lib.node as pvc_node @@ -87,6 +87,26 @@ class VMBuilder(object): self.vm_profile = vm_profile self.vm_data = vm_data + # + # Helper class functions; used by the individual scripts + # + def log_info(self, msg): + log_info(None, msg) + + def log_warn(self, msg): + log_warn(None, msg) + + def log_err(self, msg): + log_err(None, msg) + + def fail(self, msg): + self.log_err(msg) + try: + self.cleanup() + except Exception: + pass + raise ProvisioningError() + # # Primary class functions; implemented by the individual scripts #