def ccqHubSub():
VARS = request.json
jobScriptLocation = VARS['jobScriptLocation']
jobScriptText = VARS['jobScriptFile']
ccOptionsParsed = VARS['ccOptionsCommandLine']
jobName = VARS['jobName']
jobMD5Hash = VARS["jobMD5Hash"]
userName = VARS["userName"]
password = VARS["password"]
valKey = VARS['valKey']
dateExpires = VARS['dateExpires']
certLength = VARS['certLength']
ccAccessKey = VARS['ccAccessKey']
targetName = VARS['targetName']
remoteUserName = VARS['remoteUserName']
additionalActionsAndPermissionsRequired = VARS['additionalActionsAndPermissionsRequired']
# Since we are not calculating the instance type here we need to set it to None. It will be updated later on when we get the info from the ccq scheduler.
# If the job stays for a local scheduler then this argument is never needed.
ccOptionsParsed['instanceType'] = ccOptionsParsed['requestedInstanceType']
values = validateCreds(userName, password, dateExpires, valKey, certLength, ccAccessKey, remoteUserName, additionalActionsAndPermissionsRequired)
if values['status'] != "success":
#Credentials failed to validate on the server send back error message and failure
return {"status": "failure", "payload": {"message": str(values['payload']), "cert": str(None)}}
else:
identity = values['payload']['identity']
userName = values['payload']['userName']
password = values['payload']['password']
cert = values['payload']['cert']
#TODO implement pricing calls to the instances
# The unique identification of the user who submitted the job is the combination of the identity object and the username that they provide for the job
# They are required to provide a username for the job when submitting through ccqHubsub.
obj = {"jobScriptLocation": str(jobScriptLocation), "jobScriptText": str(jobScriptText), "jobName": str(jobName), "ccOptionsCommandLine": ccOptionsParsed, "jobMD5Hash": jobMD5Hash, "userName": str(userName), "targetName": str(targetName), "identity": str(identity)}
values = ccqHubMethods.saveJobScript(**obj)
if values['status'] != "success":
return {"status": "error", "payload": {"message": values['payload'], "cert": str(None)}}
else:
obj = {"jobScriptLocation": str(jobScriptLocation), "jobScriptText": str(jobScriptText), "jobName": str(jobName), "ccOptionsParsed": ccOptionsParsed, "userName": str(userName), "isRemoteSubmit": "True", "identity": str(identity), "targetName": str(targetName)}
results = ccqHubMethods.saveJob(**obj)
if results['status'] != "success":
return {"status": "error", "payload": {"message": values['payload'], "cert": str(None)}}
else:
generatedJobId = results['payload']['jobId']
return {"status": "success", "payload": {"message": "The job has successfully been submitted to ccqHub. The job id is: " + str(generatedJobId) + ".\n You may use this job id to lookup the job's status using the ccqstat utility.", "cert": str(cert)}}
评论列表
文章目录