summaryrefslogtreecommitdiffstats
path: root/share/newton_base/openoapi
diff options
context:
space:
mode:
Diffstat (limited to 'share/newton_base/openoapi')
-rw-r--r--share/newton_base/openoapi/flavor.py13
-rw-r--r--share/newton_base/openoapi/hosts.py4
-rwxr-xr-xshare/newton_base/openoapi/hypervisor.py6
-rw-r--r--share/newton_base/openoapi/image.py16
-rw-r--r--share/newton_base/openoapi/limits.py15
-rw-r--r--share/newton_base/openoapi/network.py13
-rw-r--r--share/newton_base/openoapi/server.py31
-rw-r--r--share/newton_base/openoapi/subnet.py15
-rw-r--r--share/newton_base/openoapi/tenants.py5
-rw-r--r--share/newton_base/openoapi/volume.py15
-rw-r--r--share/newton_base/openoapi/vport.py10
11 files changed, 142 insertions, 1 deletions
diff --git a/share/newton_base/openoapi/flavor.py b/share/newton_base/openoapi/flavor.py
index af811f67..18a13987 100644
--- a/share/newton_base/openoapi/flavor.py
+++ b/share/newton_base/openoapi/flavor.py
@@ -63,6 +63,11 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
resp = self._get_flavor(sess, request, flavorid)
content = resp.json()
@@ -187,6 +192,10 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
#check if the flavor is already created: name or id
tmpresp = self._get_flavor(sess, request)
content = tmpresp.json()
@@ -329,6 +338,10 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
#delete extra specs one by one
resp = self._delete_flavor_extra_specs(sess, flavorid)
diff --git a/share/newton_base/openoapi/hosts.py b/share/newton_base/openoapi/hosts.py
index d93336a4..7a311b38 100644
--- a/share/newton_base/openoapi/hosts.py
+++ b/share/newton_base/openoapi/hosts.py
@@ -52,6 +52,10 @@ class Hosts(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/hypervisor.py b/share/newton_base/openoapi/hypervisor.py
index eb0debd4..bfde0f51 100755
--- a/share/newton_base/openoapi/hypervisor.py
+++ b/share/newton_base/openoapi/hypervisor.py
@@ -72,7 +72,11 @@ class Hypervisors(APIView):
vim["domain"] = "Default"
sess = VimDriverUtils.get_session(vim, tenantid)
- logger.info("making request with URI:%s" % req_resource)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
+ logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resource, endpoint_filter = self.service)
diff --git a/share/newton_base/openoapi/image.py b/share/newton_base/openoapi/image.py
index e27d0190..85615275 100644
--- a/share/newton_base/openoapi/image.py
+++ b/share/newton_base/openoapi/image.py
@@ -58,6 +58,10 @@ class imageThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id']\
+ if vim.get('openstack_region_id')\
+ else vim['cloud_region_id']
+
#open imageurl
logger.info("making image put request with URI:%s" % req_resouce)
resp = sess.put(req_resouce, endpoint_filter=self.service, data=imagefd.read(),
@@ -113,6 +117,10 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -186,6 +194,10 @@ class Images(APIView):
#req_body = json.JSONEncoder().encode({"image": image})
req_body = json.JSONEncoder().encode(image)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
@@ -239,6 +251,10 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/limits.py b/share/newton_base/openoapi/limits.py
index fad710f3..d260ab76 100644
--- a/share/newton_base/openoapi/limits.py
+++ b/share/newton_base/openoapi/limits.py
@@ -48,6 +48,11 @@ class Limits(APIView):
req_resouce = "/limits"
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -66,6 +71,11 @@ class Limits(APIView):
#now get quota
# prepare request resource to vim instance
req_resouce = "/v2.0/quotas/%s" % tenantid
+
+ self.service_network['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service_network)
logger.info("request returns with status %s" % resp.status_code)
@@ -75,6 +85,11 @@ class Limits(APIView):
#now get volume limits
# prepare request resource to vim instance
req_resouce = "/limits"
+
+ self.service_volume['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service_volume)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/network.py b/share/newton_base/openoapi/network.py
index 9ad7a83f..9475ee2c 100644
--- a/share/newton_base/openoapi/network.py
+++ b/share/newton_base/openoapi/network.py
@@ -73,6 +73,11 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -135,6 +140,10 @@ class Networks(APIView):
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"network": network})
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
@@ -178,6 +187,10 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making delete request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py
index c5011f15..3e90bf84 100644
--- a/share/newton_base/openoapi/server.py
+++ b/share/newton_base/openoapi/server.py
@@ -63,6 +63,10 @@ class ServerVolumeAttachThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
#check if server is ready to attach
logger.debug("Servers--attach_volume, wait for server to be ACTIVE::>%s" % serverid)
req_resouce = "servers/%s" % serverid
@@ -109,6 +113,10 @@ class ServerVolumeAttachThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
#wait server to be ready to detach volume
# assume attachment id is the same as volume id
@@ -159,6 +167,10 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
for volumeid in volumeIds:
req_resouce = "servers/%s/os-volume_attachments/%s" % (serverId, volumeid)
logger.debug("Servers--dettachVolume::>%s" % (req_resouce))
@@ -234,6 +246,11 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
req_resouce = "servers/%s/os-interface" % serverid
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -258,6 +275,11 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -392,6 +414,11 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.post(req_resouce, data=req_body,
endpoint_filter=self.service,
@@ -450,6 +477,10 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
#check and dettach them if volumes attached to server
server, status_code = self._get_servers("", vimid, tenantid, serverid)
volumearray = server.pop("volumeArray", None)
diff --git a/share/newton_base/openoapi/subnet.py b/share/newton_base/openoapi/subnet.py
index 9ff61f2a..1d4f761b 100644
--- a/share/newton_base/openoapi/subnet.py
+++ b/share/newton_base/openoapi/subnet.py
@@ -75,6 +75,11 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -136,6 +141,11 @@ class Subnets(APIView):
VimDriverUtils.replace_key_by_mapping(subnet,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"subnet": subnet})
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
@@ -180,6 +190,11 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/tenants.py b/share/newton_base/openoapi/tenants.py
index 76fd2137..a8b97464 100644
--- a/share/newton_base/openoapi/tenants.py
+++ b/share/newton_base/openoapi/tenants.py
@@ -52,6 +52,11 @@ class Tenants(APIView):
req_resouce = "/v2.0/tenants"
sess = VimDriverUtils.get_session(vim)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/volume.py b/share/newton_base/openoapi/volume.py
index 827baea9..100d2392 100644
--- a/share/newton_base/openoapi/volume.py
+++ b/share/newton_base/openoapi/volume.py
@@ -76,6 +76,11 @@ class Volumes(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -137,6 +142,11 @@ class Volumes(APIView):
VimDriverUtils.replace_key_by_mapping(volume,
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"volume": volume})
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
logger.debug("with data:%s" % req_body)
resp = sess.post(req_resouce, data=req_body,
@@ -179,6 +189,11 @@ class Volumes(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
diff --git a/share/newton_base/openoapi/vport.py b/share/newton_base/openoapi/vport.py
index 648ec02b..195b820b 100644
--- a/share/newton_base/openoapi/vport.py
+++ b/share/newton_base/openoapi/vport.py
@@ -77,6 +77,11 @@ class Vports(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)
@@ -213,6 +218,11 @@ class Vports(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
+
+ self.service['region_id'] = vim['openstack_region_id'] \
+ if vim.get('openstack_region_id') \
+ else vim['cloud_region_id']
+
logger.info("making request with URI:%s" % req_resouce)
resp = sess.delete(req_resouce, endpoint_filter=self.service)
logger.info("request returns with status %s" % resp.status_code)