summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2018-11-24 09:49:15 +0000
committerBin Yang <bin.yang@windriver.com>2018-11-27 13:07:43 +0000
commitd60ccadfb84bbdb18e480f6550d27c51f0c21661 (patch)
treeac3e1e3224d2ca2e8252d54c380d02d51fb270a0
parentadab0a38879e8f6d5d85f986a6c9008c548be69a (diff)
Add filter to queries
Change-Id: I8845592fa9a52ce5aac382885072dee66d664f23 Issue-ID: MULTICLOUD-417 Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com> (cherry picked from commit 370ed53582ba1da526b7cc7c52fd780eb7a5b70b)
-rw-r--r--share/newton_base/openoapi/network.py8
-rw-r--r--share/newton_base/openoapi/subnet.py12
-rw-r--r--share/newton_base/openoapi/vport.py11
3 files changed, 25 insertions, 6 deletions
diff --git a/share/newton_base/openoapi/network.py b/share/newton_base/openoapi/network.py
index 2206143a..0f4a2df1 100644
--- a/share/newton_base/openoapi/network.py
+++ b/share/newton_base/openoapi/network.py
@@ -45,7 +45,11 @@ class Networks(APIView):
logger.debug("With data = %s" % request.data)
pass
try:
- query = VimDriverUtils.get_query_part(request)
+ querystr = VimDriverUtils.get_query_part(request)
+ query = "project_id=%s" % (tenantid)
+ if querystr:
+ query += "&" + querystr
+
content, status_code = self._get_networks(query, vimid, tenantid, networkid)
logger.info("response with status = %s" % status_code)
return Response(data=content, status=status_code)
@@ -115,7 +119,7 @@ class Networks(APIView):
pass
try:
#check if created already: check name
- query = "name=%s" % request.data["name"]
+ query = "project_id=%s&name=%s" % (tenantid, request.data["name"])
content, status_code = self._get_networks(query, vimid, tenantid)
existed = False
if status_code == 200:
diff --git a/share/newton_base/openoapi/subnet.py b/share/newton_base/openoapi/subnet.py
index a5cef9c7..06e029a8 100644
--- a/share/newton_base/openoapi/subnet.py
+++ b/share/newton_base/openoapi/subnet.py
@@ -48,7 +48,11 @@ class Subnets(APIView):
pass
try:
# prepare request resource to vim instance
- query = VimDriverUtils.get_query_part(request)
+ querystr = VimDriverUtils.get_query_part(request)
+ query = "project_id=%s" % (tenantid)
+ if querystr:
+ query += "&" + querystr
+
content, status_code = self._get_subnets(query, vimid, tenantid, subnetid)
logger.info("request returns with status %s" % status_code)
return Response(data=content, status=status_code)
@@ -117,7 +121,11 @@ class Subnets(APIView):
pass
try:
#check if created already: check name
- query = "name=%s" % request.data["name"]
+ query = "project_id=%s&name=%s" % (tenantid, request.data["name"])
+ networkid = request.data.get("networkId", None)
+ if networkid:
+ query += "&network_id=%s" % networkid
+
content, status_code = self._get_subnets(query, vimid, tenantid)
existed = False
if status_code == 200:
diff --git a/share/newton_base/openoapi/vport.py b/share/newton_base/openoapi/vport.py
index 5a799262..ca6297dc 100644
--- a/share/newton_base/openoapi/vport.py
+++ b/share/newton_base/openoapi/vport.py
@@ -47,7 +47,11 @@ class Vports(APIView):
pass
try:
# prepare request resource to vim instance
- query = VimDriverUtils.get_query_part(request)
+ querystr = VimDriverUtils.get_query_part(request)
+ query = "project_id=%s" % (tenantid)
+ if querystr:
+ query += "&" + querystr
+
content, status_code = self._get_ports(query, vimid, tenantid, portid)
logger.info("response with status = %s" % status_code)
return Response(data=content, status=status_code)
@@ -127,7 +131,10 @@ class Vports(APIView):
pass
try:
#check if already created: name
- query = "name=%s" % request.data["name"]
+ query = "project_id=%s&name=%s" % (tenantid, request.data["name"])
+ networkid = request.data.get("networkId", None)
+ if networkid:
+ query += "&network_id=%s" % networkid
content, status_code = self._get_ports(query, vimid, tenantid, portid)
existed = False
if status_code == 200: