diff options
author | 2017-09-20 13:05:30 +0800 | |
---|---|---|
committer | 2017-09-20 19:27:38 +0800 | |
commit | 0d081b4743d113be79edf5a1c0ce1078477619e3 (patch) | |
tree | e857fcfc77c7623454bcb3c18c8cbfffd2e9ae97 | |
parent | 344c1a5ba476987be054ead16bf88e99e71877b7 (diff) |
Fix multicloud vio bugs
Change-Id: I707846d4c6a8ba0adb4e5666b2c74e9dc382d9c9
Issue-Id: MULTICLOUD-98
Signed-off-by: liangke <lokyse@163.com>
-rwxr-xr-x | vio/docker/instance-config.sh | 2 | ||||
-rwxr-xr-x | vio/stop.sh | 2 | ||||
-rw-r--r-- | vio/vio/pub/msapi/extsys.py | 6 | ||||
-rw-r--r-- | vio/vio/swagger/views/proxyplugin/httpclient.py | 7 | ||||
-rw-r--r-- | vio/vio/swagger/views/proxyplugin/identity/views.py | 21 |
5 files changed, 29 insertions, 9 deletions
diff --git a/vio/docker/instance-config.sh b/vio/docker/instance-config.sh index 221cac9..cb05a9a 100755 --- a/vio/docker/instance-config.sh +++ b/vio/docker/instance-config.sh @@ -2,7 +2,7 @@ # Configure MSB IP address MSB_IP=`echo $MSB_ADDR | cut -d: -f 1` -MSB_PORT=`echo $MSB_ADDR | cut -d: -f 2` +MSB_PORT=`echo $MSB_PORT | cut -d: -f 2` sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" vio/vio/pub/config/config.py sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" vio/vio/pub/config/config.py sed -i "s|DB_NAME.*|DB_NAME = 'inventory'|" vio/vio/pub/config/config.py diff --git a/vio/stop.sh b/vio/stop.sh index 0196606..1d35d39 100755 --- a/vio/stop.sh +++ b/vio/stop.sh @@ -11,4 +11,4 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -ps auxww | grep 'manage.py runserver 127.0.0.1:9004' | awk '{print $2}' | xargs kill -9 +ps auxww | grep 'manage.py runserver 0.0.0.0:9004' | awk '{print $2}' | xargs kill -9 diff --git a/vio/vio/pub/msapi/extsys.py b/vio/vio/pub/msapi/extsys.py index b3ed044..c3d87d1 100644 --- a/vio/vio/pub/msapi/extsys.py +++ b/vio/vio/pub/msapi/extsys.py @@ -33,7 +33,7 @@ def get_vim_by_id(vim_id): ret['vimId'] = vim_id ret['name'] = vim_id ret['userName'] = ret['esr-system-info-list'][ - 'esr-system-info'][0]['username'] + 'esr-system-info'][0]['user-name'] ret['password'] = ret['esr-system-info-list'][ 'esr-system-info'][0]['password'] ret['tenant'] = ret['esr-system-info-list'][ @@ -43,7 +43,7 @@ def get_vim_by_id(vim_id): ret['domain'] = ret['esr-system-info-list'][ 'esr-system-info'][0]['cloud-domain'] ret['cacert'] = ret['esr-system-info-list'][ - 'esr-system-info'][0]['ssl-cacert'] + 'esr-system-info'][0].get('ssl-cacert', "") ret['insecure'] = ret['esr-system-info-list'][ - 'esr-system-info'][0]['ssl-insecure'] + 'esr-system-info'][0].get('ssl-insecure', False) return ret diff --git a/vio/vio/swagger/views/proxyplugin/httpclient.py b/vio/vio/swagger/views/proxyplugin/httpclient.py index f1cfbb1..bf1bc17 100644 --- a/vio/vio/swagger/views/proxyplugin/httpclient.py +++ b/vio/vio/swagger/views/proxyplugin/httpclient.py @@ -69,14 +69,15 @@ class BaseClient(APIView): def buildRequest(self, request, vimid, tenantid="", tail=None): + headers = {} preUrl = catalog.getEndpointBy( vimid, serverType=self.serverType, interface="public") token = request.META.get('HTTP_X_AUTH_TOKEN', "") tail = "/" + tail if tail else "" tenantid = "/" + tenantid if tenantid else "" endPointURL = preUrl + tenantid + tail - - headers = {"X-Auth-Token": token} + headers["X-Auth-Token"] = token + headers["X-Subject-Token"] = token headers['Content-Type'] = request.META.get( "CONTENT_TYPE", "application/json") try: @@ -84,7 +85,7 @@ class BaseClient(APIView): except Exception: json_req = "" - return (endPointURL, headers, json_req) + return endPointURL, headers, json_req def _request(self, url, method, redirect=20, connect_retries=0, connect_retry_delay=0.5, **kwargs): diff --git a/vio/vio/swagger/views/proxyplugin/identity/views.py b/vio/vio/swagger/views/proxyplugin/identity/views.py index cee11e7..56ac864 100644 --- a/vio/vio/swagger/views/proxyplugin/identity/views.py +++ b/vio/vio/swagger/views/proxyplugin/identity/views.py @@ -46,7 +46,26 @@ class IdentityServer(BaseClient): if query != "": query = query[:-1] url += "/?" + query - return self._request(url, method="GET", headers=headers) + + try: + res = self._request(url, method="GET", headers=headers) + if res.status_code != status.HTTP_200_OK: + return Response(data={"error": res.content}, + status=res.status_code) + res = res.data + # replace keystone auth url with multicloud + # identity url + if other is None: + res['version']['links'][0]['href'] = \ + "http://" + MSB_ADDRESS + "/multicloud-vio/v0/" \ + + vimid + "/identity" + + except Exception as e: + logging.exception("error %s" % e) + return Response(data={"error": str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + return Response(data=res, status=status.HTTP_200_OK) def patch(self, request, vimid, other): |