Add barebones dstat endpoint and URL mapping (currently only serving from
current directory)
This commit is contained in:
parent
0f81e65e5f
commit
d496735a94
@ -92,6 +92,8 @@ TEST_REPOSITORIES = [
|
||||
BASE_DIR
|
||||
]
|
||||
|
||||
DSTAT_CSV = 'dstat.log'
|
||||
|
||||
# If true, AJAX calls should attempt to load `*.json.gz` files rather than plain
|
||||
# `*.json` files. This should only ever be toggled `True` for static site
|
||||
# exports and is not currently supported on live servers.
|
||||
|
@ -12,5 +12,6 @@ urlpatterns = patterns('',
|
||||
url(r'^index.html$', IndexView.as_view(), name="index"),
|
||||
url(r'^tempest_', include('stackviz.views.tempest.urls')),
|
||||
url(r'^devstack_', include('stackviz.views.devstack.urls')),
|
||||
url(r'^upstream_', include ('stackviz.views.upstream.urls'))
|
||||
url(r'^upstream_', include ('stackviz.views.upstream.urls')),
|
||||
url(r'^dstat_', include ('stackviz.views.dstat.urls'))
|
||||
)
|
||||
|
1
stackviz/views/dstat/__init__.py
Normal file
1
stackviz/views/dstat/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__author__ = 'tim'
|
22
stackviz/views/dstat/api.py
Normal file
22
stackviz/views/dstat/api.py
Normal file
@ -0,0 +1,22 @@
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import View
|
||||
|
||||
from stackviz import settings
|
||||
|
||||
_cached_csv = None
|
||||
|
||||
|
||||
def _load_csv():
|
||||
global _cached_csv
|
||||
|
||||
if _cached_csv:
|
||||
return _cached_csv
|
||||
|
||||
with open(settings.DSTAT_CSV, 'r') as f:
|
||||
_cached_csv = f.readlines()
|
||||
return _cached_csv
|
||||
|
||||
|
||||
class DStatCSVEndpoint(View):
|
||||
def get(self, request):
|
||||
return HttpResponse(_load_csv(), content_type="text/csv")
|
7
stackviz/views/dstat/urls.py
Normal file
7
stackviz/views/dstat/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
|
||||
from .api import DStatCSVEndpoint
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^log.csv$', DStatCSVEndpoint.as_view()),
|
||||
)
|
Loading…
Reference in New Issue
Block a user