Adoption of base framework code for azure plugin
[multicloud/azure.git] / azure / azure / samples / views.py
1 # Copyright (c) 2018 Amdocs
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13 import os
14 import logging
15
16 from rest_framework.views import APIView
17 from rest_framework.response import Response
18
19 logger = logging.getLogger(__name__)
20 log_file = "/var/log/onap/multicloud/azure/azure.log"
21
22
23 class SampleList(APIView):
24     """
25     List all samples.
26     """
27
28     def get(self, request, format=None):
29         logger.debug("get")
30         output = ""
31         if os.path.exists(log_file):
32             with open("/var/log/onap/multicloud/azure/azure.log", "r") as f:
33                 lines = f.readlines()
34                 output = lines[-1]
35         return Response({"status": "active", "logs": output})