Skip to content

Commit

Permalink
adding initial /configuration endpoint to view agent's currently conf…
Browse files Browse the repository at this point in the history
…iguration
  • Loading branch information
opalmer committed Mar 27, 2014
1 parent 8366b24 commit bf6f105
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pyfarm/agent/http/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyfarm/agent/http/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def cb(content):
return NOT_DONE_YET


# TODO: add form to edit values
class Configuration(Resource):
TEMPLATE = "configuration.html"

Expand Down
34 changes: 34 additions & 0 deletions pyfarm/agent/http/templates/configuration.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "layout.html" %}
{% block title %}Information{% endblock %}
{% block head %}
{{ super() }}
<style type="text/css">
.firstcolumn {
width: 40%;
}
</style>
{% endblock %}
{% block content %}
<h3>Current Configuration Table</h3>
<table class="table">
<thead>
<tr>
<th class="firstcolumn">Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for key, value, css_class in configuration %}
<tr>
{% if css_class %}
<td class="{{ css_class }}">{{key}}</td>
<td class="{{ css_class }}">{{ repr(value) }}</td>
{% else %}
<td>{{key}}</td>
<td>{{value}}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
9 changes: 7 additions & 2 deletions pyfarm/agent/http/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
{% endblock %}
</head>
<body>
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
Expand All @@ -36,7 +35,13 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">System</a></li>
<li class="dropdown">
<a href="/" class="dropdown-toggle" data-toggle="dropdown">System <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/">Hardware</a></li>
<li><a href="/configuration">Configuration</a></li>
</ul>
</li>
<li><a href="/processes">Processes</a></li>
<li><a href="/tasks">Tasks</a></li>
<li><a href="/logging">Logging</a></li>
Expand Down
3 changes: 2 additions & 1 deletion pyfarm/agent/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
from pyfarm.core.logger import getLogger
from pyfarm.core.sysinfo import memory
from pyfarm.agent.http.client import post, get
from pyfarm.agent.http.index import Index
from pyfarm.agent.http.resource import Resource
from pyfarm.agent.http.server import Site, StaticPath
from pyfarm.agent.http.system import Index, Configuration
from pyfarm.agent.tasks import ScheduledTaskManager
from pyfarm.agent.config import config

Expand Down Expand Up @@ -168,6 +168,7 @@ def build_http_resource(self):

# external endpoints
resource.putChild("", Index())
resource.putChild("configuration", Configuration())

# TODO: renable these once they are working again
# resource.putChild("assign", Assign(config))
Expand Down

0 comments on commit bf6f105

Please sign in to comment.