summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
Diffstat (limited to 'newton')
-rw-r--r--newton/newton/resource/views/capacity.py15
-rw-r--r--newton/newton/resource/views/events.py11
2 files changed, 16 insertions, 10 deletions
diff --git a/newton/newton/resource/views/capacity.py b/newton/newton/resource/views/capacity.py
index 973bc980..c9d465e2 100644
--- a/newton/newton/resource/views/capacity.py
+++ b/newton/newton/resource/views/capacity.py
@@ -45,23 +45,26 @@ class CapacityCheck(APIView):
try :
resource_demand = request.data
+ tenant_name = None
+ vim = VimDriverUtils.get_vim_info(vimid)
+ sess = VimDriverUtils.get_session(vim, tenant_name)
+
#get token:
cloud_owner, regionid = extsys.decode_vim_id(vimid)
interface = 'public'
service = {'service_type': 'compute',
'interface': interface,
- 'region_id': regionid}
-
- tenant_name = None
- vim = VimDriverUtils.get_vim_info(vimid)
- sess = VimDriverUtils.get_session(vim, tenant_name)
+ 'region_id': vim['openstack_region_id']
+ if vim.get('openstack_region_id')
+ else vim['cloud_region_id']
+ }
#get limit for this tenant
req_resouce = "/limits"
resp = sess.get(req_resouce, endpoint_filter=service)
content = resp.json()
compute_limits = content['limits']['absolute']
-
+
#get total resource of this cloud region
try:
req_resouce = "/os-hypervisors/statistics"
diff --git a/newton/newton/resource/views/events.py b/newton/newton/resource/views/events.py
index bf7de344..1f06c785 100644
--- a/newton/newton/resource/views/events.py
+++ b/newton/newton/resource/views/events.py
@@ -44,16 +44,19 @@ class EventsCheck(APIView):
try :
resource_demand = request.data
+ tenant_name = None
+ vim = VimDriverUtils.get_vim_info(vimid)
+ sess = VimDriverUtils.get_session(vim, tenant_name)
+
# get token:
cloud_owner, regionid = extsys.decode_vim_id(vimid)
interface = 'public'
service = {'service_type': 'compute',
'interface': interface,
- 'region_id': regionid}
+ 'region_id': vim['openstack_region_id']
+ if vim.get('openstack_region_id')
+ else vim['cloud_region_id']}
- tenant_name = None
- vim = VimDriverUtils.get_vim_info(vimid)
- sess = VimDriverUtils.get_session(vim, tenant_name)
# get servers detail info
req_resouce = "/servers/detail"