From 0a04c5d74869f6a0f98ef6d5039ae81d46cd333c Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 4 Jan 2020 14:05:42 -0500 Subject: [PATCH] Handle empty arguments better --- client-api/api_lib/pvcapi_provisioner.py | 7 +++++-- client-api/pvc-api.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client-api/api_lib/pvcapi_provisioner.py b/client-api/api_lib/pvcapi_provisioner.py index 261da763..bf9dd45d 100755 --- a/client-api/api_lib/pvcapi_provisioner.py +++ b/client-api/api_lib/pvcapi_provisioner.py @@ -663,7 +663,7 @@ def list_profile(limit, is_fuzzy=True): close_database(conn, cur) 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): retmsg = { 'message': 'The profile "{}" already exists'.format(name) } retcode = 400 @@ -719,7 +719,10 @@ def create_profile(name, system_template, network_template, storage_template, us retcode = 400 return retmsg, retcode - arguments_formatted = '|'.join(arguments) + if arguments is not None and isinstance(arguments, list): + arguments_formatted = '|'.join(arguments) + else: + arguments_formatted = '' conn, cur = open_database(config) try: diff --git a/client-api/pvc-api.py b/client-api/pvc-api.py index ef9593e5..6e07d133 100755 --- a/client-api/pvc-api.py +++ b/client-api/pvc-api.py @@ -5071,7 +5071,7 @@ class API_Provisioner_Profile_Root(Resource): reqargs.get('storage_template', None), reqargs.get('userdata', None), reqargs.get('script', None), - reqargs.get('arg', None) + reqargs.get('arg', []) ) 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('userdata', None), reqargs.get('script', None), - reqargs.get('arg', None) + reqargs.get('arg', []) ) @Authenticator