summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2018-11-30 08:52:54 +0000
committerBin Yang <bin.yang@windriver.com>2018-12-26 03:05:22 +0000
commitaf748bc7968795759037202d2740777e81866f0b (patch)
treea81f6eeb387e9fa3cebe0c17eecfe76b2cf20b07
parent249bb57d39d783349232b8e515ef6bd58b8d069e (diff)
Fix issue of Delete Infra_workload
Enforce client to pass in workload_id Change-Id: I017321920aad665bee352499e0b43f5c5db5898c Issue-ID: MULTICLOUD-423 Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
-rw-r--r--ocata/ocata/resource/views/infra_workload.py16
-rw-r--r--pike/pike/resource/views/infra_workload.py12
-rw-r--r--windriver/titanium_cloud/resource/views/infra_workload.py8
3 files changed, 27 insertions, 9 deletions
diff --git a/ocata/ocata/resource/views/infra_workload.py b/ocata/ocata/resource/views/infra_workload.py
index d78e3cee..b9d754b6 100644
--- a/ocata/ocata/resource/views/infra_workload.py
+++ b/ocata/ocata/resource/views/infra_workload.py
@@ -41,7 +41,7 @@ class InfraWorkload(APIView):
self._logger.info("data: %s" % request.data)
self._logger.debug("META: %s" % request.META)
- try :
+ try:
data = request.data
oof_directive = data.get("oof_directives", {})
template_type = data.get("template_type", None)
@@ -59,7 +59,7 @@ class InfraWorkload(APIView):
for attr in directive2.get("attributes", []):
label_name = attr["attribute_name"]
label_value = attr["attribute_value"]
- if parameters.has_key(label_name):
+ if label_name in parameters:
template_data["parameters"][label_name] = label_value
else:
self._logger.warn("There is no parameter exist: %s" % label_name)
@@ -119,7 +119,7 @@ class InfraWorkload(APIView):
self._logger.info("vimid, requri: %s, %s" % (vimid, requri))
self._logger.debug("META: %s" % request.META)
- try :
+ try:
# assume the workload_type is heat
template_type = "heat"
stack_id = requri
@@ -299,13 +299,19 @@ class InfraWorkload(APIView):
aai_transactions = {"transactions": transactions}
self._logger.debug("aai_transactions :%s" % aai_transactions)
- return aai_transactions
+ return aai_transactions
def delete(self, request, vimid="", requri=""):
self._logger.info("vimid, requri: %s, %s" % (vimid, requri))
self._logger.debug("META: %s" % request.META)
- try :
+ try:
+ if requri == "":
+ raise VimDriverNewtonException(
+ message="workload_id is not specified",
+ content="workload_id must be specified to delete the workload",
+ status_code=400)
+
# assume the workload_type is heat
template_type = "heat"
stack_id = requri
diff --git a/pike/pike/resource/views/infra_workload.py b/pike/pike/resource/views/infra_workload.py
index d78e3cee..45352bde 100644
--- a/pike/pike/resource/views/infra_workload.py
+++ b/pike/pike/resource/views/infra_workload.py
@@ -59,7 +59,7 @@ class InfraWorkload(APIView):
for attr in directive2.get("attributes", []):
label_name = attr["attribute_name"]
label_value = attr["attribute_value"]
- if parameters.has_key(label_name):
+ if label_name in parameters:
template_data["parameters"][label_name] = label_value
else:
self._logger.warn("There is no parameter exist: %s" % label_name)
@@ -67,7 +67,7 @@ class InfraWorkload(APIView):
# update parameters
template_data["parameters"] = parameters
- #reset to make sure "files" are empty
+ # reset to make sure "files" are empty
template_data["file"] = {}
#authenticate
@@ -305,7 +305,13 @@ class InfraWorkload(APIView):
self._logger.info("vimid, requri: %s, %s" % (vimid, requri))
self._logger.debug("META: %s" % request.META)
- try :
+ try:
+ if requri == "":
+ raise VimDriverNewtonException(
+ message="workload_id is not specified",
+ content="workload_id must be specified to delete the workload",
+ status_code=400)
+
# assume the workload_type is heat
template_type = "heat"
stack_id = requri
diff --git a/windriver/titanium_cloud/resource/views/infra_workload.py b/windriver/titanium_cloud/resource/views/infra_workload.py
index ec1e5744..e4b4b0b5 100644
--- a/windriver/titanium_cloud/resource/views/infra_workload.py
+++ b/windriver/titanium_cloud/resource/views/infra_workload.py
@@ -176,7 +176,13 @@ class InfraWorkload(APIView):
self._logger.info("vimid,requri: %s, %s" % (vimid,requri))
self._logger.debug("META: %s" % request.META)
- try :
+ try:
+ if requri == "":
+ raise VimDriverNewtonException(
+ message="workload_id is not specified",
+ content="workload_id must be specified to delete the workload",
+ status_code=400)
+
# assume the workload_type is heat
stack_id = requri
cloud_owner, regionid = extsys.decode_vim_id(vimid)