summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
authorliangke <lokyse@163.com>2018-03-29 17:48:43 +0800
committerliangke <lokyse@163.com>2018-03-29 21:23:50 +0800
commit0f1d8b698315524b7f4607302f66a81470dc7e32 (patch)
treebd4416a34842df3fad45a6c5031fc26a9edcb1d6 /vio
parenta3a72fdef2523e8959bf0a86df49485822905d37 (diff)
Fetch output of logging
Change-Id: I9599e838e48103a4f9a21cd3c159a5b2d0a90ce0 Issue-ID: MULTICLOUD-152 Signed-off-by: liangke <lokyse@163.com>
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/samples/tests.py2
-rw-r--r--vio/vio/samples/views.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/vio/vio/samples/tests.py b/vio/vio/samples/tests.py
index 0dd2731..910ded6 100644
--- a/vio/vio/samples/tests.py
+++ b/vio/vio/samples/tests.py
@@ -28,4 +28,4 @@ class SampleViewTest(unittest.TestCase):
self.assertEqual(status.HTTP_200_OK,
response.status_code, response.content)
resp_data = json.loads(response.content)
- self.assertEqual({"status": "active"}, resp_data)
+ self.assertEqual("active", resp_data["status"])
diff --git a/vio/vio/samples/views.py b/vio/vio/samples/views.py
index 36670d1..4775e78 100644
--- a/vio/vio/samples/views.py
+++ b/vio/vio/samples/views.py
@@ -10,12 +10,14 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+import os
import logging
from rest_framework.views import APIView
from rest_framework.response import Response
logger = logging.getLogger(__name__)
+log_file = "/var/log/onap/multicloud/vio/vio.log"
class SampleList(APIView):
@@ -25,4 +27,9 @@ class SampleList(APIView):
def get(self, request, format=None):
logger.debug("get")
- return Response({"status": "active"})
+ output = ""
+ if os.path.exists(log_file):
+ with open("/var/log/onap/multicloud/vio/vio.log", "r") as f:
+ lines = f.readlines()
+ output = lines[-1]
+ return Response({"status": "active", "logs": output})