summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-03 10:32:41 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-03 10:32:41 +0800
commitbe9d4b1b48403621b4c20f9c61f56314539df5ae (patch)
tree6bf28adacb2ac8520bc32c819ba5db717b9f421f /lcm
parent7bda307b801ca52bfd6693b4115530647b5c58b0 (diff)
Add health check api
Change-Id: I37953990d85e954959f578a1018311109656a45f Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/samples/tests.py14
-rw-r--r--lcm/lcm/samples/urls.py1
-rw-r--r--lcm/lcm/samples/views.py9
3 files changed, 24 insertions, 0 deletions
diff --git a/lcm/lcm/samples/tests.py b/lcm/lcm/samples/tests.py
index 688e27cf..9f1069d2 100644
--- a/lcm/lcm/samples/tests.py
+++ b/lcm/lcm/samples/tests.py
@@ -390,3 +390,17 @@ class SampleViewTest(unittest.TestCase):
r0_data_delete]
resp = self.client.post(term_res_url, data=json.dumps(term_res_data), content_type='application/json')
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, resp.status_code)
+
+
+class HealthCheckViewTest(unittest.TestCase):
+ def setUp(self):
+ self.client = APIClient()
+
+ def tearDown(self):
+ pass
+
+ def test_health_check(self):
+ response = self.client.get("/api/vnflcm/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)
diff --git a/lcm/lcm/samples/urls.py b/lcm/lcm/samples/urls.py
index b468e27f..a8b37c39 100644
--- a/lcm/lcm/samples/urls.py
+++ b/lcm/lcm/samples/urls.py
@@ -18,4 +18,5 @@ from lcm.samples import views
urlpatterns = [
url(r'^api/vnflcm/v1/resources/(?P<action_type>(inst|term)+)$', views.ResourceList.as_view()),
url(r'^samples/$', views.SampleList.as_view()),
+ url(r'^api/vnflcm/v1/health_check$', views.HealthCheckView.as_view())
]
diff --git a/lcm/lcm/samples/views.py b/lcm/lcm/samples/views.py
index de4e1bdd..86b4b8ab 100644
--- a/lcm/lcm/samples/views.py
+++ b/lcm/lcm/samples/views.py
@@ -49,3 +49,12 @@ class ResourceList(APIView):
# ResDeleteThread(request.data).start()
adaptor.delete_vim_res(request.data, self.do_notify)
return Response(data=None, status=status.HTTP_204_NO_CONTENT)
+
+
+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"})