summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaibin Huang <haibin.huang@intel.com>2019-07-11 08:22:04 +0000
committerBin Yang <bin.yang@windriver.com>2019-08-15 05:26:26 +0000
commit6068af3fd3513fb330bdf98f53b63bea909281e1 (patch)
tree775cca85e8c7fc63e9d1edd2b31ccbde80432a6c
parent0f9836f80ea187a1cef23f570f8505c54b19fdcf (diff)
upgrading python2 to python3 for openstack plugin
Issue-ID: MULTICLOUD-702 Change-Id: I9ac26b51a4be7d70d368dd039bfe1b7857114793 Signed-off-by: Haibin Huang <haibin.huang@intel.com>
-rwxr-xr-xpike/initialize.sh2
-rwxr-xr-xpike/mvn-phase-script.sh2
-rw-r--r--pike/pike/extensions/tests/test_extensions.py18
-rw-r--r--pike/pike/extensions/urls.py7
-rw-r--r--pike/pike/extensions/urls_v1.py (renamed from pike/pike/extensions/urlsV1.py)7
-rw-r--r--pike/pike/extensions/views/extensions.py10
-rw-r--r--pike/pike/middleware.py52
-rw-r--r--pike/pike/proxy/tests/test_identity_proxy.py735
-rw-r--r--pike/pike/proxy/tests/test_proxy.py (renamed from pike/pike/proxy/tests/test_service_proxy.py)387
-rw-r--r--pike/pike/proxy/urls.py14
-rw-r--r--pike/pike/proxy/urls_v1.py (renamed from pike/pike/proxy/urlsV1.py)14
-rw-r--r--pike/pike/proxy/views/identity_v3.py (renamed from pike/pike/proxy/views/identityV3.py)21
-rw-r--r--pike/pike/proxy/views/services.py44
-rw-r--r--pike/pike/registration/tests/test_registration.py98
-rw-r--r--pike/pike/registration/views/registration.py9
-rw-r--r--pike/pike/requests/urls.py7
-rw-r--r--pike/pike/requests/urls_v1.py (renamed from pike/pike/requests/urlsV1.py)7
-rw-r--r--pike/pike/requests/views/__init__.py13
-rw-r--r--pike/pike/resource/tests/test_capacity.py46
-rw-r--r--pike/pike/resource/tests/tests_infra_workload.py28
-rw-r--r--pike/pike/samples/tests.py7
-rw-r--r--pike/pike/samples/urls.py8
-rw-r--r--pike/pike/samples/views.py9
-rw-r--r--pike/pike/swagger/tests.py3
-rw-r--r--pike/pike/swagger/urls.py7
-rw-r--r--pike/pike/swagger/views.py21
-rw-r--r--pike/pike/urls.py42
-rw-r--r--pike/pike/wsgi.py5
-rw-r--r--pike/requirements.txt8
-rw-r--r--pike/tox.ini9
30 files changed, 655 insertions, 985 deletions
diff --git a/pike/initialize.sh b/pike/initialize.sh
index 1d64bfca..6ce7d40e 100755
--- a/pike/initialize.sh
+++ b/pike/initialize.sh
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-pip install -r requirements.txt
+pip3 install -r requirements.txt
diff --git a/pike/mvn-phase-script.sh b/pike/mvn-phase-script.sh
index ad1d6329..6cc1b2bb 100755
--- a/pike/mvn-phase-script.sh
+++ b/pike/mvn-phase-script.sh
@@ -53,7 +53,7 @@ run_tox_test()
DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev)
cd "${CURDIR}/${DIR}"
rm -rf ./venv-tox ./.tox
- virtualenv ./venv-tox
+ virtualenv ./venv-tox --python=python3
source ./venv-tox/bin/activate
pip install --upgrade pip
pip install --upgrade tox argparse
diff --git a/pike/pike/extensions/tests/test_extensions.py b/pike/pike/extensions/tests/test_extensions.py
index 0dd45959..a573165d 100644
--- a/pike/pike/extensions/tests/test_extensions.py
+++ b/pike/pike/extensions/tests/test_extensions.py
@@ -1,3 +1,6 @@
+'''
+test extensions
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,12 +15,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import unittest
from django.test import Client
from rest_framework import status
-import unittest
class TestExtensions(unittest.TestCase):
+ '''
+ classs test extensions
+ '''
def setUp(self):
self.client = Client()
@@ -30,9 +36,9 @@ class TestExtensions(unittest.TestCase):
"/api/multicloud-pike/v0/" + vimid + "/extensions/")
json_content = response.json()
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(4, len(json_content.keys()))
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(4, len(list(json_content.keys())))
- self.assertEquals(cloud_owner, json_content["cloud-owner"])
- self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
- self.assertEquals(vimid, json_content["vimid"])
+ self.assertEqual(cloud_owner, json_content["cloud-owner"])
+ self.assertEqual(cloud_region_id, json_content["cloud-region-id"])
+ self.assertEqual(vimid, json_content["vimid"])
diff --git a/pike/pike/extensions/urls.py b/pike/pike/extensions/urls.py
index b8e977c1..2b62e2c8 100644
--- a/pike/pike/extensions/urls.py
+++ b/pike/pike/extensions/urls.py
@@ -1,3 +1,6 @@
+'''
+Extension url
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,8 +20,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
from pike.extensions.views import extensions
-urlpatterns = [
+URLPATTERNS = [
url(r'^sions/?$', extensions.Extensions.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/extensions/urlsV1.py b/pike/pike/extensions/urls_v1.py
index eb31ca19..47a4eef5 100644
--- a/pike/pike/extensions/urlsV1.py
+++ b/pike/pike/extensions/urls_v1.py
@@ -1,3 +1,6 @@
+'''
+Extension v1 URl
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,8 +20,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
from pike.extensions.views import extensions
-urlpatterns = [
+URLPATTERNS = [
url(r'^sions/?$', extensions.APIv1Extensions.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/extensions/views/extensions.py b/pike/pike/extensions/views/extensions.py
index 767b0b97..76cf6750 100644
--- a/pike/pike/extensions/views/extensions.py
+++ b/pike/pike/extensions/views/extensions.py
@@ -14,11 +14,11 @@
import logging
-from common.msapi import extsys
from django.conf import settings
+from common.msapi import extsys
from newton_base.extensions import extensions as newton_extensions
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
# DEBUG=True
@@ -26,18 +26,18 @@ logger = logging.getLogger(__name__)
class Extensions(newton_extensions.Extensions):
def __init__(self):
- self._logger = logger
+ self._logger = LOGGER
self.proxy_prefix = settings.MULTICLOUD_PREFIX
class APIv1Extensions(Extensions):
def __init__(self):
- self._logger = logger
+ self._logger = LOGGER
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
def get(self, request, cloud_owner="", cloud_region_id=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Extensions, self).get(request, vimid)
diff --git a/pike/pike/middleware.py b/pike/pike/middleware.py
index 4f19da08..0697b81d 100644
--- a/pike/pike/middleware.py
+++ b/pike/pike/middleware.py
@@ -1,3 +1,6 @@
+'''
+This is middle module
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,45 +23,54 @@ FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST",
"HTTP_X_FORWARDED_SERVER"]
-class LogContextMiddleware(object):
+class LogContextMiddleware:
+ '''
+ log context middleware
+ '''
- # the last IP behind multiple proxies, if no exist proxies
- # get local host ip.
- def _getLastIp(self, request):
-
- ip = ""
+ def _get_last_ip(self, request):
+ '''
+ the last IP behind multiple proxies, if no exist proxies
+ get local host ip.
+ '''
+ local_ip = ""
try:
for field in FORWARDED_FOR_FIELDS:
if field in request.META:
if ',' in request.META[field]:
parts = request.META[field].split(',')
- ip = parts[-1].strip().split(":")[0]
+ local_ip = parts[-1].strip().split(":")[0]
else:
- ip = request.META[field].split(":")[0]
+ local_ip = request.META[field].split(":")[0]
- if ip == "":
- ip = request.META.get("HTTP_HOST").split(":")[0]
+ if local_ip == "":
+ local_ip = request.META.get("HTTP_HOST").split(":")[0]
except Exception:
pass
- return ip
+ return local_ip
def process_request(self, request):
+ '''
+ process request
+ '''
# fetch propageted Id from other component. if do not fetch id,
# generate one.
- ReqeustID = request.META.get("HTTP_X_TRANSACTIONID", None)
- if ReqeustID is None:
- ReqeustID = str(uuid.uuid3(uuid.NAMESPACE_URL, settings.MULTIVIM_VERSION))
- MDC.put("requestID", ReqeustID)
+ reqeust_id = request.META.get("HTTP_X_TRANSACTIONID", None)
+ if reqeust_id is None:
+ reqeust_id = str(uuid.uuid3(uuid.NAMESPACE_URL, settings.MULTIVIM_VERSION))
+ MDC.put("requestID", reqeust_id)
# generate the reqeust id
- InvocationID = str(uuid.uuid4())
- MDC.put("invocationID", InvocationID)
+ invocation_id = str(uuid.uuid4())
+ MDC.put("invocationID", invocation_id)
MDC.put("serviceName", settings.MULTIVIM_VERSION)
- MDC.put("serviceIP", self._getLastIp(request))
+ MDC.put("serviceIP", self._get_last_ip(request))
return None
- def process_response(self, request, response):
-
+ def process_response(self, response):
+ '''
+ process response
+ '''
MDC.clear()
return response
diff --git a/pike/pike/proxy/tests/test_identity_proxy.py b/pike/pike/proxy/tests/test_identity_proxy.py
deleted file mode 100644
index b4087150..00000000
--- a/pike/pike/proxy/tests/test_identity_proxy.py
+++ /dev/null
@@ -1,735 +0,0 @@
-# Copyright (c) 2018 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-import unittest
-
-from django.test import Client
-from rest_framework import status
-
-from newton_base.util import VimDriverUtils
-from newton_base.tests import mock_info
-
-mock_viminfo = {
- "createTime": "2017-04-01 02:22:27",
- "domain": "Default",
- "name": "TiS_R4",
- "password": "admin",
- "tenant": "admin",
- "type": "openstack",
- "url": "http://128.224.180.14:5000/v3",
- "userName": "admin",
- "vendor": "WindRiver",
- "version": "pike",
- "vimId": "windriver-hudson-dc_RegionOne",
- 'cloud_owner': 'windriver-hudson-dc',
- 'cloud_region_id': 'RegionOne',
- 'cloud_extra_info': '',
- 'insecure': 'True',
-}
-
-mock_token_id = "1a62b3971d774404a504c5d9a3e506e3"
-
-mock_catalog_response = {
- "catalog": [
- {
- "id": "99aefcc82a9246f98f8c281e61ffc754",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:9696",
- "id": "39583c1508ad4b71b380570a745ee10a",
- "interface": "public",
- "region_id": "RegionOne"
- },
- {
- "url": "http://192.168.204.2:9696",
- "region": "RegionOne",
- "id": "37e8d07ba24e4b8f93490c9daaba06e2",
- "interface": "internal",
- "region_id": "RegionOne"
- },
- {
- "interface": "admin",
- "id": "7eee4ca98d444b1abb00a50d4b89373f",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:9696"
- }
- ],
- "name": "neutron",
- "type": "network"
- },
- {
- "endpoints": [
- {
- "interface": "public",
- "id": "10496738fa374295a4a88a63b81a1589",
- "region_id": "RegionOne",
- "url": "http://128.224.180.14:8777",
- "region": "RegionOne"
- },
- {
- "id": "02dcb8c0bd464c4489fa0a0c9f28571f",
- "region_id": "RegionOne",
- "interface": "internal",
- "url": "http://192.168.204.2:8777",
- "region": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "8a73b0d3743b4e78b87614690f6e97fe",
- "interface": "admin",
- "url": "http://192.168.204.2:8777",
- "region": "RegionOne"
- }
- ],
- "id": "d131054da83f4c93833799747a0f4709",
- "name": "ceilometer",
- "type": "metering"
- },
- {
- "type": "volumev2",
- "name": "cinderv2",
- "endpoints": [
- {
- "id": "35a67ad36f0447d19c9662babf7cf609",
- "interface": "public",
- "region_id": "RegionOne",
- "url": "http://128.224.180.14:8776/v2/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v2/fcca3cc49d5e42caae15459e27103efc",
- "id": "c6ea42052268420fa2c8d351ee68c922",
- "interface": "internal",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "91cb24853dc3450d847b0c286a2e44ea",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v2/fcca3cc49d5e42caae15459e27103efc"
- }
- ],
- "id": "40440057102440739c30be10a66bc5d1"
- },
- {
- "name": "heat",
- "type": "orchestration",
- "id": "35300cce88db4bd4bb5a72ffe3b88b00",
- "endpoints": [
- {
- "id": "58999d7b4a94439089ecfb2aca2d7f6c",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:8004/v1/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "url": "http://192.168.204.2:8004/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "interface": "internal",
- "id": "1e0ee1a2aef84802b921d422372a567e",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8004/v1/fcca3cc49d5e42caae15459e27103efc",
- "id": "17661bf4859741b8a43a461dedad1871",
- "region_id": "RegionOne",
- "interface": "admin"
- }
- ]
- },
- {
- "id": "08dc6912aea64c01925012c8a6df250a",
- "endpoints": [
- {
- "id": "02792c4eed77486083f9b2e52d7b94b0",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:5000/v3"
- },
- {
- "id": "b6d5cad394b94309ae40d8de88059c5f",
- "region_id": "RegionOne",
- "interface": "internal",
- "url": "http://192.168.204.2:5000/v3",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:35357/v3",
- "region_id": "RegionOne",
- "id": "1f18e2b7c6a34493b86853b65917888e",
- "interface": "admin"
- }
- ],
- "type": "identity",
- "name": "keystone"
- },
- {
- "name": "vim",
- "type": "nfv",
- "endpoints": [
- {
- "url": "http://128.224.180.14:4545",
- "region": "RegionOne",
- "id": "b33e317345e4480ab0786e4960995ec9",
- "interface": "public",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:4545",
- "interface": "internal",
- "id": "03c85828d5bf432ab04831aa65ac9c52",
- "region_id": "RegionOne"
- },
- {
- "id": "067983abb061476cb53a9e23a740d98f",
- "region_id": "RegionOne",
- "interface": "admin",
- "url": "http://192.168.204.2:4545",
- "region": "RegionOne"
- }
- ],
- "id": "01636c856fc84988b38b9117eb4a8021"
- },
- {
- "name": "aodh",
- "type": "alarming",
- "id": "eb269151d0e44744a5b5449657bdc61c",
- "endpoints": [
- {
- "id": "5bfc6c056e0244c493642eb82f6aaa11",
- "region_id": "RegionOne",
- "interface": "public",
- "url": "http://128.224.180.14:8042",
- "region": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8042",
- "region_id": "RegionOne",
- "id": "ad69c7f76dce4089a195b9221ddbfb44",
- "interface": "internal"
- },
- {
- "interface": "admin",
- "id": "3e8fcdfa7bcb40b0ae33c282adfcc9ff",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8042"
- }
- ]
- },
- {
- "name": "sysinv",
- "type": "platform",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:6385/v1",
- "interface": "public",
- "id": "ba4ba8104590421b84672306c7e0e1f1",
- "region_id": "RegionOne"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:6385/v1",
- "interface": "internal",
- "id": "a1cba34b163f496ab1acd6e9b51e39a2",
- "region_id": "RegionOne"
- },
- {
- "url": "http://192.168.204.2:6385/v1",
- "region": "RegionOne",
- "id": "7c171210a2c841a6a52a5713e316d6fc",
- "interface": "admin",
- "region_id": "RegionOne"
- }
- ],
- "id": "256bbad671f946fea543e6bd71f98875"
- },
- {
- "id": "e84665dcce814c05b4c5084964547534",
- "endpoints": [
- {
- "url": "http://128.224.180.14:8000/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "region_id": "RegionOne",
- "id": "b2ed1a23dc6944bea129c20861e0286a",
- "interface": "public"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8000/v1/fcca3cc49d5e42caae15459e27103efc",
- "interface": "internal",
- "id": "c4df7c6bc15646848eff35caf6ffea8e",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "61b3dabb761443a89ab549f437c05ab0",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8000/v1/fcca3cc49d5e42caae15459e27103efc"
- }
- ],
- "name": "heat-cfn",
- "type": "cloudformation"
- },
- {
- "id": "823024424a014981a3721229491c0b1a",
- "endpoints": [
- {
- "region": "RegionOne",
- "url": "http://128.224.180.14:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "region_id": "RegionOne",
- "id": "4a52e4e54ff440789f9a797919c4a0f2",
- "interface": "public"
- },
- {
- "url": "http://192.168.204.2:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "id": "d4f9a84476524a39844f0fce63f1022e",
- "region_id": "RegionOne",
- "interface": "internal"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v1/fcca3cc49d5e42caae15459e27103efc",
- "interface": "admin",
- "id": "81bf3810a8cc4697b68c6e93b5b8fe1f",
- "region_id": "RegionOne"
- }
- ],
- "type": "volume",
- "name": "cinder"
- },
- {
- "name": "glance",
- "type": "image",
- "endpoints": [
- {
- "id": "bd930aba961946cfb1401bada56d55e3",
- "region_id": "RegionOne",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:9292"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:9292",
- "id": "c11da585f0b141b99d1e18bb9a607beb",
- "region_id": "RegionOne",
- "interface": "internal"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:9292",
- "id": "31b26c625a6a4fc7910dc5935155996e",
- "interface": "admin",
- "region_id": "RegionOne"
- }
- ],
- "id": "3b78cf039bc54d1bbb99ab3a4be15ef1"
- },
- {
- "id": "b8701374bf254de1beee8a2c9ecc6b33",
- "endpoints": [
- {
- "region_id": "RegionOne",
- "id": "f7407f330c8b4577b1d377d3fab9c2f8",
- "interface": "public",
- "region": "RegionOne",
- "url": "http://128.224.180.14:15491"
- },
- {
- "url": "http://192.168.204.2:5491",
- "region": "RegionOne",
- "interface": "internal",
- "id": "0b37ce31a32f4b6fa5e1aa0d6c20680f",
- "region_id": "RegionOne"
- },
- {
- "region_id": "RegionOne",
- "id": "7b87ea72adf245e1991e9e0df29b7ea9",
- "interface": "admin",
- "region": "RegionOne",
- "url": "http://192.168.204.2:5491"
- }
- ],
- "type": "patching",
- "name": "patching"
- },
- {
- "id": "0ec0923a58f04ffeb6fced3bbc5c0947",
- "endpoints": [
- {
- "url": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne",
- "id": "13168b12da17451fb39630de67db168f",
- "region_id": "RegionOne",
- "interface": "public"
- },
- {
- "id": "22dd6a44209f42d986b82e3aa6535f82",
- "interface": "internal",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://192.168.204.2:8774/v2.1/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8774/v2.1/fcca3cc49d5e42caae15459e27103efc",
- "id": "552a991ae501492f841c1b6e2ff38fc5",
- "region_id": "RegionOne",
- "interface": "admin"
- }
- ],
- "type": "compute",
- "name": "nova"
- },
- {
- "id": "50b219650f1049b097b3f14e8c70cdf8",
- "endpoints": [
- {
- "interface": "public",
- "id": "5a4276cd6e4d43e883cf8640d4e13f7d",
- "region_id": "RegionOne",
- "region": "RegionOne",
- "url": "http://128.224.180.14:8776/v3/fcca3cc49d5e42caae15459e27103efc"
- },
- {
- "region": "RegionOne",
- "url": "http://192.168.204.2:8776/v3/fcca3cc49d5e42caae15459e27103efc",
- "region_id": "RegionOne",
- "id": "c796df3ca5a84fc18db5b43a55283953",
- "interface": "internal"
- },
- {
- "region_id": "RegionOne",
- "id": "cf55c2b34d0049ba835a2e48b9ad0e2e",
- "interface": "admin",
- "url": "http://192.168.204.2:8776/v3/fcca3cc49d5e42caae15459e27103efc",
- "region": "RegionOne"
- }
- ],
- "type": "volumev3",
- "name": "cinderv3"
- }
- ],
-}
-
-mock_auth_state = {
- "body": {
- "token": {
- "is_domain": "false",
- "expires_at": "2017-08-27T14:19:15.000000Z",
- "issued_at": "2017-08-27T13:19:15.000000Z",
- "roles": [
- {
- "id": "9fe2ff9ee4384b1894a90878d3e92bab",
- "name": "_member_"
- },
- {
- "id": "b86a7e02935844b899d3d326f83c1b1f",
- "name": "admin"
- },
- {
- "name": "heat_stack_owner",
- "id": "7de502236e954c8282de32e773fc052e"
- }
- ],
- "methods": [
- "password"
- ],
- "catalog": mock_catalog_response['catalog'],
- "project": {
- "name": "admin",
- "id": "fcca3cc49d5e42caae15459e27103efc",
- "domain": {
- "id": "default",
- "name": "Default"
- }
- },
- "user": {
- "name": "admin",
- "id": "9efb043c7629497a8028d7325ca1afb0",
- "domain": {
- "id": "default",
- "name": "Default"
- }
- },
- "audit_ids": [
- "_ZWT10DtSZKRXIvIcxun7w"
- ]
- }
- },
- "auth_token": mock_token_id
-}
-
-
-class TestIdentityService(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_auth_state')
- @mock.patch.object(VimDriverUtils, 'update_token_cache')
- def test_token(self, mock_update_token_cache, mock_get_auth_state, mock_get_session, mock_get_vim_info):
- '''
- test API: get token
- :param mock_update_token_cache:
- :param mock_get_auth_state:
- :param mock_get_session:
- :param mock_get_vim_info:
- :return:
- '''
-
- # mock VimDriverUtils APIs
- mock_session_specs = ["get"]
- mock_session_get_response = {'status': 200}
- mock_session = mock.Mock(name='mock_session', spec=mock_session_specs)
- mock_session.get.return_value = mock_session_get_response
-
- mock_get_vim_info.return_value = mock_viminfo
- mock_get_session.return_value = mock_session
- mock_get_auth_state.return_value = json.dumps(mock_auth_state)
- mock_update_token_cache.return_value = mock_token_id
-
- # simulate client to make the request
- data = {}
- response = self.client.post("/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens", data=data, format='json')
- self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code)
- context = response.json()
-
- self.assertTrue(response['X-Subject-Token'] == mock_token_id)
- self.assertTrue(context['token']['catalog'] is not None)
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_auth_state')
- @mock.patch.object(VimDriverUtils, 'update_token_cache')
- def test_tokensV2(self, mock_update_token_cache, mock_get_auth_state,
- mock_get_session, mock_get_vim_info):
- '''
- test API: get token
- :param mock_update_token_cache:
- :param mock_get_auth_state:
- :param mock_get_session:
- :param mock_get_vim_info:
- :return:
- '''
-
- # mock VimDriverUtils APIs
- mock_session_specs = ["get"]
- mock_session_get_response = {'status': 200}
- mock_session = mock.Mock(name='mock_session',
- spec=mock_session_specs)
- mock_session.get.return_value = mock_session_get_response
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
- mock_get_session.return_value = mock_session
- mock_get_auth_state.return_value = json.dumps(mock_auth_state)
- mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
-
- # simulate client to make the request
- data = {}
- response = self.client.post(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens",
- data=data, format='json')
- self.failUnlessEqual(status.HTTP_200_OK,
- response.status_code)
- context = response.json()
-
- self.assertIsNotNone(context['access']['token'])
- self.assertEqual(mock_info.MOCK_TOKEN_ID,
- context['access']['token']["id"])
- self.assertIsNotNone(context['access']['serviceCatalog'])
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_auth_state')
- @mock.patch.object(VimDriverUtils, 'update_token_cache')
- def test_token_with_tenantname(self, mock_update_token_cache, mock_get_auth_state,
- mock_get_session, mock_get_vim_info):
- '''
- test API: get token
- :param mock_update_token_cache:
- :param mock_get_auth_state:
- :param mock_get_session:
- :param mock_get_vim_info:
- :return:
- '''
-
- # mock VimDriverUtils APIs
- mock_session_specs = ["get"]
- mock_session_get_response = {'status': 200}
- mock_session = mock.Mock(name='mock_session',
- spec=mock_session_specs)
- mock_session.get.return_value = mock_session_get_response
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
- mock_get_session.return_value = mock_session
- mock_get_auth_state.return_value = json.dumps(mock_auth_state)
- mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
-
- # simulate client to make the request
- token_data = {
- "auth": {
- "identity": {
- "methods": ["password"],
- "password": {
- "user": {
- "name": "demo",
- "domain": {"name": "Default"},
- "password": "demo"
- }
- }
- },
- "scope": {
- "project": {
- "domain": {"name": "Default"},
- "name": "Integration"
- }
- }
- }
- }
-
- response = self.client.post(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens",
- data=json.dumps(token_data), content_type='application/json')
- self.failUnlessEqual(status.HTTP_201_CREATED,
- response.status_code)
- context = response.json()
-
- self.assertEqual(mock_info.MOCK_TOKEN_ID,
- response['X-Subject-Token'])
- self.assertIsNotNone(context['token']['catalog'])
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_auth_state')
- @mock.patch.object(VimDriverUtils, 'update_token_cache')
- def test_tokensV2_with_tenantname(self, mock_update_token_cache, mock_get_auth_state,
- mock_get_session, mock_get_vim_info):
- '''
- test API: get token
- :param mock_update_token_cache:
- :param mock_get_auth_state:
- :param mock_get_session:
- :param mock_get_vim_info:
- :return:
- '''
-
- # mock VimDriverUtils APIs
- mock_session_specs = ["get"]
- mock_session_get_response = {'status': 200}
- mock_session = mock.Mock(name='mock_session',
- spec=mock_session_specs)
- mock_session.get.return_value = mock_session_get_response
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
- mock_get_session.return_value = mock_session
- mock_get_auth_state.return_value = json.dumps(mock_auth_state)
- mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
-
- # simulate client to make the request
- token_data = {
- "auth": {
- "tenantName": "Integration",
- "passwordCredentials": {
- "username": "demo",
- "password": "demo"
- }
- }
- }
-
- response = self.client.post(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens",
- data=json.dumps(token_data), content_type='application/json')
- self.failUnlessEqual(status.HTTP_200_OK,
- response.status_code)
- context = response.json()
-
- self.assertIsNotNone(context['access']['token'])
- self.assertEqual(mock_info.MOCK_TOKEN_ID,
- context['access']['token']["id"])
- self.assertIsNotNone(context['access']['serviceCatalog'])
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- @mock.patch.object(VimDriverUtils, 'get_session')
- @mock.patch.object(VimDriverUtils, 'get_auth_state')
- @mock.patch.object(VimDriverUtils, 'update_token_cache')
- def test_token_with_projectid(self, mock_update_token_cache, mock_get_auth_state,
- mock_get_session, mock_get_vim_info):
- '''
- test API: get token
- :param mock_update_token_cache:
- :param mock_get_auth_state:
- :param mock_get_session:
- :param mock_get_vim_info:
- :return:
- '''
-
- # mock VimDriverUtils APIs
- mock_session_specs = ["get"]
- mock_session_get_response = {'status': 200}
- mock_session = mock.Mock(name='mock_session',
- spec=mock_session_specs)
- mock_session.get.return_value = mock_session_get_response
-
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
- mock_get_session.return_value = mock_session
- mock_get_auth_state.return_value = json.dumps(mock_auth_state)
- mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
-
- # simulate client to make the request
- token_data = {
- "auth": {
- "identity": {
- "methods": ["password"],
- "password": {
- "user": {
- "name": "demo",
- "password": "demo"
- }
- }
- },
- "scope": {
- "project": {"id": "dd327af0542e47d7853e0470fe9ad625"}
- }
- }
- }
-
- response = self.client.post(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens",
- data=json.dumps(token_data), content_type='application/json')
- self.failUnlessEqual(status.HTTP_201_CREATED,
- response.status_code)
- context = response.json()
-
- self.assertEqual(mock_info.MOCK_TOKEN_ID,
- response['X-Subject-Token'])
- self.assertIsNotNone(context['token']['catalog'])
diff --git a/pike/pike/proxy/tests/test_service_proxy.py b/pike/pike/proxy/tests/test_proxy.py
index f0d2d4a4..3bcae959 100644
--- a/pike/pike/proxy/tests/test_service_proxy.py
+++ b/pike/pike/proxy/tests/test_proxy.py
@@ -1,3 +1,6 @@
+'''
+Test proxy
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,16 +15,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import copy
import json
-from django.test import Client
-import mock
-from rest_framework import status
+import copy
import unittest
+import mock
+from django.test import Client
+from rest_framework import status
from newton_base.util import VimDriverUtils
+from newton_base.tests import mock_info
+
MOCK_VIM_INFO = {
"createTime": "2017-04-01 02:22:27",
@@ -34,7 +39,7 @@ MOCK_VIM_INFO = {
"userName": "admin",
"vendor": "WindRiver",
"version": "pike",
- "vimId": "windriver-hudson-dc_RegionOne",
+ "vimId": "pike_RegionOne",
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '',
@@ -490,72 +495,75 @@ MOCK_AUTH_STATE = {
MOCK_INTERNAL_METADATA_CATALOG = {
"identity": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/identity",
+ "proxy_prefix":
+ "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/identity",
"prefix": "http://128.224.180.14:5000",
"suffix": "v3"
},
"patching": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/patching",
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/patching",
"suffix": "",
"prefix": "http://128.224.180.14:15491"
},
"orchestration": {
"suffix": "v1/fcca3cc49d5e42caae15459e27103efc",
"prefix": "http://128.224.180.14:8004",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/orchestration"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/"
+ "orchestration"
},
"volume": {
"prefix": "http://128.224.180.14:8776",
"suffix": "v1/fcca3cc49d5e42caae15459e27103efc",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/volume"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/volume"
},
"metering": {
"suffix": "",
"prefix": "http://128.224.180.14:8777",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/metering"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/metering"
},
"volumev3": {
"prefix": "http://128.224.180.14:8776",
"suffix": "v3/fcca3cc49d5e42caae15459e27103efc",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/volumev3"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/volumev3"
},
"compute": {
"suffix": "v2.1/fcca3cc49d5e42caae15459e27103efc",
"prefix": "http://128.224.180.14:8774",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/compute"
},
"platform": {
"prefix": "http://128.224.180.14:6385",
"suffix": "v1",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/platform"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/platform"
},
"nfv": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/nfv",
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/nfv",
"prefix": "http://128.224.180.14:4545",
"suffix": ""
},
"volumev2": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/volumev2",
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/volumev2",
"suffix": "v2/fcca3cc49d5e42caae15459e27103efc",
"prefix": "http://128.224.180.14:8776"
},
"image": {
"suffix": "",
"prefix": "http://128.224.180.14:9292",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/image"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/image"
},
"network": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/network",
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/network",
"prefix": "http://128.224.180.14:9696",
"suffix": ""
},
"alarming": {
"suffix": "",
"prefix": "http://128.224.180.14:8042",
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/alarming"
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/alarming"
},
"cloudformation": {
- "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/cloudformation",
+ "proxy_prefix": "http://172.16.77.20:9003/api/multicloud-pike/v0/pike_RegionOne/"
+ "cloudformation",
"prefix": "http://128.224.180.14:8000",
"suffix": "v1/fcca3cc49d5e42caae15459e27103efc"
}
@@ -567,11 +575,13 @@ MOCK_GET_SERVERS_RESPONSE = {
{
"links": [
{
- "href": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc/servers/b2581b5c-7c56-4564-819d-fe7a2ce9c261",
+ "href": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc/"
+ "servers/b2581b5c-7c56-4564-819d-fe7a2ce9c261",
"rel": "self"
},
{
- "href": "http://128.224.180.14:8774/fcca3cc49d5e42caae15459e27103efc/servers/b2581b5c-7c56-4564-819d-fe7a2ce9c261",
+ "href": "http://128.224.180.14:8774/fcca3cc49d5e42caae15459e27103efc/"
+ "servers/b2581b5c-7c56-4564-819d-fe7a2ce9c261",
"rel": "bookmark"
}
],
@@ -584,11 +594,13 @@ MOCK_GET_SERVERS_RESPONSE = {
"links": [
{
"rel": "self",
- "href": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc/servers/ff7b51ca-a272-45f4-b54c-e40b8099e67d"
+ "href": "http://128.224.180.14:8774/v2.1/fcca3cc49d5e42caae15459e27103efc/"
+ "servers/ff7b51ca-a272-45f4-b54c-e40b8099e67d"
},
{
"rel": "bookmark",
- "href": "http://128.224.180.14:8774/fcca3cc49d5e42caae15459e27103efc/servers/ff7b51ca-a272-45f4-b54c-e40b8099e67d"
+ "href": "http://128.224.180.14:8774/fcca3cc49d5e42caae15459e27103efc/"
+ "servers/ff7b51ca-a272-45f4-b54c-e40b8099e67d"
}
]
}
@@ -610,7 +622,15 @@ MOCK_POST_SERVER_REQUEST = {
"personality": [
{
"path": "/etc/banner.txt",
- "contents": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
+ "contents": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp "
+ "dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k "
+ "IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs "
+ "c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g "
+ "QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo "
+ "ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv "
+ "dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy "
+ "c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 "
+ "b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
],
"security_groups": [
@@ -632,11 +652,13 @@ MOCK_POST_SERVER_RESPONSE = {
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"links": [
{
- "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
+ "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/"
+ "servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
- "href": "http://openstack.example.com/6f70656e737461636b20342065766572/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
+ "href": "http://openstack.example.com/6f70656e737461636b20342065766572/"
+ "servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
],
@@ -691,6 +713,256 @@ MOCK_PATCH_IMAGE_RESPONSE = {
}
+class TestIdentityService(unittest.TestCase):
+ def setUp(self):
+ self.client = Client()
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_token(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session', spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
+
+ mock_update_token_cache.return_value = MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ data = {}
+ response = self.client.post(
+ "/api/multicloud-pike/v0/pike_RegionOne/identity/v3/auth/tokens",
+ data=data, format='json')
+ self.assertEqual(status.HTTP_201_CREATED, response.status_code)
+ context = response.json()
+
+ self.assertTrue(response['X-Subject-Token'] == MOCK_TOKEN_ID)
+ self.assertTrue(context['token']['catalog'] is not None)
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_tokensV2(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ data = {}
+ response = self.client.post(
+ "/api/multicloud-pike/v0/pike_RegionOne/identity/v2.0/tokens",
+ data=data, format='json')
+ self.assertEqual(status.HTTP_200_OK,
+ response.status_code)
+ context = response.json()
+
+ self.assertIsNotNone(context['access']['token'])
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ context['access']['token']["id"])
+ self.assertIsNotNone(context['access']['serviceCatalog'])
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_token_with_tenantname(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ token_data = {
+ "auth": {
+ "identity": {
+ "methods": ["password"],
+ "password": {
+ "user": {
+ "name": "demo",
+ "domain": {"name": "Default"},
+ "password": "demo"
+ }
+ }
+ },
+ "scope": {
+ "project": {
+ "domain": {"name": "Default"},
+ "name": "Integration"
+ }
+ }
+ }
+ }
+
+ response = self.client.post(
+ "/api/multicloud-pike/v0/pike_RegionOne/identity/v3/auth/tokens",
+ data=json.dumps(token_data), content_type='application/json')
+ self.assertEqual(status.HTTP_201_CREATED,
+ response.status_code)
+ context = response.json()
+
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ response['X-Subject-Token'])
+ self.assertIsNotNone(context['token']['catalog'])
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_tokensV2_with_tenantname(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ token_data = {
+ "auth": {
+ "tenantName": "Integration",
+ "passwordCredentials": {
+ "username": "demo",
+ "password": "demo"
+ }
+ }
+ }
+
+ response = self.client.post(
+ "/api/multicloud-pike/v0/pike_RegionOne/identity/v2.0/tokens",
+ data=json.dumps(token_data), content_type='application/json')
+ self.assertEqual(status.HTTP_200_OK,
+ response.status_code)
+ context = response.json()
+
+ self.assertIsNotNone(context['access']['token'])
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ context['access']['token']["id"])
+ self.assertIsNotNone(context['access']['serviceCatalog'])
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_token_with_projectid(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ token_data = {
+ "auth": {
+ "identity": {
+ "methods": ["password"],
+ "password": {
+ "user": {
+ "name": "demo",
+ "password": "demo"
+ }
+ }
+ },
+ "scope": {
+ "project": {"id": "dd327af0542e47d7853e0470fe9ad625"}
+ }
+ }
+ }
+
+ response = self.client.post(
+ "/api/multicloud-pike/v0/pike_RegionOne/identity/v3/auth/tokens",
+ data=json.dumps(token_data), content_type='application/json')
+ self.assertEqual(status.HTTP_201_CREATED,
+ response.status_code)
+ context = response.json()
+
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ response['X-Subject-Token'])
+ self.assertIsNotNone(context['token']['catalog'])
+
+
class MockResponse(object):
status_code = 200
content = ''
@@ -720,22 +992,25 @@ class TestServiceProxy(unittest.TestCase):
mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE),
json.dumps(MOCK_INTERNAL_METADATA_CATALOG))
response = self.client.head(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers",
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers",
{}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
def test_unauthorized_access(self):
response = self.client.get(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers")
- self.assertEquals(status.HTTP_403_FORBIDDEN, response.status_code)
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers")
+ self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_expired_auth_token(self, mock_get_vim_info):
mock_get_vim_info.return_value = MOCK_VIM_INFO
- response = self.client.get("/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers",
+ response = self.client.get("/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers",
{}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_403_FORBIDDEN, response.status_code)
+ self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_token_cache')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -743,33 +1018,36 @@ class TestServiceProxy(unittest.TestCase):
mock_get_vim_info.return_value = MOCK_VIM_INFO
mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE), {})
servicetype = "compute"
- base_url = "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
+ base_url = "/api/multicloud-pike/v0/pike_RegionOne/"
server_url = "/v2.1/fcca3cc49d5e42caae15459e27103efc/servers"
url = (base_url + servicetype + server_url)
response = self.client.get(url, {}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
+ self.assertEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
metadata_catalog = copy.deepcopy(MOCK_INTERNAL_METADATA_CATALOG)
metadata_catalog[servicetype] = None
- mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE), json.dumps(metadata_catalog))
+ mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE),
+ json.dumps(metadata_catalog))
response = self.client.get(url, {}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
+ self.assertEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
metadata_catalog = copy.deepcopy(MOCK_INTERNAL_METADATA_CATALOG)
metadata_catalog[servicetype]['prefix'] = None
metadata_catalog[servicetype]['proxy_prefix'] = None
- mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE), json.dumps(metadata_catalog))
+ mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE),
+ json.dumps(metadata_catalog))
response = self.client.get(url, {}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
+ self.assertEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_auth_state')
@mock.patch.object(VimDriverUtils, 'update_token_cache')
@mock.patch.object(VimDriverUtils, 'get_token_cache')
- def test_crud_resources(self, mock_get_token_cache, mock_update_token_cache, mock_get_auth_state, mock_get_session, mock_get_vim_info):
+ def test_crud_resources(self, mock_get_token_cache, mock_update_token_cache,
+ mock_get_auth_state, mock_get_session, mock_get_vim_info):
'''
Test service proxy API: GET
@@ -812,42 +1090,47 @@ class TestServiceProxy(unittest.TestCase):
mock_get_session.return_value = mock_session
mock_get_auth_state.return_value = json.dumps(MOCK_AUTH_STATE)
mock_update_token_cache.return_value = MOCK_TOKEN_ID
- mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE), json.dumps(MOCK_INTERNAL_METADATA_CATALOG))
+ mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE),
+ json.dumps(MOCK_INTERNAL_METADATA_CATALOG))
# Create resource
response = self.client.post(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers",
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers",
MOCK_POST_SERVER_REQUEST, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
context = response.json()
- self.assertEquals(MOCK_TOKEN_ID, response['X-Subject-Token'])
+ self.assertEqual(MOCK_TOKEN_ID, response['X-Subject-Token'])
self.assertIsNotNone(context['server'])
# Retrieve resource
response = self.client.get(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers",
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers",
{}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
context = response.json()
- self.assertEquals(MOCK_TOKEN_ID, response['X-Subject-Token'])
+ self.assertEqual(MOCK_TOKEN_ID, response['X-Subject-Token'])
self.assertIsNotNone(context['servers'])
# Update resource
response = self.client.get(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers",
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers",
{}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
context = response.json()
- self.assertEquals(MOCK_TOKEN_ID, response['X-Subject-Token'])
+ self.assertEqual(MOCK_TOKEN_ID, response['X-Subject-Token'])
self.assertIsNotNone(context['servers'])
# simulate client to make the request
response = self.client.delete(
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers/324dfb7d-f4a9-419a-9a19-237df04b443b",
+ "/api/multicloud-pike/v0/pike_RegionOne/compute/v2.1/"
+ "fcca3cc49d5e42caae15459e27103efc/servers/324dfb7d-f4a9-419a-9a19-237df04b443b",
HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_204_NO_CONTENT, response.status_code)
- self.assertEquals(MOCK_TOKEN_ID, response['X-Subject-Token'])
+ self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)
+ self.assertEqual(MOCK_TOKEN_ID, response['X-Subject-Token'])
diff --git a/pike/pike/proxy/urls.py b/pike/pike/proxy/urls.py
index 3dafd528..b92b5354 100644
--- a/pike/pike/proxy/urls.py
+++ b/pike/pike/proxy/urls.py
@@ -15,19 +15,19 @@
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
-from pike.proxy.views import identityV3
+from pike.proxy.views import identity_v3
from pike.proxy.views import services
from newton_base.proxy import dnsaasdelegate
-urlpatterns = [
+URLPATTERNS = [
url(r'^identity/v3/auth/tokens/?$',
- identityV3.Tokens.as_view()),
+ identity_v3.Tokens.as_view()),
url(r'^identity/v3/?$',
- identityV3.Tokens.as_view()),
+ identity_v3.Tokens.as_view()),
url(r'^identity/v2.0/?',
- identityV3.TokensV2.as_view()),
+ identity_v3.TokensV2.as_view()),
url(r'^identity/v2.0/tokens/?$',
- identityV3.TokensV2.as_view()),
+ identity_v3.TokensV2.as_view()),
url(r'^identity/v2.0/tenants/?$',
services.GetTenants.as_view()),
url(r'dns-delegate/(?P<requri>[0-9a-zA-Z./_-]*)$',
@@ -36,4 +36,4 @@ urlpatterns = [
services.Services.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/proxy/urlsV1.py b/pike/pike/proxy/urls_v1.py
index 481e473f..4ab75947 100644
--- a/pike/pike/proxy/urlsV1.py
+++ b/pike/pike/proxy/urls_v1.py
@@ -15,19 +15,19 @@
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
-from pike.proxy.views import identityV3
+from pike.proxy.views import identity_v3
from pike.proxy.views import services
from newton_base.proxy import dnsaasdelegate
-urlpatterns = [
+URLPATTERNS = [
url(r'^identity/v3/auth/tokens/?$',
- identityV3.APIv1Tokens.as_view()),
+ identity_v3.APIv1Tokens.as_view()),
url(r'^identity/v3/?$',
- identityV3.APIv1Tokens.as_view()),
+ identity_v3.APIv1Tokens.as_view()),
url(r'^identity/v2.0/?$',
- identityV3.APIv1TokensV2.as_view()),
+ identity_v3.APIv1TokensV2.as_view()),
url(r'^identity/v2.0/tokens/?$',
- identityV3.APIv1TokensV2.as_view()),
+ identity_v3.APIv1TokensV2.as_view()),
url(r'^identity/v2.0/tenants/?$',
services.APIv1GetTenants.as_view()),
url(r'dns-delegate/(?P<requri>[0-9a-zA-Z./_-]*)$',
@@ -36,4 +36,4 @@ urlpatterns = [
services.APIv1Services.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/proxy/views/identityV3.py b/pike/pike/proxy/views/identity_v3.py
index 340a0d14..9a87a5e3 100644
--- a/pike/pike/proxy/views/identityV3.py
+++ b/pike/pike/proxy/views/identity_v3.py
@@ -1,3 +1,6 @@
+'''
+identity v3
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +21,7 @@ from django.conf import settings
from newton_base.proxy import identityV3 as newton_identityV3
from common.msapi import extsys
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
# DEBUG=True
@@ -27,14 +30,14 @@ class Tokens(newton_identityV3.Tokens):
def __init__(self):
self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
+ self._logger = LOGGER
class TokensV2(newton_identityV3.TokensV2):
def __init__(self):
self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
+ self._logger = LOGGER
class APIv1Tokens(Tokens):
@@ -44,7 +47,7 @@ class APIv1Tokens(Tokens):
# self._logger = logger
def get(self, request, cloud_owner="", cloud_region_id=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("META> %s" % request.META)
# self._logger.debug("data> %s" % request.data)
@@ -52,7 +55,7 @@ class APIv1Tokens(Tokens):
return super(APIv1Tokens, self).get(request, vimid)
def post(self, request, cloud_owner="", cloud_region_id=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("META> %s" % request.META)
# self._logger.debug("data> %s" % request.data)
@@ -61,13 +64,17 @@ class APIv1Tokens(Tokens):
class APIv1TokensV2(TokensV2):
+ '''
+ API v1 Tokens V2
+ '''
+
def __init__(self):
super(APIv1TokensV2, self).__init__()
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
# self._logger = logger
def get(self, request, cloud_owner="", cloud_region_id=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("META> %s" % request.META)
# self._logger.debug("data> %s" % request.data)
@@ -75,7 +82,7 @@ class APIv1TokensV2(TokensV2):
return super(APIv1TokensV2, self).get(request, vimid)
def post(self, request, cloud_owner="", cloud_region_id=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("META> %s" % request.META)
# self._logger.debug("data> %s" % request.data)
diff --git a/pike/pike/proxy/views/services.py b/pike/pike/proxy/views/services.py
index 15e62056..7fe6d601 100644
--- a/pike/pike/proxy/views/services.py
+++ b/pike/pike/proxy/views/services.py
@@ -1,3 +1,6 @@
+'''
+services
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,15 +20,18 @@ import logging
from newton_base.proxy import services as newton_services
from common.msapi import extsys
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
# DEBUG=True
class Services(newton_services.Services):
+ '''
+ class services
+ '''
def __init__(self):
- self._logger = logger
+ self._logger = LOGGER
class GetTenants(newton_services.GetTenants):
@@ -34,7 +40,7 @@ class GetTenants(newton_services.GetTenants):
'''
def __init__(self):
- self._logger = logger
+ self._logger = LOGGER
def get(self, request, vimid="", servicetype="identity", requri='v3/projects'):
self._logger.debug("GetTenants--get::META> %s" % request.META)
@@ -49,10 +55,10 @@ class APIv1Services(Services):
def __init__(self):
super(APIv1Services, self).__init__()
- # self._logger = logger
+ # self._logger = loggier
def head(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
# self._logger.debug("META, data> %s , %s" % (request.META, request.data))
@@ -60,31 +66,31 @@ class APIv1Services(Services):
return super(APIv1Services, self).head(request, vimid, servicetype, requri)
def get(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services, self).get(request, vimid, servicetype, requri)
def post(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services, self).post(request, vimid, servicetype, requri)
def put(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services, self).put(request, vimid, servicetype, requri)
def patch(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services, self).patch(request, vimid, servicetype, requri)
def delete(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1Services, self).delete(request, vimid, servicetype, requri)
@@ -100,15 +106,16 @@ class APIv1GetTenants(GetTenants):
# self._logger = logger
def head(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri))
# self._logger.debug("META, data> %s , %s" % (request.META, request.data))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1GetTenants, self).head(request, vimid, servicetype, requri)
- def get(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri='v3/projects'):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ def get(self, request, cloud_owner="", cloud_region_id="", servicetype="identity",
+ requri='v3/projects'):
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("with servicetype, requri> %s,%s" % (servicetype, requri))
# self._logger.debug("with META> %s" % request.META)
@@ -116,7 +123,7 @@ class APIv1GetTenants(GetTenants):
return super(APIv1GetTenants, self).get(request, vimid, servicetype, requri)
def post(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
# self._logger.debug("with servicetype, requri> %s,%s" % (servicetype, requri))
# self._logger.debug("with META> %s" % request.META)
# self._logger.debug("with data> %s" % request.data)
@@ -125,19 +132,20 @@ class APIv1GetTenants(GetTenants):
return super(APIv1GetTenants, self).post(request, vimid, servicetype, requri)
def put(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1GetTenants, self).put(request, vimid, servicetype, requri)
def patch(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1GetTenants, self).patch(request, vimid, servicetype, requri)
- def delete(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""):
- self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
+ def delete(self, request, cloud_owner="", cloud_region_id="", servicetype="identity",
+ requri=""):
+ self._logger.debug("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id))
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
return super(APIv1GetTenants, self).delete(request, vimid, servicetype, requri)
diff --git a/pike/pike/registration/tests/test_registration.py b/pike/pike/registration/tests/test_registration.py
index 84840cdb..640d1240 100644
--- a/pike/pike/registration/tests/test_registration.py
+++ b/pike/pike/registration/tests/test_registration.py
@@ -1,3 +1,6 @@
+'''
+test registration
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -166,7 +169,7 @@ MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE = {
}
# HPA UT2: CPU-Topology
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS2_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS2_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -177,7 +180,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS2_RESPONSE = {
}
# HPA UT3: mem_page_size
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS3_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS3_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -186,7 +189,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS3_RESPONSE = {
}
# HPA UT4: numa_nodes
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS4_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS4_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -199,7 +202,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS4_RESPONSE = {
}
# HPA UT5: instruction set
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS5_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS5_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -208,7 +211,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS5_RESPONSE = {
}
# HPA UT6: pci passthrough
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS6_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -216,7 +219,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE = {
}
}
-MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE = {
+MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
"capabilities:cpu_info:model": "Haswell",
@@ -227,6 +230,9 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE = {
class TestRegistration(test_base.TestRequest):
+ '''
+ test registration
+ '''
def setUp(self):
super(TestRegistration, self).setUp()
@@ -263,13 +269,13 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
- response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED,
+ response.status_code)
# @mock.patch.object(VimDriverUtils, 'delete_vim_info')
# def test_unregister_endpoint_successfully(
@@ -289,13 +295,13 @@ class TestRegistration(test_base.TestRequest):
self, mock_delete_vim_info):
mock_delete_vim_info.return_value = 1
- response = self.client.delete((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), "{}", content_type="application/json",
+ response = self.client.delete(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ "{}", content_type="application/json",
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_204_NO_CONTENT,
- response.status_code)
+ self.assertEqual(status.HTTP_204_NO_CONTENT,
+ response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -309,7 +315,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -319,12 +325,12 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -338,7 +344,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS2_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS2_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -348,12 +354,12 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -367,7 +373,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS3_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS3_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -377,12 +383,12 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -396,7 +402,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS4_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS4_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -406,12 +412,12 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -425,7 +431,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS5_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS5_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -435,12 +441,12 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
@@ -454,7 +460,7 @@ class TestRegistration(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE),
- self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE),
+ self._get_mock_response(MOCK_GET_HPA_FLAVOR_ONAP_MINI_EXTRA_SPECS6_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -464,9 +470,9 @@ class TestRegistration(test_base.TestRequest):
]
})
- response = self.client.post((
- "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/"
- "registry"), TEST_REGISTER_ENDPOINT_REQUEST,
+ response = self.client.post(
+ "/api/multicloud-pike/v0/windriver-hudson-dc_RegionOne/registry",
+ TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code)
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
diff --git a/pike/pike/registration/views/registration.py b/pike/pike/registration/views/registration.py
index a437e2a4..fc6a6799 100644
--- a/pike/pike/registration/views/registration.py
+++ b/pike/pike/registration/views/registration.py
@@ -1,3 +1,6 @@
+'''
+registration
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +22,7 @@ from django.conf import settings
from newton_base.registration import registration as newton_registration
from common.msapi import extsys
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
# DEBUG=True
@@ -29,7 +32,7 @@ class Registry(newton_registration.Registry):
def __init__(self):
self.proxy_prefix = settings.MULTICLOUD_PREFIX
self.aai_base_url = settings.AAI_BASE_URL
- self._logger = logger
+ self._logger = LOGGER
super(Registry, self).__init__()
@@ -37,7 +40,7 @@ class RegistryV1(Registry):
def __init__(self):
self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
self.aai_base_url = settings.AAI_BASE_URL
- self._logger = logger
+ self._logger = LOGGER
super(RegistryV1, self).__init__()
def post(self, request, cloud_owner="", cloud_region_id=""):
diff --git a/pike/pike/requests/urls.py b/pike/pike/requests/urls.py
index 64ec70db..6f9d56cf 100644
--- a/pike/pike/requests/urls.py
+++ b/pike/pike/requests/urls.py
@@ -1,3 +1,6 @@
+'''
+Request url
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +28,7 @@ from newton_base.openoapi import limits
from newton_base.openoapi import hosts
from newton_base.openoapi import flavor
-urlpatterns = [
+URLPATTERNS = [
url(r'^networks(/(?P<networkid>[0-9a-zA-Z_-]+))?',
network.Networks.as_view()),
url(r'^subnets(/(?P<subnetid>[0-9a-zA-Z_-]+))?',
@@ -46,4 +49,4 @@ urlpatterns = [
url(r'^hosts(/(?P<hostname>[0-9a-zA-Z_-]+))?', hosts.Hosts.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/requests/urlsV1.py b/pike/pike/requests/urls_v1.py
index 80b0a7e9..bde8b6a0 100644
--- a/pike/pike/requests/urlsV1.py
+++ b/pike/pike/requests/urls_v1.py
@@ -1,3 +1,6 @@
+'''
+Request url V1
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +28,7 @@ from newton_base.openoapi import limits
from newton_base.openoapi import hosts
from newton_base.openoapi import flavor
-urlpatterns = [
+URLPATTERNS = [
url(r'^networks(/(?P<networkid>[0-9a-zA-Z_-]+))?',
network.APIv1Networks.as_view()),
url(r'^subnets(/(?P<subnetid>[0-9a-zA-Z_-]+))?',
@@ -46,4 +49,4 @@ urlpatterns = [
url(r'^hosts(/(?P<hostname>[0-9a-zA-Z_-]+))?', hosts.APIv1Hosts.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/requests/views/__init__.py b/pike/pike/requests/views/__init__.py
deleted file mode 100644
index 5a9af6b8..00000000
--- a/pike/pike/requests/views/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2018 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/pike/pike/resource/tests/test_capacity.py b/pike/pike/resource/tests/test_capacity.py
index d6f3ea32..cfee8075 100644
--- a/pike/pike/resource/tests/test_capacity.py
+++ b/pike/pike/resource/tests/test_capacity.py
@@ -1,3 +1,6 @@
+'''
+test capability
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import mock
import json
+import mock
from rest_framework import status
@@ -115,9 +118,9 @@ TEST_REQ_FAILED_SOURCE = {
class TestCapacity(test_base.TestRequest):
- def setUp(self):
- super(TestCapacity, self).setUp()
-
+ '''
+ TestCapacity
+ '''
def _get_mock_response(self, return_value=None):
mock_response = mock.Mock(spec=test_base.MockResponse)
mock_response.status_code = status.HTTP_200_OK
@@ -127,6 +130,9 @@ class TestCapacity(test_base.TestRequest):
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_success(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_success
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -142,12 +148,15 @@ class TestCapacity(test_base.TestRequest):
TEST_REQ_SUCCESS_SOURCE,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": True}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_nova_limits_failed(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_nova_limits_failed
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -163,12 +172,15 @@ class TestCapacity(test_base.TestRequest):
TEST_REQ_FAILED_SOURCE,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_nova_hypervisor_outofram(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_nova_hypervisor_outofram
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -185,12 +197,15 @@ class TestCapacity(test_base.TestRequest):
content_type='application/json',
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_nova_hypervisor_outofstorage(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_nova_hypervisor_outofstorage
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -207,12 +222,15 @@ class TestCapacity(test_base.TestRequest):
content_type='application/json',
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_nova_hypervisor_outofvcpu(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_nova_hypervisor_outofvcpu
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -229,12 +247,15 @@ class TestCapacity(test_base.TestRequest):
content_type='application/json',
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_nova_limits_outofram(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_nova_limits_outofram
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -251,12 +272,15 @@ class TestCapacity(test_base.TestRequest):
content_type='application/json',
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": True}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@mock.patch.object(VimDriverUtils, 'get_vim_info')
def test_capacity_check_volume_limits_outofstorage(self, mock_get_vim_info, mock_get_session):
+ '''
+ test_capacity_check_volume_limits_outofstorage
+ '''
mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
@@ -273,5 +297,5 @@ class TestCapacity(test_base.TestRequest):
content_type='application/json',
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual({"result": False}, response.data)
diff --git a/pike/pike/resource/tests/tests_infra_workload.py b/pike/pike/resource/tests/tests_infra_workload.py
index 52a76e58..c4df70b4 100644
--- a/pike/pike/resource/tests/tests_infra_workload.py
+++ b/pike/pike/resource/tests/tests_infra_workload.py
@@ -1,3 +1,6 @@
+'''
+test infra workload
+'''
# Copyright (c) 2018 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -101,7 +104,8 @@ MOCK_HEAT_CREATE_BODY1 = {
"get_param": "flavor"
},
"image": "40be8d1a-3eb9-40de-8abd-43237517384f",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
+ "user_data":
+ "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
}
}
}
@@ -154,7 +158,8 @@ MOCK_HEAT_CREATE_BODY2 = {
"get_param": "flavor"
},
"image": "40be8d1a-3eb9-40de-8abd-43237517384f",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
+ "user_data":
+ "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
}
}
}
@@ -166,7 +171,7 @@ MOCK_HEAT_CREATE_BODY2 = {
class InfraWorkloadTest(unittest.TestCase):
def setUp(self):
- self._InfraWorkload = InfraWorkload()
+ self._infra_workload = InfraWorkload()
pass
def tearDown(self):
@@ -189,13 +194,14 @@ class InfraWorkloadTest(unittest.TestCase):
vimid = "CloudOwner_Region1"
- response = self._InfraWorkload.post(mock_request, vimid)
+ response = self._infra_workload.post(mock_request, vimid)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
pass
@mock.patch.object(helper, 'MultiCloudServiceHelper')
@mock.patch.object(helper, 'MultiCloudIdentityHelper')
- def test_post_wo_oof_directive(self, mock_MultiCloudIdentityHelper, mock_MultiCloudServiceHelper):
+ def test_post_wo_oof_directive(self, mock_MultiCloudIdentityHelper,
+ mock_MultiCloudServiceHelper):
mock_request = mock.Mock()
mock_request.META = {"testkey": "testvalue"}
mock_request.data = MOCK_HEAT_CREATE_BODY2
@@ -210,7 +216,7 @@ class InfraWorkloadTest(unittest.TestCase):
vimid = "CloudOwner_Region1"
- response = self._InfraWorkload.post(mock_request, vimid)
+ response = self._infra_workload.post(mock_request, vimid)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
pass
@@ -231,7 +237,7 @@ class InfraWorkloadTest(unittest.TestCase):
vimid = "CloudOwner_Region1"
mock_stack_id = "MOCKED_HEAT_STACK_ID1"
- response = self._InfraWorkload.get(mock_request, vimid, mock_stack_id)
+ response = self._infra_workload.get(mock_request, vimid, mock_stack_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
pass
@@ -252,7 +258,7 @@ class InfraWorkloadTest(unittest.TestCase):
vimid = "CloudOwner_Region1"
mock_stack_id = "MOCKED_HEAT_STACK_ID1"
- response = self._InfraWorkload.delete(mock_request, vimid, mock_stack_id)
+ response = self._infra_workload.delete(mock_request, vimid, mock_stack_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
pass
@@ -305,7 +311,8 @@ class APIv1InfraWorkloadTest(unittest.TestCase):
cloud_region_id = "Region1"
mock_stack_id = "MOCKED_HEAT_STACK_ID1"
- response = self._APIv1InfraWorkload.get(mock_request, cloud_owner, cloud_region_id, mock_stack_id)
+ response = self._APIv1InfraWorkload.get(mock_request, cloud_owner,
+ cloud_region_id, mock_stack_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
pass
@@ -327,6 +334,7 @@ class APIv1InfraWorkloadTest(unittest.TestCase):
cloud_region_id = "Region1"
mock_stack_id = "MOCKED_HEAT_STACK_ID1"
- response = self._APIv1InfraWorkload.delete(mock_request, cloud_owner, cloud_region_id, mock_stack_id)
+ response = self._APIv1InfraWorkload.delete(mock_request, cloud_owner,
+ cloud_region_id, mock_stack_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
pass
diff --git a/pike/pike/samples/tests.py b/pike/pike/samples/tests.py
index 02c59247..4258e257 100644
--- a/pike/pike/samples/tests.py
+++ b/pike/pike/samples/tests.py
@@ -1,3 +1,6 @@
+'''
+pike sample test
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +21,11 @@ from rest_framework import status
class SampleViewTest(unittest.TestCase):
+ '''
+ Sample view test
+ '''
def setUp(self):
+
self.client = Client()
def tearDown(self):
diff --git a/pike/pike/samples/urls.py b/pike/pike/samples/urls.py
index 94bd5669..cee20b31 100644
--- a/pike/pike/samples/urls.py
+++ b/pike/pike/samples/urls.py
@@ -1,3 +1,6 @@
+'''
+Samples url
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +16,10 @@
# limitations under the License.
from django.conf.urls import url
+from rest_framework.urlpatterns import format_suffix_patterns
from pike.samples import views
-urlpatterns = [
+URLPATTERNS = [
url(r'^samples/$', views.SampleList.as_view()), ]
+
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/samples/views.py b/pike/pike/samples/views.py
index 58d1d80b..f0fe6883 100644
--- a/pike/pike/samples/views.py
+++ b/pike/pike/samples/views.py
@@ -1,3 +1,6 @@
+'''
+samples view
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,13 +20,13 @@ import logging
from rest_framework.views import APIView
from rest_framework.response import Response
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
class SampleList(APIView):
"""
List all samples.
"""
- def get(self, request, format=None):
- logger.debug("get")
+ def get(self, request):
+ LOGGER.debug("get %s", request)
return Response({"status": "active"})
diff --git a/pike/pike/swagger/tests.py b/pike/pike/swagger/tests.py
index cb90d692..8cd83134 100644
--- a/pike/pike/swagger/tests.py
+++ b/pike/pike/swagger/tests.py
@@ -1,3 +1,6 @@
+'''
+test swagger
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/pike/pike/swagger/urls.py b/pike/pike/swagger/urls.py
index 5e0c0233..ca5a49b7 100644
--- a/pike/pike/swagger/urls.py
+++ b/pike/pike/swagger/urls.py
@@ -1,3 +1,6 @@
+'''
+swagger url
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,9 +21,9 @@ from rest_framework.urlpatterns import format_suffix_patterns
from pike.swagger.views import SwaggerJsonView
from pike.swagger.views import APIv1SwaggerJsonView
-urlpatterns = [
+URLPATTERNS = [
url(r'^api/multicloud-pike/v0/swagger.json$', SwaggerJsonView.as_view()),
url(r'^api/multicloud-pike/v1/swagger.json$', APIv1SwaggerJsonView.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/pike/pike/swagger/views.py b/pike/pike/swagger/views.py
index 07c6960f..1a7f2b02 100644
--- a/pike/pike/swagger/views.py
+++ b/pike/pike/swagger/views.py
@@ -1,3 +1,6 @@
+'''
+swagger view
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,16 +15,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import logging
-
from rest_framework.response import Response
from newton_base.swagger import views as newton_json_view
-logger = logging.getLogger(__name__)
-
class SwaggerJsonView(newton_json_view.SwaggerJsonView):
+ '''
+ Swagger Json View
+ '''
def get(self, request):
'''
@@ -36,11 +38,14 @@ class SwaggerJsonView(newton_json_view.SwaggerJsonView):
json_data["basePath"] = "/api/multicloud-pike/v0/"
json_data["info"]["title"] = "Service NBI of MultiCloud plugin for OpenStack Pike"
return Response(data=json_data, status=200)
- else:
- return Response(data={'error': 'internal error'}, status=500)
+
+ return Response(data={'error': 'internal error'}, status=500)
class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView):
+ '''
+ V1 Swagger Json View
+ '''
def get(self, request):
'''
@@ -55,5 +60,5 @@ class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView):
json_data["basePath"] = "/api/multicloud-pike/v1/"
json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Pike"
return Response(data=json_data, status=200)
- else:
- return Response(data={'error': 'internal error'}, status=500)
+
+ return Response(data={'error': 'internal error'}, status=500)
diff --git a/pike/pike/urls.py b/pike/pike/urls.py
index 3658dc1f..97fd593d 100644
--- a/pike/pike/urls.py
+++ b/pike/pike/urls.py
@@ -1,3 +1,6 @@
+'''
+The entry of urls
+'''
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +31,8 @@ urlpatterns = [
include('pike.extensions.urls')),
url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/?$',
infra_workload.InfraWorkload.as_view()),
- url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',
+ url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/'
+ '(?P<requri>[0-9a-zA-Z_-]*)/?$',
infra_workload.InfraWorkload.as_view()),
url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/',
include('pike.proxy.urls')),
@@ -40,25 +44,35 @@ urlpatterns = [
capacity.CapacityCheck.as_view()),
url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/?$',
infra_workload.InfraWorkload.as_view()),
- url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',
+ url(r'^api/multicloud-pike/v0/(?P<vimid>[0-9a-zA-Z_-]+)/infra_workload/'
+ '(?P<requri>[0-9a-zA-Z_-]*)/?$',
infra_workload.InfraWorkload.as_view()),
# API upgrading
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/registry$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/registry$',
registration.RegistryV1.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)$',
registration.RegistryV1.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/exten',
- include('pike.extensions.urlsV1')),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/tenants/?$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/exten',
+ include('pike.extensions.urls_v1')),
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/tenants/?$',
tenants.APIv1Tenants.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/'
- '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('pike.requests.urlsV1')),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/capacity_check/?$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/'
+ '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('pike.requests.urls_v1')),
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/capacity_check/?$',
capacity.APIv1CapacityCheck.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$',
infra_workload.APIv1InfraWorkload.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',
infra_workload.APIv1InfraWorkload.as_view()),
- url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/',
- include('pike.proxy.urlsV1')),
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ '(?P<cloud_region_id>[0-9a-zA-Z_-]+)/',
+ include('pike.proxy.urls_v1')),
]
diff --git a/pike/pike/wsgi.py b/pike/pike/wsgi.py
index ebe63812..9b533a1a 100644
--- a/pike/pike/wsgi.py
+++ b/pike/pike/wsgi.py
@@ -1,3 +1,6 @@
+"""
+start django web server.
+"""
# Copyright (c) 2017-2018 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,4 +21,4 @@ from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pike.settings")
-application = get_wsgi_application()
+APPLICATION = get_wsgi_application()
diff --git a/pike/requirements.txt b/pike/requirements.txt
index ea5aa649..3c9eda48 100644
--- a/pike/requirements.txt
+++ b/pike/requirements.txt
@@ -13,11 +13,11 @@
# limitations under the License.
# rest framework
-Django==1.9.6
-djangorestframework==3.3.3
+Django==2.2.3
+djangorestframework==3.9.4
# for call rest api
-httplib2==0.9.2
+httplib2==0.13.0
# for call openstack auth and transport api
keystoneauth1==2.18.0
@@ -34,4 +34,4 @@ uwsgi
# unittest_xml_reporting==1.12.0
# for onap logging
-onappylog>=1.0.8
+onappylog>=1.0.9
diff --git a/pike/tox.ini b/pike/tox.ini
index c5e9e5c0..d4f5d579 100644
--- a/pike/tox.ini
+++ b/pike/tox.ini
@@ -13,7 +13,7 @@
# limitations under the License.
[tox]
-envlist = py27,pep8,cov,pylint
+envlist = py35,pep8,cov,pylint
skipsdist = true
[tox:jenkins]
@@ -25,6 +25,11 @@ exclude = ./venv-tox,./.tox
max-complexity = 27
[testenv]
+basepython =
+ py35: python3.5
+ pep8: python3.5
+ cov: python3.5
+ pylint: python3.5
setenv =
PYTHONPATH = {toxinidir}/../share
deps =
@@ -36,7 +41,7 @@ commands =
[testenv:pep8]
deps=flake8
-commands=flake8
+commands=python3.5 -m flake8
[testenv:cov]
commands = coverage xml --omit="./venv-tox/*,./.tox/*,*tests*,*__init__.py,*newton_base*,*common*, *site-packages*"