summaryrefslogtreecommitdiffstats
path: root/windriver
diff options
context:
space:
mode:
Diffstat (limited to 'windriver')
-rw-r--r--windriver/docker/Dockerfile8
-rw-r--r--windriver/initialize.sh2
-rwxr-xr-xwindriver/mvn-phase-script.sh2
-rw-r--r--windriver/pom.xml13
-rw-r--r--windriver/requirements.txt14
-rw-r--r--windriver/test-requirements.txt2
-rw-r--r--windriver/titanium_cloud/extensions/tests/test_extensions.py18
-rw-r--r--windriver/titanium_cloud/extensions/urls.py4
-rw-r--r--windriver/titanium_cloud/extensions/urlsV1.py4
-rw-r--r--windriver/titanium_cloud/extensions/views/extensions.py16
-rw-r--r--windriver/titanium_cloud/proxy/tests/test_service_proxy.py28
-rw-r--r--windriver/titanium_cloud/proxy/urls.py4
-rw-r--r--windriver/titanium_cloud/proxy/urlsV1.py4
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py20
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration2.py35
-rw-r--r--windriver/titanium_cloud/requests/urls.py4
-rw-r--r--windriver/titanium_cloud/requests/urlsV1.py4
-rw-r--r--windriver/titanium_cloud/resource/tests/test_capacity.py14
-rw-r--r--windriver/titanium_cloud/samples/urls.py5
-rw-r--r--windriver/titanium_cloud/swagger/urls.py4
-rw-r--r--windriver/titanium_cloud/wsgi.py2
-rw-r--r--windriver/tox.ini8
-rw-r--r--windriver/uwsgi-requirements.txt2
23 files changed, 122 insertions, 95 deletions
diff --git a/windriver/docker/Dockerfile b/windriver/docker/Dockerfile
index ca300fdc..8310238c 100644
--- a/windriver/docker/Dockerfile
+++ b/windriver/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:2-alpine
+FROM python:3-alpine
ARG HTTP_PROXY=${HTTP_PROXY}
ARG HTTPS_PROXY=${HTTPS_PROXY}
@@ -18,15 +18,15 @@ EXPOSE 9005
RUN addgroup -S onap && adduser -S -G onap onap
# COPY ./ /opt/windriver/
-
+COPY ./multicloud-openstack-windriver-*.zip /opt/multicloud-openstack-windriver.zip
RUN apk update && \
apk add uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
cd /opt/ && \
- wget -O multicloud-openstack-windriver.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=staging&g=org.onap.multicloud.openstack&a=multicloud-openstack-windriver&e=zip&v=1.4.0" && \
unzip -q -o -B multicloud-openstack-windriver.zip && \
chmod +x /opt/windriver/*.sh && \
rm -f multicloud-openstack-windriver.zip && \
- pip install -r /opt/windriver/requirements.txt && \
+ pip3 install -r /opt/windriver/requirements.txt && \
+ pip3 install -r /opt/windriver/uwsgi-requirements.txt && \
apk del wget unzip gcc make libc-dev libffi-dev openssl-dev && \
mkdir -p /var/log/onap/multicloud/openstack/windriver && \
chown onap:onap /var/log/onap -R && \
diff --git a/windriver/initialize.sh b/windriver/initialize.sh
index 99a8cdd0..be8e56ec 100644
--- a/windriver/initialize.sh
+++ b/windriver/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/windriver/mvn-phase-script.sh b/windriver/mvn-phase-script.sh
index ad1d6329..6cc1b2bb 100755
--- a/windriver/mvn-phase-script.sh
+++ b/windriver/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/windriver/pom.xml b/windriver/pom.xml
index 7299038d..09c8ac7c 100644
--- a/windriver/pom.xml
+++ b/windriver/pom.xml
@@ -125,17 +125,28 @@
<executions>
<execution>
<id>copy-resources</id>
- <phase>validate</phase>
+ <phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
+ <overwrite>true</overwrite>
+ <nonFilteredFileExtensions>
+ <nonFilteredFileExtension>zip</nonFilteredFileExtension>
+ </nonFilteredFileExtensions>
<outputDirectory>${project.basedir}/docker_target</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/docker</directory>
<filtering>true</filtering>
</resource>
+ <resource>
+ <directory>${project.basedir}/target</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>*.zip</include>
+ </includes>
+ </resource>
</resources>
</configuration>
</execution>
diff --git a/windriver/requirements.txt b/windriver/requirements.txt
index fefde87b..bad5c0d4 100644
--- a/windriver/requirements.txt
+++ b/windriver/requirements.txt
@@ -1,18 +1,18 @@
# 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
-#python-memcached
+# python-memcached
python-memcached
-#uwsgi for parallel processing
-uwsgi
+# uwsgi for parallel processing
+# uwsgi
# for unit test
# coverage==4.2
@@ -20,7 +20,7 @@ uwsgi
# unittest_xml_reporting==1.12.0
# for onap logging
-onappylog>=1.0.8
+onappylog>=1.0.9
# for background tasks
# celery >= 4.0
diff --git a/windriver/test-requirements.txt b/windriver/test-requirements.txt
index cc3059e2..d91d31db 100644
--- a/windriver/test-requirements.txt
+++ b/windriver/test-requirements.txt
@@ -1,6 +1,6 @@
# for unit test
coverage==4.2
-mock==2.0.0
+mock==3.0.5
unittest_xml_reporting==1.12.0
pylint # GPLv2
diff --git a/windriver/titanium_cloud/extensions/tests/test_extensions.py b/windriver/titanium_cloud/extensions/tests/test_extensions.py
index 26687b33..978e2023 100644
--- a/windriver/titanium_cloud/extensions/tests/test_extensions.py
+++ b/windriver/titanium_cloud/extensions/tests/test_extensions.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
+# Copyright (c) 2017-2019 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,9 +12,9 @@
# 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):
@@ -30,12 +30,12 @@ class TestExtensions(unittest.TestCase):
"/api/multicloud-titaniumcloud/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"])
- self.assertEquals("Multiple network support", json_content["extensions"][0]["description"])
- self.assertEquals("", json_content["extensions"][0]["spec"])
+ self.assertEqual("Multiple network support", json_content["extensions"][0]["description"])
+ self.assertEqual("", json_content["extensions"][0]["spec"])
diff --git a/windriver/titanium_cloud/extensions/urls.py b/windriver/titanium_cloud/extensions/urls.py
index 3bcf9a4c..842d8542 100644
--- a/windriver/titanium_cloud/extensions/urls.py
+++ b/windriver/titanium_cloud/extensions/urls.py
@@ -17,8 +17,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
from titanium_cloud.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/windriver/titanium_cloud/extensions/urlsV1.py b/windriver/titanium_cloud/extensions/urlsV1.py
index f6398ef6..06a9e861 100644
--- a/windriver/titanium_cloud/extensions/urlsV1.py
+++ b/windriver/titanium_cloud/extensions/urlsV1.py
@@ -17,8 +17,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
from titanium_cloud.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/windriver/titanium_cloud/extensions/views/extensions.py b/windriver/titanium_cloud/extensions/views/extensions.py
index 7dd78272..1bfe7417 100644
--- a/windriver/titanium_cloud/extensions/views/extensions.py
+++ b/windriver/titanium_cloud/extensions/views/extensions.py
@@ -25,7 +25,7 @@ from common.exceptions import VimDriverNewtonException
from common.msapi import extsys
from newton_base.extensions import extensions as newton_extensions
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
# DEBUG=True
@@ -34,12 +34,12 @@ class Extensions(newton_extensions.Extensions):
def __init__(self):
super(Extensions, self).__init__()
- # self._logger = logger
+ # self._logger = LOGGER
self.proxy_prefix = settings.MULTICLOUD_PREFIX
def get(self, request, vimid=""):
- logger.debug("Extensions--get::data> %s" % request.data)
- logger.debug("Extensions--get::vimid> %s"
+ LOGGER.debug("Extensions--get::data> %s" % request.data)
+ LOGGER.debug("Extensions--get::vimid> %s"
% vimid)
try:
cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
@@ -65,10 +65,10 @@ class Extensions(newton_extensions.Extensions):
except VimDriverNewtonException as e:
return Response(data={'error': e.content}, status=e.status_code)
except HttpError as e:
- logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
+ LOGGER.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
return Response(data=e.response.json(), status=e.http_status)
except Exception as e:
- logger.error(traceback.format_exc())
+ LOGGER.error(traceback.format_exc())
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -77,11 +77,11 @@ class APIv1Extensions(Extensions):
def __init__(self):
super(APIv1Extensions, self).__init__()
- # 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(
+ LOGGER.info(
"cloud_owner,cloud_region_id: %s,%s" %
(cloud_owner, cloud_region_id))
diff --git a/windriver/titanium_cloud/proxy/tests/test_service_proxy.py b/windriver/titanium_cloud/proxy/tests/test_service_proxy.py
index 15d46ae1..c206ba75 100644
--- a/windriver/titanium_cloud/proxy/tests/test_service_proxy.py
+++ b/windriver/titanium_cloud/proxy/tests/test_service_proxy.py
@@ -718,12 +718,12 @@ class TestServiceProxy(unittest.TestCase):
response = self.client.head(
"/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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-titaniumcloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers")
- self.assertEquals(status.HTTP_403_FORBIDDEN, response.status_code)
+ 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):
@@ -732,7 +732,7 @@ class TestServiceProxy(unittest.TestCase):
response = self.client.get(
"/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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')
@@ -744,14 +744,14 @@ class TestServiceProxy(unittest.TestCase):
url_part3 = "/v2.1/fcca3cc49d5e42caae15459e27103efc/servers"
url = (url_part1 + servicetype + url_part3)
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))
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
@@ -759,7 +759,7 @@ class TestServiceProxy(unittest.TestCase):
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')
@@ -818,29 +818,29 @@ class TestServiceProxy(unittest.TestCase):
"/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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-titaniumcloud/v0/windriver-hudson-dc_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-titaniumcloud/v0/windriver-hudson-dc_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
@@ -848,5 +848,5 @@ class TestServiceProxy(unittest.TestCase):
"/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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/windriver/titanium_cloud/proxy/urls.py b/windriver/titanium_cloud/proxy/urls.py
index 22f714d1..7b33801d 100644
--- a/windriver/titanium_cloud/proxy/urls.py
+++ b/windriver/titanium_cloud/proxy/urls.py
@@ -19,7 +19,7 @@ from titanium_cloud.proxy.views import identityV3
from titanium_cloud.proxy.views import services
from newton_base.proxy import dnsaasdelegate
-urlpatterns = [
+URLPATTERNS = [
# url(r'^identity/v2)$',
# identityV2.Tokens.as_view()),
url(r'^identity/v3/auth/tokens/?$',
@@ -38,4 +38,4 @@ urlpatterns = [
services.Services.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/windriver/titanium_cloud/proxy/urlsV1.py b/windriver/titanium_cloud/proxy/urlsV1.py
index 757ddf7e..88a8638a 100644
--- a/windriver/titanium_cloud/proxy/urlsV1.py
+++ b/windriver/titanium_cloud/proxy/urlsV1.py
@@ -19,7 +19,7 @@ from titanium_cloud.proxy.views import identityV3
from titanium_cloud.proxy.views import services
from newton_base.proxy import dnsaasdelegate
-urlpatterns = [
+URLPATTERNS = [
url(r'^identity/v3/auth/tokens/?$',
identityV3.APIv1Tokens.as_view()),
url(r'^identity/v3/?$',
@@ -36,4 +36,4 @@ urlpatterns = [
services.APIv1Services.as_view()),
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py
index 49df5b23..48d638d7 100644
--- a/windriver/titanium_cloud/registration/tests/test_registration.py
+++ b/windriver/titanium_cloud/registration/tests/test_registration.py
@@ -245,7 +245,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
# @mock.patch.object(VimDriverUtils, 'delete_vim_info')
@@ -258,7 +258,7 @@ class TestRegistration(test_base.TestRequest):
# "registry"), "{}", content_type="application/json",
# HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- # self.assertEquals(status.HTTP_202_ACCEPTED,
+ # self.assertEqual(status.HTTP_202_ACCEPTED,
# response.status_code)
@mock.patch.object(VimDriverUtils, 'delete_vim_info')
@@ -271,7 +271,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), "{}", content_type="application/json",
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_204_NO_CONTENT,
+ self.assertEqual(status.HTTP_204_NO_CONTENT,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -301,7 +301,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -331,7 +331,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -361,7 +361,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -391,7 +391,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -421,7 +421,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -451,7 +451,7 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -481,5 +481,5 @@ class TestRegistration(test_base.TestRequest):
"registry"), TEST_REGISTER_ENDPOINT_REQUEST,
HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID)
- self.assertEquals(status.HTTP_202_ACCEPTED,
+ self.assertEqual(status.HTTP_202_ACCEPTED,
response.status_code)
diff --git a/windriver/titanium_cloud/registration/tests/test_registration2.py b/windriver/titanium_cloud/registration/tests/test_registration2.py
index e00c6adc..1072b373 100644
--- a/windriver/titanium_cloud/registration/tests/test_registration2.py
+++ b/windriver/titanium_cloud/registration/tests/test_registration2.py
@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import mock
-
+# import mock
import unittest
+from unittest import mock
+
# import json
from django.test import Client
from rest_framework import status
@@ -72,6 +73,7 @@ MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa = {
}
+
class TestRegistration2(unittest.TestCase):
def setUp(self):
self.client = Client()
@@ -84,25 +86,30 @@ class TestRegistration2(unittest.TestCase):
restcall.req_to_aai = mock.Mock()
restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK)
mock_session = test_base.get_mock_session(
- ["get"], {"get": {
- "content": MOCK_GET_FLAVOR_RESPONSE}}),
-
- retcode, content = self.view.register_helper._discover_flavors(vimid="windriver-hudson-dc_RegionOne",
+ ["get"], {
+ "side_effect": [
+ test_base.get_mock_response(MOCK_GET_FLAVOR_RESPONSE)
+ ]
+ })
+ retcode, content = self.view.register_helper._discover_flavors(
+ vimid="windriver-hudson-dc_RegionOne",
session=mock_session, viminfo=MOCK_VIM_INFO)
- self.assertEquals(retcode, 11)
+ self.assertEqual(retcode, 0)
def test_discover_flavors_w_hpa_numa(self):
restcall.req_to_aai = mock.Mock()
restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK)
mock_session = test_base.get_mock_session(
- ["get"], {"side_effect": [{
- "content": MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa},
- {
- "content": MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa}
- ]}),
+ ["get"], {
+ "side_effect": [
+ test_base.get_mock_response(MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa),
+ test_base.get_mock_response(MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa),
+ ]
+ })
- retcode, content = self.view.register_helper._discover_flavors(vimid="windriver-hudson-dc_RegionOne",
+ retcode, content = self.view.register_helper._discover_flavors(
+ vimid="windriver-hudson-dc_RegionOne",
session=mock_session, viminfo=MOCK_VIM_INFO)
- self.assertEquals(retcode, 11)
+ self.assertEqual(retcode, 0)
diff --git a/windriver/titanium_cloud/requests/urls.py b/windriver/titanium_cloud/requests/urls.py
index bfba9c73..73a91f20 100644
--- a/windriver/titanium_cloud/requests/urls.py
+++ b/windriver/titanium_cloud/requests/urls.py
@@ -25,7 +25,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_-]+))?',
@@ -50,4 +50,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/windriver/titanium_cloud/requests/urlsV1.py b/windriver/titanium_cloud/requests/urlsV1.py
index eaca68c6..2bd18287 100644
--- a/windriver/titanium_cloud/requests/urlsV1.py
+++ b/windriver/titanium_cloud/requests/urlsV1.py
@@ -25,7 +25,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_-]+))?',
@@ -50,4 +50,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/windriver/titanium_cloud/resource/tests/test_capacity.py b/windriver/titanium_cloud/resource/tests/test_capacity.py
index 82c453a2..72fff786 100644
--- a/windriver/titanium_cloud/resource/tests/test_capacity.py
+++ b/windriver/titanium_cloud/resource/tests/test_capacity.py
@@ -143,7 +143,7 @@ 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({'AZs': [],"result": True}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -164,7 +164,7 @@ 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({'AZs': [],"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -186,7 +186,7 @@ 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({'AZs': [],"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -208,7 +208,7 @@ 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({'AZs': [],"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -230,7 +230,7 @@ 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({'AZs': [],"result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -252,7 +252,7 @@ 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({'AZs': [], "result": False}, response.data)
@mock.patch.object(VimDriverUtils, 'get_session')
@@ -274,5 +274,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({'AZs': [], "result": False}, response.data)
diff --git a/windriver/titanium_cloud/samples/urls.py b/windriver/titanium_cloud/samples/urls.py
index e5f0e65c..71a53593 100644
--- a/windriver/titanium_cloud/samples/urls.py
+++ b/windriver/titanium_cloud/samples/urls.py
@@ -13,7 +13,10 @@
# limitations under the License.
from django.conf.urls import url
+from rest_framework.urlpatterns import format_suffix_patterns
from titanium_cloud.samples import views
-urlpatterns = [
+URLPATTERNS = [
url(r'^samples/?$', views.SampleList.as_view()), ]
+
+urlpatterns = format_suffix_patterns(URLPATTERNS) \ No newline at end of file
diff --git a/windriver/titanium_cloud/swagger/urls.py b/windriver/titanium_cloud/swagger/urls.py
index a690d9cf..cdd9e8ed 100644
--- a/windriver/titanium_cloud/swagger/urls.py
+++ b/windriver/titanium_cloud/swagger/urls.py
@@ -20,7 +20,7 @@ from titanium_cloud.swagger.views import APIv1SwaggerJsonViewDepreciated
from titanium_cloud.swagger.views import SwaggerJsonView
from titanium_cloud.swagger.views import APIv1SwaggerJsonView
-urlpatterns = [
+URLPATTERNS = [
# API v0, depreciated
url(r'^api/multicloud-titanium_cloud/v0/swagger.json$', SwaggerJsonViewDepreciated.as_view()),
@@ -35,4 +35,4 @@ urlpatterns = [
]
-urlpatterns = format_suffix_patterns(urlpatterns)
+urlpatterns = format_suffix_patterns(URLPATTERNS)
diff --git a/windriver/titanium_cloud/wsgi.py b/windriver/titanium_cloud/wsgi.py
index 14676067..975baed0 100644
--- a/windriver/titanium_cloud/wsgi.py
+++ b/windriver/titanium_cloud/wsgi.py
@@ -19,4 +19,4 @@ from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "titanium_cloud.settings")
-application = get_wsgi_application()
+APPLICATION = get_wsgi_application()
diff --git a/windriver/tox.ini b/windriver/tox.ini
index 680db516..defe6218 100644
--- a/windriver/tox.ini
+++ b/windriver/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,cov,pylint
+envlist = py36,cov,pylint
skipsdist = true
[tox:jenkins]
@@ -11,6 +11,10 @@ exclude = ./venv-tox,./.tox
max-complexity = 27
[testenv]
+basepython =
+ py36: python3
+ cov: python3
+ pylint: python3
setenv =
PYTHONPATH = {toxinidir}/../share
deps =
@@ -22,7 +26,7 @@ commands =
[testenv:pep8]
deps=flake8
-commands=flake8
+commands=python3 -m flake8
[testenv:cov]
commands = coverage xml --omit="./venv-tox/*,./.tox/*,*tests*,*__init__.py,*newton_base*,*common*,*starlingx_base* *site-packages*"
diff --git a/windriver/uwsgi-requirements.txt b/windriver/uwsgi-requirements.txt
new file mode 100644
index 00000000..5b24077b
--- /dev/null
+++ b/windriver/uwsgi-requirements.txt
@@ -0,0 +1,2 @@
+# uwsgi for parallel processing
+uwsgi \ No newline at end of file