Add barebones dstat endpoint and URL mapping (currently only serving from

current directory)
This commit is contained in:
Tim Buckley 2015-07-30 17:16:16 -06:00
parent 0f81e65e5f
commit d496735a94
5 changed files with 34 additions and 1 deletions

View File

@ -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.

View File

@ -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'))
)

View File

@ -0,0 +1 @@
__author__ = 'tim'

View 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")

View 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()),
)