diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-08-20 10:01:12 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2019-08-21 03:02:23 +0000 |
commit | fbc00166dc021898a1a7dfb98672ec3bc28851b9 (patch) | |
tree | 789c60af42a259a5fb58753dc9e4485aea95db87 /windriver/titanium_cloud/extensions | |
parent | 4c33dac9a6735b07c5e7e0d2f67baa2f5eaeed97 (diff) |
Update windriver plugin to py3
Change-Id: I7bb1591a31de777d59ad1b96246bbc4d8e1f86f4
Issue-ID: MULTICLOUD-774
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/extensions')
4 files changed, 21 insertions, 21 deletions
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)) |