summaryrefslogtreecommitdiffstats
path: root/zte/vmanager
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-05 08:43:04 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-05 08:43:04 +0800
commit9a568741d8b862d5f2e0374373b64049d7703452 (patch)
treefd852abbe232d096ce6e02b17d2c75b5e80c2537 /zte/vmanager
parent62404b34213b1c30b06220b3c96fcfff20f004a3 (diff)
Add health check for ztevnfmdriver
Change-Id: I34153d348348ecb13584957514ff219100658851 Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'zte/vmanager')
-rw-r--r--zte/vmanager/driver/interfaces/tests.py6
-rw-r--r--zte/vmanager/driver/interfaces/urls.py3
-rw-r--r--zte/vmanager/driver/interfaces/views.py9
3 files changed, 17 insertions, 1 deletions
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"})