summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--newton/newton/proxy/urls.py2
-rw-r--r--newton/newton/proxy/views/dnsaasdelegate.py8
-rw-r--r--newton/newton/proxy/views/identityV3.py26
-rw-r--r--newton/newton/proxy/views/proxy_utils.py19
-rw-r--r--newton/newton/proxy/views/services.py31
-rw-r--r--newton/newton/registration/views/registration.py2
-rw-r--r--newton/newton/requests/views/util.py6
-rw-r--r--ocata/ocata/proxy/urls.py2
-rw-r--r--windriver/titanium_cloud/proxy/urls.py2
9 files changed, 82 insertions, 16 deletions
diff --git a/newton/newton/proxy/urls.py b/newton/newton/proxy/urls.py
index 0e0ca52a..3a4be2f4 100644
--- a/newton/newton/proxy/urls.py
+++ b/newton/newton/proxy/urls.py
@@ -24,6 +24,8 @@ urlpatterns = [
# identityV2.Tokens.as_view()),
url(r'^identity/v3/auth/tokens$',
identityV3.Tokens.as_view()),
+ url(r'^identity/v3/?$',
+ identityV3.Tokens.as_view()),
url(r'^identity/v2.0/?$',
identityV3.TokensV2.as_view()),
url(r'^identity/v2.0/tokens/?$',
diff --git a/newton/newton/proxy/views/dnsaasdelegate.py b/newton/newton/proxy/views/dnsaasdelegate.py
index bce24dff..0d2c97e1 100644
--- a/newton/newton/proxy/views/dnsaasdelegate.py
+++ b/newton/newton/proxy/views/dnsaasdelegate.py
@@ -62,6 +62,7 @@ class DnsaasDelegate(Services):
status=status.HTTP_404_NOT_FOUND)
tenant_name = auth_state['body']['token']['project']['name']
+ #tenant_id = auth_state['body']['token']['project']['id']
#find out the delegated DNSaaS provider
viminfo = VimDriverUtils.get_vim_info(vim_id)
@@ -135,9 +136,12 @@ class DnsaasDelegate(Services):
content = resp.json() if resp.content else None
self._logger.debug("service " + action + " response: %s, %s" % (resp.status_code, content))
- if (action != "delete"):
+ if (action == "delete"):
+ return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
+ else:
+ #content = ProxyUtils.update_dnsaas_project_id(content, tenant_id)
return Response(headers={'X-Subject-Token': tmp_auth_token}, data=content, status=resp.status_code)
- return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
+
except VimDriverNewtonException as e:
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
diff --git a/newton/newton/proxy/views/identityV3.py b/newton/newton/proxy/views/identityV3.py
index 7395fac8..d12e24ce 100644
--- a/newton/newton/proxy/views/identityV3.py
+++ b/newton/newton/proxy/views/identityV3.py
@@ -33,6 +33,22 @@ logger = logging.getLogger(__name__)
DEBUG=True
+v3_version_detail = {
+ "version": {
+ "status": "stable",
+ "updated": "2014-04-17T00:00:00Z",
+ "media-types": [
+ {
+ "base": "application/json",
+ "type": "application/vnd.openstack.identity-v3+json"
+ }
+ ],
+ "id": "v3",
+ "links": [
+ ]
+ }
+}
+
class Tokens(APIView):
service = {'service_type': 'identity',
'interface': 'public'}
@@ -41,6 +57,11 @@ class Tokens(APIView):
self.proxy_prefix = config.MULTICLOUD_PREFIX
self._logger = logger
+ def get(self, request, vimid=""):
+ self._logger.debug("identityV3--get::META> %s" % request.META)
+
+ return Response(data=v3_version_detail, status=status.HTTP_200_OK)
+
def post(self, request, vimid=""):
self._logger.debug("identityV3--post::META> %s" % request.META)
self._logger.debug("identityV3--post::data> %s" % request.data)
@@ -55,6 +76,7 @@ class Tokens(APIView):
#backward support for keystone v2.0 API
if not tenant_name and request.data.get("auth"):
tenant_name = request.data["auth"].get("tenantName")
+ tenant_id = request.data["auth"].get("tenantId")
#keystone v3 API
if not tenant_name and request.data.get("auth") \
@@ -104,7 +126,7 @@ class Tokens(APIView):
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-version_detail = {
+v2_version_detail = {
"version": {
"status": "stable",
"updated": "2014-04-17T00:00:00Z",
@@ -132,7 +154,7 @@ class TokensV2(Tokens):
def get(self, request, vimid=""):
self._logger.debug("TokensV2--get::META> %s" % request.META)
- return Response(data=version_detail, status=status.HTTP_200_OK)
+ return Response(data=v2_version_detail, status=status.HTTP_200_OK)
def post(self, request, vimid=""):
self._logger.debug("TokensV2--post::META> %s" % request.META)
diff --git a/newton/newton/proxy/views/proxy_utils.py b/newton/newton/proxy/views/proxy_utils.py
index 68182d4a..150cb217 100644
--- a/newton/newton/proxy/views/proxy_utils.py
+++ b/newton/newton/proxy/views/proxy_utils.py
@@ -174,3 +174,22 @@ class ProxyUtils(object):
logger.error(traceback.format_exc())
return catalog
+
+# @staticmethod
+# def update_dnsaas_project_id(content, new_project_id):
+# '''
+# update project id in DNSaaS delegate content
+# '''
+# try:
+# if content:
+# # filter the resp content and replace all endpoint prefix
+# tmp_content = json.dumps(content)
+# tmp_pattern = re.compile(r'(^.*)"project_id"\s*:\s*"' + r'[\w-]+'+r'"(.*$)')
+# part1 = tmp_pattern.sub(r'\1', tmp_content)
+# part2 = tmp_pattern.sub(r'"project_id":"'+new_project_id +r'"\2', tmp_content)
+# #logger.debug("jsonstr:%s,part1:%s,part2:%s"%(tmp_content,part1,part2))
+# content = json.loads(part1+part2)
+# return content
+# except Exception as e:
+# logger.error(traceback.format_exc())
+# return content
diff --git a/newton/newton/proxy/views/services.py b/newton/newton/proxy/views/services.py
index d86b0e8c..19fec9ca 100644
--- a/newton/newton/proxy/views/services.py
+++ b/newton/newton/proxy/views/services.py
@@ -35,6 +35,7 @@ DEBUG=True
class HasValidToken(BasePermission):
def has_permission(self, request, view):
+ logger.debug("HasValidToken--has_permission::META> %s" % request.META)
token = request.META.get('HTTP_X_AUTH_TOKEN', None)
if token:
state, metadata = VimDriverUtils.get_token_cache(token)
@@ -85,6 +86,12 @@ class Services(APIView):
def _do_action(self, action, request, vim_id, servicetype, requri):
tmp_auth_token = self._get_token(request)
try:
+ #special handling of compute/v2 request from APPC, temp solution for A release
+ if servicetype == 'compute':
+ tmp_pattern = re.compile(r'^v2/(.+)')
+ requri = tmp_pattern.sub(r'v2.1/' + r'\1', requri)
+
+
vim = VimDriverUtils.get_vim_info(vim_id)
# fetch the auth_state out of cache
auth_state, metadata_catalog = VimDriverUtils.get_token_cache(tmp_auth_token)
@@ -130,10 +137,16 @@ class Services(APIView):
content = resp.json() if resp.content else None
self._logger.debug("service " + action + " response: %s, %s" % (resp.status_code, content))
- if (action != "delete"):
+ if (action == "delete"):
+ return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
+ else:
content = ProxyUtils.update_prefix(metadata_catalog, content)
+ if (action == "get"):
+ if requri == '/v3/auth/catalog' and content and content.get("catalog"):
+ content['catalog'] = ProxyUtils.update_catalog_dnsaas(
+ vim_id, content['catalog'], self.proxy_prefix, vim)
return Response(headers={'X-Subject-Token': tmp_auth_token}, data=content, status=resp.status_code)
- return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code)
+
except VimDriverNewtonException as e:
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
@@ -145,7 +158,7 @@ class Services(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def head(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--head::META> %s" % request.META)
+ #self._logger.debug("Services--head::META> %s" % request.META)
self._logger.debug("Services--head::data> %s" % request.data)
self._logger.debug("Services--head::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
@@ -184,14 +197,14 @@ class Services(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--get::META> %s" % request.META)
+ #self._logger.debug("Services--get::META> %s" % request.META)
self._logger.debug("Services--get::data> %s" % request.data)
self._logger.debug("Services--get::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
return self._do_action("get", request, vimid, servicetype, requri)
def post(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--post::META> %s" % request.META)
+ #self._logger.debug("Services--post::META> %s" % request.META)
self._logger.debug("Services--post::data> %s" % request.data)
self._logger.debug("Services--post::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
@@ -199,21 +212,21 @@ class Services(APIView):
return self._do_action("post", request, vimid, servicetype, requri)
def put(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--put::META> %s" % request.META)
+ #self._logger.debug("Services--put::META> %s" % request.META)
self._logger.debug("Services--put::data> %s" % request.data)
self._logger.debug("Services--put::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
return self._do_action("put", request, vimid, servicetype, requri)
def patch(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--patch::META> %s" % request.META)
+ #self._logger.debug("Services--patch::META> %s" % request.META)
self._logger.debug("Services--patch::data> %s" % request.data)
self._logger.debug("Services--patch::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
return self._do_action("patch", request, vimid, servicetype, requri)
def delete(self, request, vimid="", servicetype="", requri=""):
- self._logger.debug("Services--delete::META> %s" % request.META)
+ #self._logger.debug("Services--delete::META> %s" % request.META)
self._logger.debug("Services--delete::data> %s" % request.data)
self._logger.debug("Services--delete::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
@@ -229,7 +242,7 @@ class GetTenants(Services):
self._logger = logger
def get(self, request, vimid="", servicetype="identity", requri='projects'):
- self._logger.debug("GetTenants--get::META> %s" % request.META)
+ #self._logger.debug("GetTenants--get::META> %s" % request.META)
self._logger.debug("GetTenants--get::data> %s" % request.data)
self._logger.debug("GetTenants--get::vimid, servicetype, requri> %s,%s,%s"
% (vimid, servicetype, requri))
diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py
index 0a9f7f8e..5a1d2e9d 100644
--- a/newton/newton/registration/views/registration.py
+++ b/newton/newton/registration/views/registration.py
@@ -600,7 +600,7 @@ class Registry(APIView):
if retcode == 0 and content:
viminfo = json.JSONDecoder().decode(content)
# cloud_epa_caps["resource-version"] = content["resource-version"]
- viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v3" % vimid
+ viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid
retcode, content, status_code = \
restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
diff --git a/newton/newton/requests/views/util.py b/newton/newton/requests/views/util.py
index 59eed5ab..ba383475 100644
--- a/newton/newton/requests/views/util.py
+++ b/newton/newton/requests/views/util.py
@@ -68,7 +68,8 @@ class VimDriverUtils(object):
password=vim["password"],
user_domain_name=vim["domain"],
project_id=tenantid)
- elif '/identity' in vim["url"]:
+ #elif '/identity' in vim["url"]:
+ else:
auth = keystone_v3.Password(auth_url=vim["url"]+"/v3",
username=vim["userName"],
password=vim["password"],
@@ -87,7 +88,8 @@ class VimDriverUtils(object):
project_name=tenant_name,
user_domain_name=vim["domain"],
project_domain_name=vim["domain"])
- elif '/identity' in vim["url"]:
+ #elif '/identity' in vim["url"]:
+ else:
auth = keystone_v3.Password(auth_url=vim["url"]+"/v3",
username=vim["userName"],
password=vim["password"],
diff --git a/ocata/ocata/proxy/urls.py b/ocata/ocata/proxy/urls.py
index 34b84728..ad0bb2cc 100644
--- a/ocata/ocata/proxy/urls.py
+++ b/ocata/ocata/proxy/urls.py
@@ -24,6 +24,8 @@ urlpatterns = [
# identityV2.Tokens.as_view()),
url(r'^identity/v3/auth/tokens/?$',
identityV3.Tokens.as_view()),
+ url(r'^identity/v3/?$',
+ identityV3.Tokens.as_view()),
url(r'^identity/v2.0/?',
identityV3.TokensV2.as_view()),
url(r'^identity/v2.0/tokens/?$',
diff --git a/windriver/titanium_cloud/proxy/urls.py b/windriver/titanium_cloud/proxy/urls.py
index eaa5600f..dd353937 100644
--- a/windriver/titanium_cloud/proxy/urls.py
+++ b/windriver/titanium_cloud/proxy/urls.py
@@ -24,6 +24,8 @@ urlpatterns = [
# identityV2.Tokens.as_view()),
url(r'^identity/v3/auth/tokens/?$',
identityV3.Tokens.as_view()),
+ url(r'^identity/v3/?$',
+ identityV3.Tokens.as_view()),
url(r'^identity/v2.0/?$',
identityV3.TokensV2.as_view()),
url(r'^identity/v2.0/tokens/?$',