diff options
Diffstat (limited to 'share/newton_base')
-rw-r--r-- | share/newton_base/openoapi/flavor.py | 13 | ||||
-rw-r--r-- | share/newton_base/openoapi/hosts.py | 4 | ||||
-rwxr-xr-x | share/newton_base/openoapi/hypervisor.py | 6 | ||||
-rw-r--r-- | share/newton_base/openoapi/image.py | 16 | ||||
-rw-r--r-- | share/newton_base/openoapi/limits.py | 15 | ||||
-rw-r--r-- | share/newton_base/openoapi/network.py | 13 | ||||
-rw-r--r-- | share/newton_base/openoapi/server.py | 31 | ||||
-rw-r--r-- | share/newton_base/openoapi/subnet.py | 15 | ||||
-rw-r--r-- | share/newton_base/openoapi/tenants.py | 5 | ||||
-rw-r--r-- | share/newton_base/openoapi/volume.py | 15 | ||||
-rw-r--r-- | share/newton_base/openoapi/vport.py | 10 | ||||
-rw-r--r-- | share/newton_base/proxy/dnsaasdelegate.py | 5 | ||||
-rw-r--r-- | share/newton_base/proxy/services.py | 11 | ||||
-rw-r--r-- | share/newton_base/registration/registration.py | 21 |
14 files changed, 172 insertions, 8 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) diff --git a/share/newton_base/proxy/dnsaasdelegate.py b/share/newton_base/proxy/dnsaasdelegate.py index 4ffe29f8..07ba1b51 100644 --- a/share/newton_base/proxy/dnsaasdelegate.py +++ b/share/newton_base/proxy/dnsaasdelegate.py @@ -128,9 +128,12 @@ class DnsaasDelegate(Services): service = { 'service_type': servicetype, 'interface': interface, - 'region_id': regionid + 'region_id': vim['openstack_region_id'] + if vim.get('openstack_region_id') + else vim['cloud_region_id'] } + req_resource = requri querystr = VimDriverUtils.get_query_part(request) if querystr: diff --git a/share/newton_base/proxy/services.py b/share/newton_base/proxy/services.py index a6076bb7..6aa1bbce 100644 --- a/share/newton_base/proxy/services.py +++ b/share/newton_base/proxy/services.py @@ -103,9 +103,12 @@ class Services(APIView): service = { 'service_type': servicetype, 'interface': interface, - 'region_id': regionid + 'region_id': vim['openstack_region_id'] + if vim.get('openstack_region_id') + else vim['cloud_region_id'] } + querystr = VimDriverUtils.get_query_part(request) if querystr: req_resource += "?" + querystr @@ -183,7 +186,11 @@ class Services(APIView): interface = 'public' service = {'service_type': servicetype, 'interface': interface, - 'region_id': regionid} + 'region_id': vim['openstack_region_id'] + if vim.get('openstack_region_id') + else vim['cloud_region_id'] + } + self._logger.info("service head request with uri %s" % (req_resource)) resp = sess.head(req_resource, endpoint_filter=service) diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py index c3aaec24..41fe5733 100644 --- a/share/newton_base/registration/registration.py +++ b/share/newton_base/registration/registration.py @@ -41,7 +41,10 @@ class Registry(APIView): vimid, content_key): service = {'service_type': service_type, 'interface': 'public', - 'region_id': viminfo['cloud_region_id']} + 'region_id': viminfo['openstack_region_id'] + if viminfo.get('openstack_region_id') + else viminfo['cloud_region_id']} + self._logger.info("making request with URI:%s" % resource_url) resp = session.get(resource_url, endpoint_filter=service) self._logger.info("request returns with status %s" % resp.status_code) @@ -248,7 +251,11 @@ class Registry(APIView): req_resource = schema service = {'service_type': "image", 'interface': 'public', - 'region_id': viminfo['cloud_region_id']} + 'region_id': viminfo['openstack_region_id'] + if viminfo.get('openstack_region_id') + else viminfo['cloud_region_id'] + } + self._logger.info("making request with URI:%s" % req_resource) resp = session.get(req_resource, endpoint_filter=service) self._logger.info("request returns with status %s" % resp.status_code) @@ -291,7 +298,11 @@ class Registry(APIView): req_resource = "/os-hypervisors/detail?hypervisor_hostname_pattern=%s" % k service = {'service_type': "compute", 'interface': 'public', - 'region_id': viminfo['cloud_region_id']} + 'region_id': viminfo['openstack_region_id'] + if viminfo.get('openstack_region_id') + else viminfo['cloud_region_id'] + } + self._logger.info("making request with URI:%s" % req_resource) resp = session.get(req_resource, endpoint_filter=service) self._logger.info("request returns with status %s" % resp.status_code) @@ -558,7 +569,9 @@ class Registry(APIView): # add resource-version to url if retcode == 0 and content: viminfo = json.JSONDecoder().decode(content) - viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid + viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid \ + if self.proxy_prefix[-3:] == "/v0" else \ + self.proxy_prefix + "/%s/%s/identity/v2.0" % extsys.decode_vim_id(vimid) retcode, content, status_code = \ restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" |