Correct handling of template arguments
This commit is contained in:
parent
9b8dec8991
commit
7ed6308e80
|
@ -3616,30 +3616,34 @@ class API_Provisioner_Template_System_Root(Resource):
|
||||||
id: Message
|
id: Message
|
||||||
"""
|
"""
|
||||||
# Validate arguments
|
# Validate arguments
|
||||||
if not isinstance(reqargs.get('vcpus'), int):
|
try:
|
||||||
|
vcpus = int(reqargs.get('vcpus'))
|
||||||
|
except:
|
||||||
return { "message": "A vcpus value must be an integer" }, 400
|
return { "message": "A vcpus value must be an integer" }, 400
|
||||||
if not isinstance(reqargs.get('vram'), int):
|
try:
|
||||||
|
vram = int(reqargs.get('vram'))
|
||||||
|
except:
|
||||||
return { "message": "A vram value must be an integer" }, 400
|
return { "message": "A vram value must be an integer" }, 400
|
||||||
# Cast boolean arguments
|
# Cast boolean arguments
|
||||||
if bool(strtobool(reqargs.get('serial'))):
|
if bool(strtobool(reqargs.get('serial', False))):
|
||||||
serial = True
|
serial = True
|
||||||
else:
|
else:
|
||||||
serial = False
|
serial = False
|
||||||
if bool(strtobool(reqargs.get('vnc'))):
|
if bool(strtobool(reqargs.get('vnc', False))):
|
||||||
vnc = True
|
vnc = True
|
||||||
vnc_bind = reqargs.get('vnc_bind', None)
|
vnc_bind = reqargs.get('vnc_bind', None)
|
||||||
else:
|
else:
|
||||||
vnc = False
|
vnc = False
|
||||||
vnc_bind = None
|
vnc_bind = None
|
||||||
if bool(strtobool(reqargs.get('node_autostart'))):
|
if bool(strtobool(reqargs.get('node_autostart', False))):
|
||||||
node_autostart = True
|
node_autostart = True
|
||||||
else:
|
else:
|
||||||
node_autostart = False
|
node_autostart = False
|
||||||
|
|
||||||
return api_provisioner.create_template_system(
|
return api_provisioner.create_template_system(
|
||||||
reqargs.get('name'),
|
reqargs.get('name'),
|
||||||
reqargs.get('vcpus'),
|
vcpus,
|
||||||
reqargs.get('vram'),
|
vram,
|
||||||
serial,
|
serial,
|
||||||
vnc,
|
vnc,
|
||||||
vnc_bind,
|
vnc_bind,
|
||||||
|
@ -3745,30 +3749,34 @@ class API_Provisioner_Template_System_Element(Resource):
|
||||||
id: Message
|
id: Message
|
||||||
"""
|
"""
|
||||||
# Validate arguments
|
# Validate arguments
|
||||||
if not isinstance(reqargs.get('vcpus'), int):
|
try:
|
||||||
|
vcpus = int(reqargs.get('vcpus'))
|
||||||
|
except:
|
||||||
return { "message": "A vcpus value must be an integer" }, 400
|
return { "message": "A vcpus value must be an integer" }, 400
|
||||||
if not isinstance(reqargs.get('vram'), int):
|
try:
|
||||||
|
vram = int(reqargs.get('vram'))
|
||||||
|
except:
|
||||||
return { "message": "A vram value must be an integer" }, 400
|
return { "message": "A vram value must be an integer" }, 400
|
||||||
# Cast boolean arguments
|
# Cast boolean arguments
|
||||||
if bool(strtobool(reqargs.get('serial'))):
|
if bool(strtobool(reqargs.get('serial', False))):
|
||||||
serial = True
|
serial = True
|
||||||
else:
|
else:
|
||||||
serial = False
|
serial = False
|
||||||
if bool(strtobool(reqargs.get('vnc'))):
|
if bool(strtobool(reqargs.get('vnc', False))):
|
||||||
vnc = True
|
vnc = True
|
||||||
vnc_bind = reqargs.get('vnc_bind', None)
|
vnc_bind = reqargs.get('vnc_bind', None)
|
||||||
else:
|
else:
|
||||||
vnc = False
|
vnc = False
|
||||||
vnc_bind = None
|
vnc_bind = None
|
||||||
if bool(strtobool(reqargs.get('node_autostart'))):
|
if bool(strtobool(reqargs.get('node_autostart', False))):
|
||||||
node_autostart = True
|
node_autostart = True
|
||||||
else:
|
else:
|
||||||
node_autostart = False
|
node_autostart = False
|
||||||
|
|
||||||
return api_provisioner.create_template_system(
|
return api_provisioner.create_template_system(
|
||||||
template,
|
template,
|
||||||
reqargs.get('vcpus'),
|
vcpus,
|
||||||
reqargs.get('vram'),
|
vram,
|
||||||
serial,
|
serial,
|
||||||
vnc,
|
vnc,
|
||||||
vnc_bind,
|
vnc_bind,
|
||||||
|
|
Loading…
Reference in New Issue