rbmd_django/rbmd/views.py

52 lines
1.1 KiB
Python
Raw Normal View History

2017-08-31 00:52:20 +03:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import HttpResponse
from django.shortcuts import render
import json
import requests
2017-08-31 18:10:08 +03:00
def get_status():
with open('conf.json') as conf:
status = json.load(conf)["api"] + '/status'
try: res = requests.get(status)
except: res = 'connection can\'t be established'
return res.content
2017-08-31 00:52:20 +03:00
2017-08-31 18:10:08 +03:00
def node():
pass
2017-08-31 00:52:20 +03:00
2017-08-31 18:10:08 +03:00
def health():
pass
2017-08-31 00:52:20 +03:00
def mount():
pass
def unmount():
pass
2017-08-31 18:10:08 +03:00
def resolve():
pass
def get_metrics():
#with open('conf.json') as conf:
# api = json.load(conf)["api"]
#try: res = requests.get(api + metrics)
#return api
with open('conf.json') as conf:
metrics = json.load(conf)["api"] + '/metrics'
res = requests.get(metrics)
print res
#except: res = 'connection can\'t be established'
return res.content
def panel(request):
with open('conf.json') as conf:
ws = json.load(conf)["ws"]
metrics = json.loads(get_metrics())
status = get_status()
return render(request, 'rbmd/index.html', {'ws' : ws, 'metrics' : metrics, 'status' : status})