diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index fb245b5f..b2672801 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -28,7 +28,7 @@ import gevent.pywsgi import flask -from distutils.util import strtobool +from distutils.util import strtobool as dustrtobool from functools import wraps @@ -45,6 +45,13 @@ from flask_sqlalchemy import SQLAlchemy API_VERSION = 1.0 +def strtobool(stringv): + if stringv is None: + return False + if isinstance(stringv, bool): + return bool(stringv) + return bool(dustrtobool(stringv)) + # Parse the configuration file try: pvc_config_file = os.environ['PVC_CONFIG_FILE'] diff --git a/api-daemon/pvcapid/helper.py b/api-daemon/pvcapid/helper.py index 0e284859..e3b25cde 100755 --- a/api-daemon/pvcapid/helper.py +++ b/api-daemon/pvcapid/helper.py @@ -24,7 +24,7 @@ import flask import json import lxml.etree as etree -from distutils.util import strtobool +from distutils.util import strtobool as dustrtobool import daemon_lib.common as pvc_common import daemon_lib.cluster as pvc_cluster @@ -33,6 +33,13 @@ import daemon_lib.vm as pvc_vm import daemon_lib.network as pvc_network import daemon_lib.ceph as pvc_ceph +def strtobool(stringv): + if stringv is None: + return False + if isinstance(stringv, bool): + return bool(stringv) + return bool(dustrtobool(stringv)) + # # Initialization function # diff --git a/api-daemon/pvcapid/provisioner.py b/api-daemon/pvcapid/provisioner.py index c2e3a828..fd81e4d3 100755 --- a/api-daemon/pvcapid/provisioner.py +++ b/api-daemon/pvcapid/provisioner.py @@ -30,7 +30,7 @@ import time import shlex import subprocess -from distutils.util import strtobool +from distutils.util import strtobool as dustrtobool import daemon_lib.common as pvc_common import daemon_lib.node as pvc_node @@ -42,6 +42,13 @@ import pvcapid.libvirt_schema as libvirt_schema from pvcapid.ova import list_ova +def strtobool(stringv): + if stringv is None: + return False + if isinstance(stringv, bool): + return bool(stringv) + return bool(dustrtobool(stringv)) + # # Exceptions (used by Celery tasks) #