Some fixes for passing arguments to system/management jobs

This commit is contained in:
Matthew Jones
2014-12-12 13:40:10 -05:00
parent c0f4f7185b
commit 1e1ea4e9ee
2 changed files with 11 additions and 6 deletions

View File

@@ -1755,8 +1755,11 @@ class SystemJobTemplateLaunch(GenericAPIView):
new_job = obj.create_unified_job() new_job = obj.create_unified_job()
if 'extra_vars' in request.DATA: if 'extra_vars' in request.DATA:
try: try:
extra_vars = json.loads(request.DATA['extra_vars']) if type(request.DATA['extra_vars']) == dict:
except Exception: extra_vars = request.DATA['extra_vars']
else:
extra_vars = json.loads(request.DATA['extra_vars'])
except Exception, e:
extra_vars = {} extra_vars = {}
else: else:
extra_vars = {} extra_vars = {}

View File

@@ -994,13 +994,15 @@ class SystemJob(UnifiedJob, SystemJobOptions):
def handle_extra_data(self, extra_data): def handle_extra_data(self, extra_data):
if extra_data == "" or extra_data is None: if extra_data == "" or extra_data is None:
return return
try:
evars = json.loads(self.extra_vars)
except Exception, e:
evars = {}
if type(extra_data) == str: if type(extra_data) == str:
try: try:
evars = json.loads(self.extra_vars) extra_data = json.loads(extra_data)
except Exception, e: except Exception, e:
return extra_data = {}
else:
evars = extra_data
if evars is None: if evars is None:
evars = extra_data evars = extra_data
else: else: