summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Ates <mates@entrouvert.com>2016-01-22 16:22:47 (GMT)
committerMikaël Ates <mates@entrouvert.com>2016-01-22 16:22:47 (GMT)
commit8a302b1ce6d4bd97c6b38cd62179380cc2773fb9 (patch)
tree935be96819971c2bf829444cb7f3226f3d0f5b63
parenta9b2a56973bccf7e267a5ab42432b8bfb2c5ea2d (diff)
downloadbiomon-8a302b1ce6d4bd97c6b38cd62179380cc2773fb9.zip
biomon-8a302b1ce6d4bd97c6b38cd62179380cc2773fb9.tar.gz
biomon-8a302b1ce6d4bd97c6b38cd62179380cc2773fb9.tar.bz2
Add a proxy view to the json config endpoint of rfiddrivers.
-rw-r--r--src/biomon/urls.py1
-rw-r--r--src/biomon/views.py19
2 files changed, 20 insertions, 0 deletions
diff --git a/src/biomon/urls.py b/src/biomon/urls.py
index 25955ae..cb687f6 100644
--- a/src/biomon/urls.py
+++ b/src/biomon/urls.py
@@ -53,6 +53,7 @@ urlpatterns += (
urlpatterns += (
url(r'^readers/$', login_required(views.ReaderList.as_view()), name='reader_list'),
+ url(r'^readers/(?P<pk>\d+)/$', login_required(views.ReaderConfig.as_view()), name='reader_config'),
url(r'^reader/add/$', login_required(views.ReaderCreate.as_view()), name='reader_add'),
url(r'^reader/(?P<pk>\d+)/$', login_required(views.ReaderUpdate.as_view()), name='reader_update'),
url(r'^reader/(?P<pk>\d+)/delete/$', login_required(views.ReaderDelete.as_view()), name='reader_delete'),
diff --git a/src/biomon/views.py b/src/biomon/views.py
index e175fba..971b1f4 100644
--- a/src/biomon/views.py
+++ b/src/biomon/views.py
@@ -349,3 +349,22 @@ class ReaderDelete(DeleteView):
except:
pass
return context
+
+
+class ReaderConfig(View):
+ def get(self, request, *args, **kwargs):
+ reader = get_object_or_404(models.Reader,
+ id=kwargs.get('pk', None))
+ infos = {'status' : 'unknown'}
+ target = "http://{}:{}/config".format(reader.ip_address,
+ reader.management_port)
+ response = None
+ try:
+ response = requests.get(target)
+ except requests.ConnectionError:
+ infos['status'] = 'disconnected'
+ else:
+ infos['status'] = 'connected'
+ if response.status_code != 404:
+ infos['config'] = response.json()
+ return JsonResponse(infos)