:param workload_data:
:return: result code, status enum, status reason
result code: 0-ok, otherwise error
- status enum: "WORKLOAD_CREATE_IN_PROGRESS", "WORKLOAD_CREATE_FAIL"
+ status enum: "CREATE_IN_PROGRESS", "CREATE_FAILED"
status reason: message to explain the status enum
'''
data = workload_data
template_data = data.get("template_data", {})
# resp_template = None
if not template_type or "heat" != template_type.lower():
- return 14, "WORKLOAD_CREATE_FAIL", \
+ return 14, "CREATE_FAILED", \
"Bad parameters: template type %s is not heat" %\
template_type or ""
(cloud_owner, regionid, v2_token_resp_json)
logger.error(errmsg)
return (
- retcode, "WORKLOAD_CREATE_FAIL", errmsg
+ retcode, "CREATE_FAILED", errmsg
)
# tenant_id = v2_token_resp_json["access"]["token"]["tenant"]["id"]
if retcode == 0:
stack1 = content.get('stack', None)
# stackid = stack1["id"] if stack1 else ""
- return 0, "WORKLOAD_CREATE_IN_PROGRESS", stack1
+ return 0, "CREATE_IN_PROGRESS", stack1
else:
self._logger.info("RESP with data> result:%s" % content)
- return retcode, "WORKLOAD_CREATE_FAIL", content
+ return retcode, "CREATE_FAILED", content
def workload_update(self, vimid, stack_id, otherinfo):
'''
:param otherinfo:
:return: result code, status enum, status reason
result code: 0-ok, otherwise error
- status enum: "WORKLOAD_UPDATE_IN_PROGRESS", "WORKLOAD_UPDATE_FAIL"
+ status enum: "UPDATE_IN_PROGRESS", "UPDATE_FAILED"
status reason: message to explain the status enum
'''
errmsg = "authenticate fails:%s, %s, %s" %\
(cloud_owner, regionid, v2_token_resp_json)
logger.error(errmsg)
- return retcode, "WORKLOAD_UPDATE_FAIL", errmsg
+ return retcode, "UPDATE_FAILED", errmsg
tenant_id = v2_token_resp_json["access"]["token"]["tenant"]["id"]
# tenant_name = v2_token_resp_json["access"]["token"]["tenant"]["name"]
errmsg = "stack:%s, query fails: %s" %\
(resource_uri, content)
logger.error(errmsg)
- return retcode, "WORKLOAD_UPDATE_FAIL", errmsg
+ return retcode, "UPDATE_FAILED", errmsg
# find and update resources
# transactions = []
errmsg = "stack: %s, resource not ready :%s" % \
(resource_uri, resource)
logger.info(errmsg)
- return retcode, "WORKLOAD_UPDATE_FAIL", errmsg
+ return retcode, "UPDATE_FAILED", errmsg
# continue
if resource.get('resource_type', None) == 'OS::Nova::Server':
# retrieve vserver details
errmsg = "stack resource:%s, query fails: %s" % \
(resource_uri, content)
logger.error(errmsg)
- return retcode, "WORKLOAD_UPDATE_FAIL", errmsg
+ return retcode, "UPDATE_FAILED", errmsg
vserver_detail = content.get('server', None) if retcode == 0 and content else None
if vserver_detail:
# compose inventory entry for vserver
(aai_resource['uri'], content))
except Exception as e:
self._logger.error(e.message)
- return retcode, "WORKLOAD_UPDATE_FAIL", e.message
+ return retcode, "UPDATE_FAILED", e.message
# aai_resource_transactions = {"put": [aai_resource]}
# transactions.append(aai_resource_transactions)
errmsg = "stack resource:%s, query fails: %s" % \
(resource_uri, content)
logger.error(errmsg)
- return retcode, "WORKLOAD_UPDATE_FAIL", errmsg
+ return retcode, "UPDATE_FAILED", errmsg
vport_detail = content.get('port', None) if retcode == 0 and content else None
if vport_detail:
(aai_resource['uri'], content))
except Exception as e:
self._logger.error(e.message)
- return retcode, "WORKLOAD_UPDATE_FAIL", e.message
+ return retcode, "UPDATE_FAILED", e.message
# aai_resource_transactions = {"put": [aai_resource]}
# transactions.append(aai_resource_transactions)
# aai_transactions = {"transactions": transactions}
# self._logger.debug("aai_transactions :%s" % aai_transactions)
- return 0, "WORKLOAD_UPDATE_COMPLETE", "succeed"
+ return 0, "UPDATE_COMPLETE", "succeed"
def workload_delete(self, vimid, stack_id, otherinfo):
'''
:param otherinfo:
:return: result code, status enum, status reason
result code: 0-ok, otherwise error
- status enum: "WORKLOAD_DELETE_IN_PROGRESS", "WORKLOAD_DELETE_FAIL"
+ status enum: "DELETE_IN_PROGRESS", "DELETE_FAILED"
status reason: message to explain the status enum
'''
errmsg = "authenticate fails:%s, %s, %s" %\
(cloud_owner, regionid, v2_token_resp_json)
logger.error(errmsg)
- return retcode, "WORKLOAD_DELETE_FAIL", errmsg
+ return retcode, "DELETE_FAILED", errmsg
tenant_id = v2_token_resp_json["access"]["token"]["tenant"]["id"]
# tenant_name = v2_token_resp_json["access"]["token"]["tenant"]["name"]
restcall.req_to_aai(vserver_list_url, "GET")
if retcode > 0 or not content:
self._logger.debug("AAI get %s response: %s" % (vserver_list_url, content))
- return (retcode, "WORKLOAD_DELETE_FAIL", "authenticate fails:%s, %s, %s" %
+ return (retcode, "DELETE_FAILED", "authenticate fails:%s, %s, %s" %
(cloud_owner, regionid, v2_token_resp_json))
content = json.JSONDecoder().decode(content)
restcall.req_to_aai(vport_delete_url, "DELETE")
except Exception as e:
- # return 12, "WORKLOAD_DELETE_FAIL", e.message
+ # return 12, "DELETE_FAILED", e.message
pass
try:
except Exception:
continue
- return 0, "WORKLOAD_DELETE_COMPLETE", "succeed"
+ return 0, "DELETE_COMPLETE", "succeed"
except Exception as e:
self._logger.error(e.message)
- return 12, "WORKLOAD_DELETE_FAIL", e.message
+ return 12, "DELETE_FAILED", e.message
pass
def workload_status(self, vimid, stack_id, otherinfo):
errmsg = "authenticate fails:%s, %s, %s" % \
(cloud_owner, regionid, v2_token_resp_json)
logger.error(errmsg)
- return retcode, "WORKLOAD_STATUS_UNKNOWN", errmsg
+ return retcode, "GET_FAILED", errmsg
# get stack status
service_type = "orchestration"
return retcode, stack_status, stacks
except Exception as e:
self._logger.error(e.message)
- return 12, "WORKLOAD_STATUS_UNKNOWN", e.message
+ return 12, "GET_FAILED", e.message
resp_template = {
"template_type": "HEAT",
"workload_id": workloadid,
- "workload_status": "WORKLOAD_CREATE_FAIL",
+ "workload_status": "CREATE_FAILED",
"workload_status_reason": "Exception occurs"
}
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
settings.AAI_BASE_URL
)
if workloadid == "":
- resp_template["workload_status"] = "WORKLOAD_CREATE_FAIL"
+ resp_template["workload_status"] = "CREATE_FAILED"
# post to create a new stack, stack id available only after creating a stack is done
progress_code, progress_status, progress_msg = worker_self.workload_create(vimid, request.data)
resp_template["workload_status"] = progress_status
return Response(data=resp_template, status=status_code)
# return super(InfraWorkload, self).post(request, vimid)
else:
- resp_template["workload_status"] = "WORKLOAD_UPDATE_FAIL"
+ resp_template["workload_status"] = "UPDATE_FAILED"
# a post to heatbridge
backlog_item = {
"id": workloadid,
"repeat": 0, # one time job
# format of status: retcode:0 is ok, otherwise error code from http status, Status ENUM, Message
"status": (
- 0, "WORKLOAD_UPDATE_IN_PROGRESS",
+ 0, "UPDATE_IN_PROGRESS",
"backlog to update workload %s pends to schedule" % workloadid
)
}
)
else:
progress = backlog_item.get("status",
- (13, "WORKLOAD_DELETE_FAIL",
+ (13, "DELETE_FAILED",
"Unexpected:status not found in backlog item")
)
resp_template = {
"template_type": "HEAT",
"workload_id": workloadid,
- "workload_status": "WORKLOAD_GET_FAIL",
+ "workload_status": "GET_FAILED",
"workload_status_reason": "Exception occurs"
}
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
else:
progress = backlog_item.get("status",
- (13, "WORKLOAD_DELETE_FAIL",
+ (13, "GET_FAILED",
"Unexpected:status not found in backlog item")
)
try:
resp_template = {
"template_type": "HEAT",
"workload_id": workloadid,
- "workload_status": "WORKLOAD_DELETE_FAIL",
+ "workload_status": "DELETE_FAILED",
"workload_status_reason": "Exception occurs"
}
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
"repeat": 0, # one time job
# format of status: retcode:0 is ok, otherwise error code from http status, Status ENUM, Message
"status": (
- 0, "WORKLOAD_DELETE_IN_PROGRESS",
+ 0, "DELETE_IN_PROGRESS",
"backlog for delete the workload %s "
"pends to schedule" % workloadid
)
)
else:
progress = backlog_item.get("status",
- (13, "WORKLOAD_DELETE_FAIL",
+ (13, "DELETE_FAILED",
"Unexpected:status not found in backlog item")
)
try:
else:
pass
else:
- self._logger.info("artifacts not available for vfmodule %s" % vfmodule_uuid)
+ self._logger.info("artifacts not available for vfmodule %s" % vf_module_model_customization_id)
pass
except Exception as e:
self._logger.error("template_update fails: %s" % e.message)
:param workload_data:
:return: result code, status enum, status reason
result code: 0-ok, otherwise error
- status enum: "WORKLOAD_CREATE_IN_PROGRESS", "WORKLOAD_CREATE_FAIL"
+ status enum: "CREATE_IN_PROGRESS", "CREATE_FAILED"
status reason: message to explain the status enum
'''
template_data = data.get("template_data", {})
# resp_template = None
if not template_type or "heat" != template_type.lower():
- return 14, "WORKLOAD_CREATE_FAIL", \
+ return 14, "CREATE_FAILED", \
"Bad parameters: template type %s is not heat" %\
template_type or ""
(cloud_owner, regionid, v2_token_resp_json)
logger.error(errmsg)
return (
- retcode, "WORKLOAD_CREATE_FAIL", errmsg
+ retcode, "CREATE_FAILED", errmsg
)
# tenant_id = v2_token_resp_json["access"]["token"]["tenant"]["id"]
if retcode == 0:
stack1 = content.get('stack', None)
# stackid = stack1["id"] if stack1 else ""
- return 0, "WORKLOAD_CREATE_IN_PROGRESS", stack1
+ return 0, "CREATE_IN_PROGRESS", stack1
else:
self._logger.info("RESP with data> result:%s" % content)
- return retcode, "WORKLOAD_CREATE_FAIL", content
+ return retcode, "CREATE_FAILED", content