Handle empty arguments better

This commit is contained in:
Joshua Boniface 2020-01-04 14:05:42 -05:00
parent c2c6198dae
commit 0a04c5d748
2 changed files with 7 additions and 4 deletions

View File

@ -663,7 +663,7 @@ def list_profile(limit, is_fuzzy=True):
close_database(conn, cur) close_database(conn, cur)
return data return data
def create_profile(name, system_template, network_template, storage_template, userdata, script, arguments=[]): def create_profile(name, system_template, network_template, storage_template, userdata, script, arguments=None):
if list_profile(name, is_fuzzy=False): if list_profile(name, is_fuzzy=False):
retmsg = { 'message': 'The profile "{}" already exists'.format(name) } retmsg = { 'message': 'The profile "{}" already exists'.format(name) }
retcode = 400 retcode = 400
@ -719,7 +719,10 @@ def create_profile(name, system_template, network_template, storage_template, us
retcode = 400 retcode = 400
return retmsg, retcode return retmsg, retcode
if arguments is not None and isinstance(arguments, list):
arguments_formatted = '|'.join(arguments) arguments_formatted = '|'.join(arguments)
else:
arguments_formatted = ''
conn, cur = open_database(config) conn, cur = open_database(config)
try: try:

View File

@ -5071,7 +5071,7 @@ class API_Provisioner_Profile_Root(Resource):
reqargs.get('storage_template', None), reqargs.get('storage_template', None),
reqargs.get('userdata', None), reqargs.get('userdata', None),
reqargs.get('script', None), reqargs.get('script', None),
reqargs.get('arg', None) reqargs.get('arg', [])
) )
api.add_resource(API_Provisioner_Profile_Root, '/provisioner/profile') api.add_resource(API_Provisioner_Profile_Root, '/provisioner/profile')
@ -5164,7 +5164,7 @@ class API_Provisioner_Profile_Element(Resource):
reqargs.get('storage_template', None), reqargs.get('storage_template', None),
reqargs.get('userdata', None), reqargs.get('userdata', None),
reqargs.get('script', None), reqargs.get('script', None),
reqargs.get('arg', None) reqargs.get('arg', [])
) )
@Authenticator @Authenticator