Skip to contentSkip to conversation

toaster: enable remote HTTP API for status aggregation

PATCH New David Reyna 1 participant 1 message Jul 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: enable remote HTTP API for status aggregation

From: David Reyna <[email protected]>

Add support for Toaster aggregators with a set of api links that return JSON data for (a) builds in progress, (b) builds completed,
(c) specific build stata, and (d) an is-alive health ping link.

[YOCTO #11794]

---
 .../lib/toaster/toastergui/templates/health.html   |  6 ++
 bitbake/lib/toaster/toastergui/urls.py             |  7 +-
 bitbake/lib/toaster/toastergui/views.py            | 86 +++++++++++++++++++++-
 bitbake/lib/toaster/toastermain/urls.py            |  5 +-
 4 files changed, 100 insertions(+), 4 deletions(-)
 create mode 100644 bitbake/lib/toaster/toastergui/templates/health.html
bitbake/lib/toaster/toastergui/templates/health.html new file +6 -0
new file mode 100644
index 0000000..f17fdbc
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head><title>Toaster Health</title></head>
+  <body>Ok</body>
+</html>
+
bitbake/lib/toaster/toastergui/urls.py +6 -1
index 6aebc3f..3ad5566 100644
@@ -244,6 +244,11 @@ urlpatterns = [
         url(r'^mostrecentbuilds$', widgets.MostRecentBuildsView.as_view(),
             name='most_recent_builds'),
 
-          # default redirection
+        # JSON data for aggregators
+        url(r'^api/builds$', views.json_builds, name='json_builds'),
+        url(r'^api/building$', views.json_building, name='json_building'),
+        url(r'^api/build/(?P<build_id>\d+)$', views.json_build, name='json_build'),
+
+        # default redirection
         url(r'^$', RedirectView.as_view(url='landing', permanent=True)),
 ]
bitbake/lib/toaster/toastergui/views.py +85 -1

101 lines not on this page · raw message

bitbake/lib/toaster/toastermain/urls.py +3 -2
index bb32559..6750bdf 100644
@@ -20,9 +20,8 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 from django.conf.urls import patterns, include, url
-from django.views.generic import RedirectView
+from django.views.generic import RedirectView, TemplateView
 from django.views.decorators.cache import never_cache
-
 import bldcollector.views
 
 import logging
@@ -46,6 +45,8 @@ urlpatterns = [
     # in the future.
     url(r'^orm/eventfile$', bldcollector.views.eventfile),
 
+    url(r'^health$', TemplateView.as_view(template_name="health.html"), name='Toaster Health'),
+
     # if no application is selected, we have the magic toastergui app here
     url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/', permanent=True))),
 ]
Signature · 1 line
1.9.1