diff options
author | Bin Yang <bin.yang@windriver.com> | 2018-08-16 04:32:18 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2018-08-17 06:21:56 +0000 |
commit | 591cdc9da7149fa4e68eac0de2efa8efd25281d6 (patch) | |
tree | fa75681ece5154f4215d78f104661fa99419b504 /share/newton_base/openoapi/server.py | |
parent | 400e1b7c35a1db4cdcf20f4453631bc0888a330f (diff) |
multi-region discovery
Decouple the openstack region id from cloud-region-id
Change-Id: If4bfacf05d87ca4bc97a485d4153f4f379ad451a
Issue-ID: MULTICLOUD-311
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/newton_base/openoapi/server.py')
-rw-r--r-- | share/newton_base/openoapi/server.py | 31 |
1 files changed, 31 insertions, 0 deletions
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) |