diff options
-rw-r--r-- | INFO.yaml | 2 | ||||
-rw-r--r-- | zte/vmanager/driver/interfaces/serializers.py | 33 | ||||
-rw-r--r-- | zte/vmanager/driver/interfaces/tests.py | 6 | ||||
-rw-r--r-- | zte/vmanager/driver/interfaces/urls.py | 3 | ||||
-rw-r--r-- | zte/vmanager/driver/interfaces/views.py | 9 | ||||
-rw-r--r-- | zte/vmanager/driver/swagger/tests.py | 31 |
6 files changed, 73 insertions, 11 deletions
@@ -26,7 +26,7 @@ meetings: server: 'n/a' channel: 'n/a' repeats: 'weekly' - time: '09:00 UTC' + time: '09:00 UTC/China 17:00' repositories: - 'vfc-gvnfm-vnflcm' - 'vfc-gvnfm-vnfmgr' diff --git a/zte/vmanager/driver/interfaces/serializers.py b/zte/vmanager/driver/interfaces/serializers.py index 1d518df1..069797f4 100644 --- a/zte/vmanager/driver/interfaces/serializers.py +++ b/zte/vmanager/driver/interfaces/serializers.py @@ -288,7 +288,10 @@ class NotifyVmlistSerializer(serializers.Serializer): allow_null=True) VMIDlist = serializers.ListSerializer( help_text='VMIDlist', - child=VMIDlistSerializer(help_text='VMIDlist', required=True, allow_null=True), + child=VMIDlistSerializer( + help_text='VMIDlist', + required=True, + allow_null=True), required=False, allow_null=True) @@ -330,16 +333,19 @@ class NotifyReqSerializer(serializers.Serializer): many=True) extension = serializers.DictField( help_text="extension", - child=serializers.DictField(allow_null=True), + child=serializers.DictField( + allow_null=True), required=False, allow_null=True) affectedcp = serializers.ListSerializer( help_text='affectedcp', - child=serializers.DictField(allow_null=True), + child=serializers.DictField( + allow_null=True), required=False) affectedvirtuallink = serializers.ListSerializer( help_text='affectedvirtuallink', - child=serializers.DictField(allow_null=True), + child=serializers.DictField( + allow_null=True), required=False) @@ -361,7 +367,8 @@ class ScaleReqSerializer(serializers.Serializer): allow_null=True) additionalParam = serializers.DictField( help_text="additionalParam", - child=serializers.DictField(allow_null=True), + child=serializers.DictField( + allow_null=True), required=False, allow_null=True) @@ -394,7 +401,8 @@ class AffectedvmSerializer(serializers.Serializer): allow_null=True) flavour = serializers.DictField( help_text="flavour", - child=serializers.CharField(allow_blank=True), + child=serializers.CharField( + allow_blank=True), required=False, allow_null=True) @@ -417,7 +425,10 @@ class HealReqSerializer(serializers.Serializer): allow_null=True) affectedvm = serializers.ListSerializer( help_text='affectedvm', - child=AffectedvmSerializer(help_text='affectedvm', required=True, allow_null=True), + child=AffectedvmSerializer( + help_text='affectedvm', + required=True, + allow_null=True), required=True, allow_null=True) @@ -524,12 +535,16 @@ class VnfPkgSerializer(serializers.Serializer): allow_null=True) imagefiles = serializers.ListSerializer( help_text='imagefiles', - child=serializers.CharField(help_text='imagefile', required=True), + child=serializers.CharField( + help_text='imagefile', + required=True), required=False, allow_null=True) swfiles = serializers.ListSerializer( help_text='swfiles', - child=serializers.CharField(help_text='swfile', required=True), + child=serializers.CharField( + help_text='swfile', + required=True), required=False, allow_null=True) description = serializers.CharField( diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py index 5e975f04..ead550b7 100644 --- a/zte/vmanager/driver/interfaces/tests.py +++ b/zte/vmanager/driver/interfaces/tests.py @@ -486,6 +486,12 @@ class InterfacesTest(TestCase): self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) self.assertDictEqual(job_info, response.data) + def test_health_check(self): + response = self.client.get("/api/ztevnfmdriver/v1/health_check") + self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) + resp_data = json.loads(response.content) + self.assertEqual({"status": "active"}, resp_data) + notify_req_data = {"vnfinstanceid": "1", "nfvoid": "3", diff --git a/zte/vmanager/driver/interfaces/urls.py b/zte/vmanager/driver/interfaces/urls.py index 9732cacd..3a966df3 100644 --- a/zte/vmanager/driver/interfaces/urls.py +++ b/zte/vmanager/driver/interfaces/urls.py @@ -37,5 +37,6 @@ urlpatterns = [ url(r'^api/ztevnfmdriver/v1/vnfpkgs$', views.VnfPkgs.as_view(), name='VnfPkgs'), url(r'^api/ztevnfmdriver/v1/vnfpkgs/(?P<packageId>[0-9a-zA-Z\-\_]+)/(?P<fileName>[0-9a-zA-Z\.\-\_]+)$', views.VnfPkg.as_view(), name='VnfPkg'), url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/nfvo/info$', views.NfvoInfo.as_view(), name='NfvoInfo'), - url(r'^samples/$', views.SampleList.as_view(), name='samples') + url(r'^samples/$', views.SampleList.as_view(), name='samples'), + url(r'^api/ztevnfmdriver/v1/health_check$', views.HealthCheckView.as_view()), ] diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index d3c5a831..b981c9a1 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -748,3 +748,12 @@ class NfvoInfo(APIView): return Response(data={'error': ret[1]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) logger.debug("update nfvo info successfully.") return Response(data={}, status=status.HTTP_200_OK) + + +class HealthCheckView(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: 'Active'}) + def get(self, request, format=None): + logger.debug("HealthCheck") + return Response({"status": "active"}) diff --git a/zte/vmanager/driver/swagger/tests.py b/zte/vmanager/driver/swagger/tests.py new file mode 100644 index 00000000..1951e070 --- /dev/null +++ b/zte/vmanager/driver/swagger/tests.py @@ -0,0 +1,31 @@ +# Copyright (C) 2019 ZTE. All Rights Reserved +# +# 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. + +from django.test import TestCase +from django.test import Client +from rest_framework import status + + +class TestSwagger(TestCase): + def setUp(self): + self.client = Client() + + def tearDown(self): + pass + + def test_swagger_json(self): + url = "/api/ztevnfmdriver/v1/swagger.json" + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual("2.0", response.data.get("swagger")) |