diff options
author | Bin Yang <bin.yang@windriver.com> | 2018-09-03 08:46:12 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2018-09-03 08:46:12 +0000 |
commit | 0ac4f904fae7793a3909f6db34ad9b3c35a08c12 (patch) | |
tree | ac9239304a11abd8429f4f6e36ef407b51d012f5 /windriver | |
parent | 1a4ae5657da11a59bd5cbde5240450f5db69e379 (diff) |
Add new namespace to workaround ISTIO hostname
ISTIO restrains the usage of _ in hostname
Issue-ID: MULTICLOUD-335
Change-Id: I54c712aea1a95c6aaac7d50c3b07472730608503
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'windriver')
-rw-r--r-- | windriver/titanium_cloud/extensions/tests/test_extensions.py | 2 | ||||
-rw-r--r-- | windriver/titanium_cloud/proxy/tests/test_identity_proxy.py | 10 | ||||
-rw-r--r-- | windriver/titanium_cloud/proxy/tests/test_service_proxy.py | 44 | ||||
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 18 | ||||
-rw-r--r-- | windriver/titanium_cloud/resource/tests/test_capacity.py | 14 | ||||
-rw-r--r-- | windriver/titanium_cloud/resource/tests/test_events.py | 362 | ||||
-rw-r--r-- | windriver/titanium_cloud/resource/views/events.py | 105 | ||||
-rw-r--r-- | windriver/titanium_cloud/settings.py | 8 | ||||
-rw-r--r-- | windriver/titanium_cloud/swagger/tests.py | 2 | ||||
-rw-r--r-- | windriver/titanium_cloud/swagger/urls.py | 16 | ||||
-rw-r--r-- | windriver/titanium_cloud/swagger/views.py | 60 | ||||
-rw-r--r-- | windriver/titanium_cloud/urls.py | 51 | ||||
-rw-r--r-- | windriver/titanium_cloud/vesagent/tests.py | 2 |
13 files changed, 166 insertions, 528 deletions
diff --git a/windriver/titanium_cloud/extensions/tests/test_extensions.py b/windriver/titanium_cloud/extensions/tests/test_extensions.py index 1ab792b9..26687b33 100644 --- a/windriver/titanium_cloud/extensions/tests/test_extensions.py +++ b/windriver/titanium_cloud/extensions/tests/test_extensions.py @@ -27,7 +27,7 @@ class TestExtensions(unittest.TestCase): vimid = cloud_owner + "_" + cloud_region_id response = self.client.get( - "/api/multicloud-titanium_cloud/v0/" + vimid + "/extensions/") + "/api/multicloud-titaniumcloud/v0/" + vimid + "/extensions/") json_content = response.json() self.assertEquals(status.HTTP_200_OK, response.status_code) diff --git a/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py b/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py index a3b84f9a..75fb49f5 100644 --- a/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py +++ b/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py @@ -524,7 +524,7 @@ class TestIdentityService(unittest.TestCase): #simulate client to make the request data ={} - response = self.client.post("/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens", data=data, format='json') + response = self.client.post("/api/multicloud-titaniumcloud/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() @@ -561,7 +561,7 @@ class TestIdentityService(unittest.TestCase): # simulate client to make the request data = {} response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens", data=data, format='json') self.failUnlessEqual(status.HTTP_200_OK, response.status_code) @@ -622,7 +622,7 @@ class TestIdentityService(unittest.TestCase): } response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens", + "/api/multicloud-titaniumcloud/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) @@ -671,7 +671,7 @@ class TestIdentityService(unittest.TestCase): } response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens", + "/api/multicloud-titaniumcloud/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) @@ -728,7 +728,7 @@ class TestIdentityService(unittest.TestCase): } response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v3/auth/tokens", + "/api/multicloud-titaniumcloud/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) diff --git a/windriver/titanium_cloud/proxy/tests/test_service_proxy.py b/windriver/titanium_cloud/proxy/tests/test_service_proxy.py index 7a838bce..9f54d08e 100644 --- a/windriver/titanium_cloud/proxy/tests/test_service_proxy.py +++ b/windriver/titanium_cloud/proxy/tests/test_service_proxy.py @@ -490,72 +490,72 @@ MOCK_AUTH_STATE = { MOCK_INTERNAL_METADATA_CATALOG = { "identity" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/identity", "prefix" : "http://128.224.180.14:5000", "suffix" : "v3" }, "patching" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/patching", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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-titanium_cloud/v0/windriver-hudson-dc_RegionOne/orchestration" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/orchestration" }, "volume" : { "prefix" : "http://128.224.180.14:8776", "suffix" : "v1/fcca3cc49d5e42caae15459e27103efc", - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/volume" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/volume" }, "metering" : { "suffix" : "", "prefix" : "http://128.224.180.14:8777", - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/metering" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/metering" }, "volumev3" : { "prefix" : "http://128.224.180.14:8776", "suffix" : "v3/fcca3cc49d5e42caae15459e27103efc", - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/volumev3" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/volumev3" }, "compute" : { "suffix" : "v2.1/fcca3cc49d5e42caae15459e27103efc", "prefix" : "http://128.224.180.14:8774", - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/compute" }, "platform" : { "prefix" : "http://128.224.180.14:6385", "suffix" : "v1", - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/platform" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/platform" }, "nfv" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/nfv", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/nfv", "prefix" : "http://128.224.180.14:4545", "suffix" : "" }, "volumev2" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/volumev2", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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-titanium_cloud/v0/windriver-hudson-dc_RegionOne/image" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/image" }, "network" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/network", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_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-titanium_cloud/v0/windriver-hudson-dc_RegionOne/alarming" + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/alarming" }, "cloudformation" : { - "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/cloudformation", + "proxy_prefix" : "http://172.16.77.20:9003/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/cloudformation", "prefix" : "http://128.224.180.14:8000", "suffix" : "v1/fcca3cc49d5e42caae15459e27103efc" } @@ -719,13 +719,13 @@ class TestServiceProxy(unittest.TestCase): mock_get_session.return_value = mock_session mock_get_token_cache.return_value = (json.dumps(MOCK_AUTH_STATE),json.dumps(MOCK_INTERNAL_METADATA_CATALOG)) response = self.client.head( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers", + "/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) def test_unauthorized_access(self): response = self.client.get( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers") + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers") self.assertEquals(status.HTTP_403_FORBIDDEN, response.status_code) @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -733,7 +733,7 @@ class TestServiceProxy(unittest.TestCase): mock_get_vim_info.return_value = MOCK_VIM_INFO response = self.client.get( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers", + "/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) @@ -743,7 +743,7 @@ 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" - url = ("/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + servicetype + + url = ("/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" + servicetype + "/v2.1/fcca3cc49d5e42caae15459e27103efc/servers") response = self.client.get(url, {}, HTTP_X_AUTH_TOKEN=MOCK_TOKEN_ID) self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code) @@ -815,7 +815,7 @@ class TestServiceProxy(unittest.TestCase): # Create resource response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers", + "/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) @@ -825,7 +825,7 @@ class TestServiceProxy(unittest.TestCase): # Retrieve resource response = self.client.get( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers", + "/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) context = response.json() @@ -835,7 +835,7 @@ class TestServiceProxy(unittest.TestCase): # Update resource response = self.client.get( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers", + "/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) context = response.json() @@ -845,7 +845,7 @@ class TestServiceProxy(unittest.TestCase): #simulate client to make the request response = self.client.delete( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/compute/v2.1/fcca3cc49d5e42caae15459e27103efc/servers/324dfb7d-f4a9-419a-9a19-237df04b443b", + "/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) diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 5c31c4e8..cc4bdd6c 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -234,7 +234,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -247,7 +247,7 @@ class TestRegistration(test_base.TestRequest): mock_delete_vim_info.return_value = 0 response = self.client.delete(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), "{}", content_type="application/json", HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -261,7 +261,7 @@ class TestRegistration(test_base.TestRequest): mock_delete_vim_info.return_value = 1 response = self.client.delete(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), "{}", content_type="application/json", HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -291,7 +291,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -321,7 +321,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -352,7 +352,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -382,7 +382,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -412,7 +412,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -442,7 +442,7 @@ class TestRegistration(test_base.TestRequest): }) response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/" "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) diff --git a/windriver/titanium_cloud/resource/tests/test_capacity.py b/windriver/titanium_cloud/resource/tests/test_capacity.py index b112818f..51785308 100644 --- a/windriver/titanium_cloud/resource/tests/test_capacity.py +++ b/windriver/titanium_cloud/resource/tests/test_capacity.py @@ -139,7 +139,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", TEST_REQ_SUCCESS_SOURCE, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -160,7 +160,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", TEST_REQ_FAILED_SOURCE, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -181,7 +181,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -203,7 +203,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -225,7 +225,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -247,7 +247,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) @@ -266,7 +266,7 @@ class TestCapacity(test_base.TestRequest): }) response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + "/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/capacity_check", data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) diff --git a/windriver/titanium_cloud/resource/tests/test_events.py b/windriver/titanium_cloud/resource/tests/test_events.py deleted file mode 100644 index 3db76d66..00000000 --- a/windriver/titanium_cloud/resource/tests/test_events.py +++ /dev/null @@ -1,362 +0,0 @@ -# Copyright (c) 2017-2018 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. -# 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 mock - -from rest_framework import status - -from common.utils import restcall -from newton_base.tests import mock_info -from newton_base.tests import test_base -from newton_base.util import VimDriverUtils - -MOCK_GET_SERVERS_DETAIL_RESPONSE = { - "servers" : [ - { - "accessIPv4" : "", - "OS-EXT-SRV-ATTR:instance_name" : "instance-0000000a", - "OS-SRV-USG:terminated_at" : "", - "accessIPv6" : "", - "config_drive" : "", - "OS-DCF:diskConfig" : "AUTO", - "updated" : "2018-03-27T02:17:12Z", - "metadata" : {}, - "id" : "12f5b1d0-fe5c-469f-a7d4-b62a91134bf8", - "flavor" : { - "id" : "60edb520-5826-4ae7-9e07-709b19ba6f39", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/flavors/60edb520-5826-4ae7-9e07-709b19ba6f39" - } - ] - }, - "links" : [ - { - "rel" : "self", - "href" : "http://192.168.100.100:8774/v2.1/ad979139d5ea4a84b21b3620c0e4761e/servers/12f5b1d0-fe5c-469f-a7d4-b62a91134bf8" - }, - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/servers/12f5b1d0-fe5c-469f-a7d4-b62a91134bf8" - } - ], - "OS-EXT-SRV-ATTR:host" : "compute-0", - "OS-EXT-AZ:availability_zone" : "nova", - "name" : "test1", - "wrs-res:pci_devices" : "", - "hostId" : "b3479a460f5effda10c6fdb860e824be631026c1d09f551479180577", - "user_id" : "777155411f3042c9b7e3194188d6f85d", - "status" : "PAUSED", - "OS-EXT-STS:power_state" : 3, - "OS-EXT-SRV-ATTR:hypervisor_hostname" : "compute-0", - "tenant_id" : "ad979139d5ea4a84b21b3620c0e4761e", - "OS-SRV-USG:launched_at" : "2018-03-27T02:16:40.000000", - "OS-EXT-STS:vm_state" : "paused", - "wrs-if:nics" : [ - { - "nic1" : { - "mac_address" : "fa:16:3e:5f:1a:76", - "network" : "mgmt", - "port_id" : "6c225c23-abe3-42a8-8909-83471503d5d4", - "vif_model" : "virtio", - "vif_pci_address" : "", - "mtu" : 9216 - } - }, - { - "nic2" : { - "mac_address" : "fa:16:3e:7c:7b:d7", - "network" : "data0", - "port_id" : "cbea2fec-c9b8-48ec-a964-0e3e255841bc", - "vif_model" : "virtio", - "vif_pci_address" : "", - "mtu" : 9216 - } - } - ], - "wrs-sg:server_group" : "", - "OS-EXT-STS:task_state" : "", - "wrs-res:topology" : "node:0, 1024MB, pgsize:2M, 1s,1c,2t, vcpus:0,1, pcpus:5,21, siblings:{0,1}, pol:ded, thr:pre\nnode:1, 1024MB, pgsize:2M, 1s,1c,2t, vcpus:2,3, pcpus:8,24, siblings:{2,3}, pol:ded, thr:pre", - "wrs-res:vcpus" : [ - 4, - 4, - 4 - ], - "key_name" : "", - "image" : { - "id" : "7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/images/7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb" - } - ] - }, - "created" : "2018-03-27T02:16:32Z", - "addresses" : { - "data0" : [ - { - "OS-EXT-IPS:type" : "fixed", - "version" : 4, - "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:7c:7b:d7", - "addr" : "192.168.2.8" - } - ], - "mgmt" : [ - { - "OS-EXT-IPS:type" : "fixed", - "version" : 4, - "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:5f:1a:76", - "addr" : "192.168.1.6" - } - ] - }, - "os-extended-volumes:volumes_attached" : [] - }, - { - "accessIPv4" : "", - "OS-EXT-SRV-ATTR:instance_name" : "instance-00000009", - "OS-SRV-USG:terminated_at" : "", - "accessIPv6" : "", - "config_drive" : "", - "OS-DCF:diskConfig" : "AUTO", - "updated" : "2018-03-27T02:12:21Z", - "metadata" : {}, - "id" : "3f1b0375-a1db-4d94-b336-f32c82c0d7ec", - "flavor" : { - "id" : "0d3b1381-1626-4f6b-869b-4a4d5d42085e", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/flavors/0d3b1381-1626-4f6b-869b-4a4d5d42085e" - } - ] - }, - "links" : [ - { - "rel" : "self", - "href" : "http://192.168.100.100:8774/v2.1/ad979139d5ea4a84b21b3620c0e4761e/servers/3f1b0375-a1db-4d94-b336-f32c82c0d7ec" - }, - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/servers/3f1b0375-a1db-4d94-b336-f32c82c0d7ec" - } - ], - "OS-EXT-SRV-ATTR:host" : "compute-0", - "OS-EXT-AZ:availability_zone" : "nova", - "name" : "test2", - "wrs-res:pci_devices" : "", - "hostId" : "b3479a460f5effda10c6fdb860e824be631026c1d09f551479180577", - "user_id" : "777155411f3042c9b7e3194188d6f85d", - "status" : "ACTIVE", - "OS-EXT-STS:power_state" : 1, - "OS-EXT-SRV-ATTR:hypervisor_hostname" : "compute-0", - "tenant_id" : "ad979139d5ea4a84b21b3620c0e4761e", - "OS-SRV-USG:launched_at" : "2018-03-27T02:12:21.000000", - "OS-EXT-STS:vm_state" : "active", - "wrs-if:nics" : [ - { - "nic1" : { - "mac_address" : "fa:16:3e:54:f8:a6", - "network" : "mgmt", - "port_id" : "30e2f51c-4473-4650-9ae9-a35e5d7ad452", - "vif_model" : "avp", - "vif_pci_address" : "", - "mtu" : 9216 - } - } - ], - "wrs-sg:server_group" : "", - "OS-EXT-STS:task_state" : "", - "wrs-res:topology" : "node:0, 4096MB, pgsize:2M, 1s,3c,1t, vcpus:0-2, pcpus:4,20,7, pol:ded, thr:pre", - "progress" : 0, - "wrs-res:vcpus" : [ - 3, - 3, - 3 - ], - "key_name" : "", - "image" : { - "id" : "7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/images/7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb" - } - ] - }, - "created" : "2018-03-27T02:10:26Z", - "addresses" : { - "mgmt" : [ - { - "OS-EXT-IPS:type" : "fixed", - "version" : 4, - "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:54:f8:a6", - "addr" : "192.168.1.11" - } - ] - }, - "os-extended-volumes:volumes_attached" : [] - }, - { - "accessIPv4" : "", - "OS-EXT-SRV-ATTR:instance_name" : "instance-00000008", - "OS-SRV-USG:terminated_at" : "", - "accessIPv6" : "", - "config_drive" : "", - "OS-DCF:diskConfig" : "AUTO", - "updated" : "2018-03-27T02:12:15Z", - "metadata" : {}, - "id" : "1b6f6671-b680-42cd-89e9-fc4ddd5d2e02", - "flavor" : { - "id" : "0d3b1381-1626-4f6b-869b-4a4d5d42085e", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/flavors/0d3b1381-1626-4f6b-869b-4a4d5d42085e" - } - ] - }, - "links" : [ - { - "rel" : "self", - "href" : "http://192.168.100.100:8774/v2.1/ad979139d5ea4a84b21b3620c0e4761e/servers/1b6f6671-b680-42cd-89e9-fc4ddd5d2e02" - }, - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/servers/1b6f6671-b680-42cd-89e9-fc4ddd5d2e02" - } - ], - "OS-EXT-SRV-ATTR:host" : "compute-0", - "OS-EXT-AZ:availability_zone" : "nova", - "name" : "test3", - "wrs-res:pci_devices" : "", - "hostId" : "b3479a460f5effda10c6fdb860e824be631026c1d09f551479180577", - "user_id" : "777155411f3042c9b7e3194188d6f85d", - "status" : "ACTIVE", - "OS-EXT-STS:power_state" : 1, - "OS-EXT-SRV-ATTR:hypervisor_hostname" : "compute-0", - "tenant_id" : "ad979139d5ea4a84b21b3620c0e4761e", - "OS-SRV-USG:launched_at" : "2018-03-27T02:12:15.000000", - "OS-EXT-STS:vm_state" : "active", - "wrs-if:nics" : [ - { - "nic1" : { - "mac_address" : "fa:16:3e:4e:9b:75", - "network" : "mgmt", - "port_id" : "72d13987-1d94-4a64-aa1a-973869ae1cad", - "vif_model" : "avp", - "vif_pci_address" : "", - "mtu" : 9216 - } - } - ], - "wrs-sg:server_group" : "", - "OS-EXT-STS:task_state" : "", - "wrs-res:topology" : "node:0, 4096MB, pgsize:2M, 1s,3c,1t, vcpus:0-2, pcpus:19,3,22, pol:ded, thr:pre", - "progress" : 0, - "wrs-res:vcpus" : [ - 3, - 3, - 3 - ], - "key_name" : "", - "image" : { - "id" : "7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb", - "links" : [ - { - "rel" : "bookmark", - "href" : "http://192.168.100.100:8774/ad979139d5ea4a84b21b3620c0e4761e/images/7ba636ef-5dfd-4e67-ad32-cd23ee74e1eb" - } - ] - }, - "created" : "2018-03-27T02:10:01Z", - "addresses" : { - "mgmt" : [ - { - "OS-EXT-IPS:type" : "fixed", - "version" : 4, - "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:4e:9b:75", - "addr" : "192.168.1.8" - } - ] - }, - "os-extended-volumes:volumes_attached" : [] - } - ] -} - -SUCCESS_VMSTATE_RESPONSE = { -'result':[ - { - 'name': 'test1', - 'power_state': 3, - 'id': '12f5b1d0-fe5c-469f-a7d4-b62a91134bf8', - 'state': 'paused', - 'tenant_id': 'ad979139d5ea4a84b21b3620c0e4761e', - 'host': 'compute-0', - 'availability_zone': 'nova', - 'launched_at': '2018-03-27T02:16:40.000000' - }, - { - 'name': 'test2', - 'power_state': 1, - 'id': '3f1b0375-a1db-4d94-b336-f32c82c0d7ec', - 'state': 'active', - 'tenant_id': 'ad979139d5ea4a84b21b3620c0e4761e', - 'host': 'compute-0', - 'availability_zone': 'nova', - 'launched_at': '2018-03-27T02:12:21.000000' - }, - { - 'name': 'test3', - 'power_state': 1, - 'id': '1b6f6671-b680-42cd-89e9-fc4ddd5d2e02', - 'state': 'active', - 'tenant_id': 'ad979139d5ea4a84b21b3620c0e4761e', - 'host': 'compute-0', - 'availability_zone': 'nova', - 'launched_at': '2018-03-27T02:12:15.000000' - } - ] -} - -class TestEvents(test_base.TestRequest): - def setUp(self): - super(TestEvents, self).setUp() - - def _get_mock_response(self, return_value=None): - mock_response = mock.Mock(spec=test_base.MockResponse) - mock_response.status_code = status.HTTP_200_OK - mock_response.json.return_value = return_value - return mock_response - - @mock.patch.object(VimDriverUtils, 'get_session') - @mock.patch.object(VimDriverUtils, 'get_vim_info') - def test_events_check_success(self, mock_get_vim_info, mock_get_session): - mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO - mock_get_session.return_value = test_base.get_mock_session( - ["get"], { - "side_effect": [ - self._get_mock_response(MOCK_GET_SERVERS_DETAIL_RESPONSE), - ] - }) - - response = self.client.post( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/events_check", - HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - - self.assertEquals(status.HTTP_200_OK, response.status_code) - self.assertEqual(SUCCESS_VMSTATE_RESPONSE, response.data) diff --git a/windriver/titanium_cloud/resource/views/events.py b/windriver/titanium_cloud/resource/views/events.py deleted file mode 100644 index c65a188f..00000000 --- a/windriver/titanium_cloud/resource/views/events.py +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright (c) 2017-2018 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. -# 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 logging -import json -import traceback - -from rest_framework import status - -from django.conf import settings -from common.exceptions import VimDriverNewtonException -from newton_base.util import VimDriverUtils - -from keystoneauth1.exceptions import HttpError -from rest_framework import status -from rest_framework.response import Response -from rest_framework.views import APIView -from common.msapi import extsys - - -logger = logging.getLogger(__name__) - - -class EventsCheck(APIView): - - def __init__(self): - self._logger = logger - - def post(self, request, vimid=""): - self._logger.info("vimid, data> %s, %s" % (vimid, request.data)) - self._logger.debug("META> %s" % request.META) - - try : - resource_demand = request.data - - tenant_name = None - vim = VimDriverUtils.get_vim_info(vimid) - sess = VimDriverUtils.get_session(vim, tenant_name) - - # get token: - cloud_owner, regionid = extsys.decode_vim_id(vimid) - interface = 'public' - service = {'service_type': 'compute', - 'interface': interface, - 'region_id': vim['openstack_region_id'] - if vim.get('openstack_region_id') - else vim['cloud_region_id'] - } - - # get servers detail info - req_resouce = "/servers/detail" - self._logger.info("check servers detail> URI:%s" % req_resouce) - resp = sess.get(req_resouce, endpoint_filter=service) - self._logger.info("check servers detail> status:%s" % resp.status_code) - content = resp.json() - self._logger.debug("check servers detail> resp data:%s" % content) - - # extract server status info - if len(content['servers']): - servers = content['servers'] - resp_vmstate = [] - for num in range(0, len(servers)): - vmstate = { - 'name' : servers[num]['name'], - 'state' : servers[num]['OS-EXT-STS:vm_state'], - 'power_state' : servers[num]['OS-EXT-STS:power_state'], - 'launched_at' : servers[num]['OS-SRV-USG:launched_at'], - 'id' : servers[num]['id'], - 'host' : servers[num]['OS-EXT-SRV-ATTR:host'], - 'availability_zone' : servers[num]['OS-EXT-AZ:availability_zone'], - 'tenant_id' : servers[num]['tenant_id'] - } - - resp_vmstate.append(vmstate) - - self._logger.info("RESP with data> result:%s" % resp_vmstate) - return Response(data={'result': resp_vmstate}, status=status.HTTP_200_OK) - - except VimDriverNewtonException as e: - self._logger.error("Plugin exception> status:%s,error:%s" - % (e.status_code, e.content)) - return Response(data={'result': resp_vmstate,'error': e.content}, status=e.status_code) - - except HttpError as e: - self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) - resp = e.response.json() - resp.update({'result': resp_vmstate}) - return Response(data=e.response.json(), status=e.http_status) - - except Exception as e: - self._logger.error(traceback.format_exc()) - return Response(data={'result': resp_vmstate, 'error': str(e)}, - status=status.HTTP_500_INTERNAL_SERVER_ERROR) - diff --git a/windriver/titanium_cloud/settings.py b/windriver/titanium_cloud/settings.py index adfa4930..6cf162a1 100644 --- a/windriver/titanium_cloud/settings.py +++ b/windriver/titanium_cloud/settings.py @@ -97,10 +97,10 @@ MSB_SERVICE_ADDR = os.environ.get('MSB_ADDR', DEFAULT_MSB_ADDR) MSB_SERVICE_PORT = os.environ.get('MSB_PORT', "80") #[Multicloud] -MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-titanium_cloud/v0" % ( +MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-titaniumcloud/v0" % ( MSB_SERVICE_ADDR, MSB_SERVICE_PORT) -MULTICLOUD_API_V1_PREFIX = "http://%s:%s/api/multicloud-titanium_cloud/v1" % ( +MULTICLOUD_API_V1_PREFIX = "http://%s:%s/api/multicloud-titaniumcloud/v1" % ( MSB_SERVICE_ADDR, MSB_SERVICE_PORT) # [A&AI] @@ -113,12 +113,12 @@ AAI_PASSWORD = os.environ.get('AAI_PASSWORD', "AAI") AAI_BASE_URL = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION) -MULTICLOUD_APP_ID = 'MultiCloud-Titanium_Cloud' +MULTICLOUD_APP_ID = 'MultiCloud-TitaniumCloud' # [IMAGE LOCAL PATH] ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -OPENSTACK_VERSION = "titanium_cloud" +OPENSTACK_VERSION = "titaniumcloud" MULTIVIM_VERSION = "multicloud-" + OPENSTACK_VERSION diff --git a/windriver/titanium_cloud/swagger/tests.py b/windriver/titanium_cloud/swagger/tests.py index 83fe5409..fde26217 100644 --- a/windriver/titanium_cloud/swagger/tests.py +++ b/windriver/titanium_cloud/swagger/tests.py @@ -26,7 +26,7 @@ class SampleViewTest(unittest.TestCase): pass def test_sample(self): - response = self.client.get("/api/multicloud-titanium_cloud/v0/swagger.json") + response = self.client.get("/api/multicloud-titaniumcloud/v0/swagger.json") self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) # resp_data = response.json() # self.assertEqual({"status": "active"}, resp_data) diff --git a/windriver/titanium_cloud/swagger/urls.py b/windriver/titanium_cloud/swagger/urls.py index 723777dc..38573d58 100644 --- a/windriver/titanium_cloud/swagger/urls.py +++ b/windriver/titanium_cloud/swagger/urls.py @@ -15,10 +15,24 @@ from django.conf.urls import patterns, url from rest_framework.urlpatterns import format_suffix_patterns +from titanium_cloud.swagger.views import SwaggerJsonViewDepreciated +from titanium_cloud.swagger.views import APIv1SwaggerJsonViewDepreciated from titanium_cloud.swagger.views import SwaggerJsonView +from titanium_cloud.swagger.views import APIv1SwaggerJsonView urlpatterns = [ - url(r'^api/multicloud-titanium_cloud/v0/swagger.json$', SwaggerJsonView.as_view()), + # API v0, depreciated + url(r'^api/multicloud-titanium_cloud/v0/swagger.json$', SwaggerJsonViewDepreciated.as_view()), + + # API v1, depreciated + url(r'^api/multicloud-titanium_cloud/v1/swagger.json$', APIv1SwaggerJsonViewDepreciated.as_view()), + + # API v0, new namespace: MULTICLOUD-335 + url(r'^api/multicloud-titaniumcloud/v0/swagger.json$', SwaggerJsonView.as_view()), + + # API v1, new namespace: MULTICLOUD-335 + url(r'^api/multicloud-titaniumcloud/v1/swagger.json$', APIv1SwaggerJsonView.as_view()), + ] urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/windriver/titanium_cloud/swagger/views.py b/windriver/titanium_cloud/swagger/views.py index e912b751..6829714b 100644 --- a/windriver/titanium_cloud/swagger/views.py +++ b/windriver/titanium_cloud/swagger/views.py @@ -27,6 +27,45 @@ from newton_base.swagger import views as newton_json_view logger = logging.getLogger(__name__) +class SwaggerJsonViewDepreciated(newton_json_view.SwaggerJsonView): + + def get(self, request): + ''' + reuse newton code and update the basePath + :param request: + :return: + ''' + + resp = super(SwaggerJsonViewDepreciated,self).get(request) + json_data = resp.data if resp else None + if json_data: + json_data["basePath"] = "/api/multicloud-titanium_cloud/v0/" + json_data["info"]["title"] = "Depreciated Service NBI of MultiCloud plugin for Titanium Cloud" + return Response(data=json_data, status=200) + else: + return Response(data={'error':'internal error'}, status=500) + + + +class APIv1SwaggerJsonViewDepreciated(newton_json_view.SwaggerJsonView): + + def get(self, request): + ''' + reuse newton code and update the basePath + :param request: + :return: + ''' + + resp = super(APIv1SwaggerJsonViewDepreciated,self).get(request) + json_data = resp.data if resp else None + if json_data: + json_data["basePath"] = "/api/multicloud-titanium_cloud/v1/" + json_data["info"]["title"] = "Depreciated Service NBI v1 of MultiCloud plugin for Titanium Cloud" + return Response(data=json_data, status=200) + else: + return Response(data={'error':'internal error'}, status=500) + + class SwaggerJsonView(newton_json_view.SwaggerJsonView): def get(self, request): @@ -39,10 +78,27 @@ class SwaggerJsonView(newton_json_view.SwaggerJsonView): resp = super(SwaggerJsonView,self).get(request) json_data = resp.data if resp else None if json_data: - json_data["basePath"] = "/api/multicloud-titanium_cloud/v0/" - json_data["info"]["title"] = "Service NBI of MultiCloud plugin for Titanium Cloud" + json_data["basePath"] = "/api/multicloud-titaniumcloud/v0/" + json_data["info"]["title"] = "Service NBI v0 of MultiCloud plugin for Titanium Cloud" return Response(data=json_data, status=200) else: return Response(data={'error':'internal error'}, status=500) +class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView): + + def get(self, request): + ''' + reuse newton code and update the basePath + :param request: + :return: + ''' + + resp = super(APIv1SwaggerJsonView,self).get(request) + json_data = resp.data if resp else None + if json_data: + json_data["basePath"] = "/api/multicloud-titaniumcloud/v1/" + json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Titanium Cloud" + return Response(data=json_data, status=200) + else: + return Response(data={'error':'internal error'}, status=500) diff --git a/windriver/titanium_cloud/urls.py b/windriver/titanium_cloud/urls.py index 3be252a6..da5f66a7 100644 --- a/windriver/titanium_cloud/urls.py +++ b/windriver/titanium_cloud/urls.py @@ -17,13 +17,14 @@ from django.conf.urls import include, url from titanium_cloud.registration.views import registration from newton_base.openoapi import tenants from titanium_cloud.resource.views import capacity -from titanium_cloud.resource.views import events from titanium_cloud.vesagent import vesagent_ctrl from titanium_cloud.resource.views import infra_workload urlpatterns = [ url(r'^', include('titanium_cloud.swagger.urls')), url(r'^', include('titanium_cloud.samples.urls')), + + # API v0, depreciated due to MULTICLOUD-335 url(r'^api/multicloud-titanium_cloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/registry/?$', registration.Registry.as_view()), url(r'^api/multicloud-titanium_cloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/?$', @@ -39,13 +40,10 @@ urlpatterns = [ # CapacityCheck url(r'^api/multicloud-titanium_cloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/capacity_check/?$', capacity.CapacityCheck.as_view()), - # events - url(r'^api/multicloud-titanium_cloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/events_check/?$', - events.EventsCheck.as_view()), url(r'^api/multicloud-titanium_cloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/vesagent/?$', vesagent_ctrl.VesAgentCtrl.as_view()), -#API upgrading + # API v1, depreciated due to MULTICLOUD-335 url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/registry/?$', registration.APIv1Registry.as_view()), url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/?$', @@ -61,13 +59,50 @@ urlpatterns = [ # CapacityCheck url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/capacity_check/?$', capacity.APIv1CapacityCheck.as_view()), - # events -# url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/events_check/?$', -# events.EventsCheck.as_view()), url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/vesagent/?$', vesagent_ctrl.APIv1VesAgentCtrl.as_view()), url(r'^api/multicloud-titanium_cloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$', infra_workload.APIv1InfraWorkload.as_view()), + + # API v0, new namespace due to MULTICLOUD-335 + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/registry/?$', + registration.Registry.as_view()), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/?$', + registration.Registry.as_view()), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/exten', + include('titanium_cloud.extensions.urls')), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/', + include('titanium_cloud.proxy.urls')), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/tenants/?$', + tenants.Tenants.as_view()), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/' + '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('titanium_cloud.requests.urls')), + # CapacityCheck + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/capacity_check/?$', + capacity.CapacityCheck.as_view()), + url(r'^api/multicloud-titaniumcloud/v0/(?P<vimid>[0-9a-zA-Z_-]+)/vesagent/?$', + vesagent_ctrl.VesAgentCtrl.as_view()), + + # API v1, new namespace due to MULTICLOUD-335 + url(r'^api/multicloud-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/registry/?$', + registration.APIv1Registry.as_view()), + url(r'^api/multicloud-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/?$', + registration.APIv1Registry.as_view()), + url(r'^api/multicloud-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/exten', + include('titanium_cloud.extensions.urlsV1')), + url(r'^api/multicloud-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/', + include('titanium_cloud.proxy.urlsV1')), + url(r'^api/multicloud-titaniumcloud/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-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/' + '(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('titanium_cloud.requests.urlsV1')), + # CapacityCheck + url(r'^api/multicloud-titaniumcloud/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-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/vesagent/?$', + vesagent_ctrl.APIv1VesAgentCtrl.as_view()), + url(r'^api/multicloud-titaniumcloud/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$', + infra_workload.APIv1InfraWorkload.as_view()), ] diff --git a/windriver/titanium_cloud/vesagent/tests.py b/windriver/titanium_cloud/vesagent/tests.py index 42d76950..1fb8d51b 100644 --- a/windriver/titanium_cloud/vesagent/tests.py +++ b/windriver/titanium_cloud/vesagent/tests.py @@ -59,7 +59,7 @@ class VesAgentCtrlTest(unittest.TestCase): mock_get_vim_by_id.return_value = MOCK_VIM_INFO mock_get.return_value = '{"backlogs": [{"backlog_uuid": "2b8f6ff8-bc64-339b-a714-155909db937f", "server_id": "c4b575fa-ed85-4642-ab4b-335cb5744721", "tenant_id": "0e148b76ee8c42f78d37013bf6b7b1ae", "api_method": "GET", "source": "onap-aaf", "api_link": "/onaplab_RegionOne/compute/v2.1/0e148b76ee8c42f78d37013bf6b7b1ae/servers/c4b575fa-ed85-4642-ab4b-335cb5744721", "domain": "fault", "type": "vm", "tenant": "VIM"}], "poll_interval_default": 10, "vimid": "onaplab_RegionOne", "subscription": {"username": "user", "password": "password", "endpoint": "http://127.0.0.1:9005/sample"}}' - response = self.client.get("/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/vesagent") + response = self.client.get("/api/multicloud-titaniumcloud/v0/windriver-hudson-dc_RegionOne/vesagent") self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) @mock.patch.object(vesagent_ctrl.VesAgentCtrl, 'buildBacklogsOneVIM') |