From bf6f105f2ecdb5edb8266cb5d98ffd90ae818967 Mon Sep 17 00:00:00 2001 From: Oliver Palmer Date: Thu, 27 Mar 2014 01:04:06 -0400 Subject: [PATCH] adding initial /configuration endpoint to view agent's currently configuration --- pyfarm/agent/http/resource.py | 3 +- pyfarm/agent/http/system.py | 1 + .../agent/http/templates/configuration.html | 34 +++++++++++++++++++ pyfarm/agent/http/templates/layout.html | 9 +++-- pyfarm/agent/service.py | 3 +- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 pyfarm/agent/http/templates/configuration.html diff --git a/pyfarm/agent/http/resource.py b/pyfarm/agent/http/resource.py index 07757006..aa58be0c 100644 --- a/pyfarm/agent/http/resource.py +++ b/pyfarm/agent/http/resource.py @@ -83,7 +83,8 @@ def __init__(self): loader.environment.globals.update( hostname=lambda: config["hostname"], agent_id=lambda: config["agent-id"], - state=lambda: config["state"]) + state=lambda: config["state"], + repr=repr) # Template is only required for subclasses. This class can serve # http requests but when we build the http server that's not how diff --git a/pyfarm/agent/http/system.py b/pyfarm/agent/http/system.py index 43f1351e..2ace633b 100644 --- a/pyfarm/agent/http/system.py +++ b/pyfarm/agent/http/system.py @@ -131,6 +131,7 @@ def cb(content): return NOT_DONE_YET +# TODO: add form to edit values class Configuration(Resource): TEMPLATE = "configuration.html" diff --git a/pyfarm/agent/http/templates/configuration.html b/pyfarm/agent/http/templates/configuration.html new file mode 100644 index 00000000..6bbb65a1 --- /dev/null +++ b/pyfarm/agent/http/templates/configuration.html @@ -0,0 +1,34 @@ +{% extends "layout.html" %} +{% block title %}Information{% endblock %} +{% block head %} + {{ super() }} + +{% endblock %} +{% block content %} +

Current Configuration Table

+ + + + + + + + + {% for key, value, css_class in configuration %} + + {% if css_class %} + + + {% else %} + + + {% endif %} + + {% endfor %} + +
KeyValue
{{key}}{{ repr(value) }}{{key}}{{value}}
+{% endblock %} \ No newline at end of file diff --git a/pyfarm/agent/http/templates/layout.html b/pyfarm/agent/http/templates/layout.html index 9292e862..d087bf0e 100644 --- a/pyfarm/agent/http/templates/layout.html +++ b/pyfarm/agent/http/templates/layout.html @@ -22,7 +22,6 @@ {% endblock %} -