summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
authorliangke <lokyse@163.com>2017-08-25 10:32:55 +0800
committerliangke <lokyse@163.com>2017-09-11 15:37:31 +0800
commit146a18adf027664603444db6a2d9db6003f19c38 (patch)
treeb07032d33bee91d231699006450265862c2c106d /vio
parentcf96d79adc2f16cbd85616165daab5ef93b4e567 (diff)
Fix for VIO issue
1 Add checking response status code 2 Modify code style for passing pep8 checking Change-Id: I266f3cfb0173189510715db05b28540c4da98ba3 Issue-Id: MULTICLOUD-55 Signed-off-by: liangke <lokyse@163.com>
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/swagger/views/proxyplugin/identity/views.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/vio/vio/swagger/views/proxyplugin/identity/views.py b/vio/vio/swagger/views/proxyplugin/identity/views.py
index 0ce6312..35abc4e 100644
--- a/vio/vio/swagger/views/proxyplugin/identity/views.py
+++ b/vio/vio/swagger/views/proxyplugin/identity/views.py
@@ -93,9 +93,14 @@ class TokenView(BaseClient):
logger.info("vimid(%(vimid)s) get keystone url %(url)s ",
{"vimid": vimid, "url": keystoneURL})
try:
- res = requests.get(url=keystoneURL).json()
- res['version']['links'][0]['href'] = "http://" + \
- MSB_ADDRESS + "/multicloud-vio/v0/" + vimid + "/identity/v3"
+ res = requests.get(url=keystoneURL)
+ if res.status_code != status.HTTP_200_OK:
+ return Response(data={"error": res.content},
+ status=res.status_code)
+ res = res.json()
+ res['version']['links'][0]['href'] = \
+ "http://" + MSB_ADDRESS + "/multicloud-vio/v0/" \
+ + vimid + "/identity/v3"
except Exception as e:
logging.exception("error %s" % e)
@@ -145,6 +150,9 @@ class TokenView(BaseClient):
try:
res = requests.post(url=url, data=json.dumps(
create_req), headers=headers)
+ if res.status_code != status.HTTP_201_CREATED:
+ return Response(data={"error": res.content},
+ status=res.status_code)
tokenInfo = res.json()
resHeader = dict(res.headers)
except Exception as e: