Use custom strtobool to handle weird edge cases
This commit is contained in:
parent
36588a3a81
commit
d36d8e0637
|
@ -28,7 +28,7 @@ import gevent.pywsgi
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool as dustrtobool
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
@ -45,6 +45,13 @@ from flask_sqlalchemy import SQLAlchemy
|
||||||
|
|
||||||
API_VERSION = 1.0
|
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
|
# Parse the configuration file
|
||||||
try:
|
try:
|
||||||
pvc_config_file = os.environ['PVC_CONFIG_FILE']
|
pvc_config_file = os.environ['PVC_CONFIG_FILE']
|
||||||
|
|
|
@ -24,7 +24,7 @@ import flask
|
||||||
import json
|
import json
|
||||||
import lxml.etree as etree
|
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.common as pvc_common
|
||||||
import daemon_lib.cluster as pvc_cluster
|
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.network as pvc_network
|
||||||
import daemon_lib.ceph as pvc_ceph
|
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
|
# Initialization function
|
||||||
#
|
#
|
||||||
|
|
|
@ -30,7 +30,7 @@ import time
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool as dustrtobool
|
||||||
|
|
||||||
import daemon_lib.common as pvc_common
|
import daemon_lib.common as pvc_common
|
||||||
import daemon_lib.node as pvc_node
|
import daemon_lib.node as pvc_node
|
||||||
|
@ -42,6 +42,13 @@ import pvcapid.libvirt_schema as libvirt_schema
|
||||||
|
|
||||||
from pvcapid.ova import list_ova
|
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)
|
# Exceptions (used by Celery tasks)
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue