Add site configuration
Committed 20833a
--- a/webint_sites/__init__.py
+++ b/webint_sites/__init__.py
class Machine:
"""Manage one of your machines."""
+ owner_only = ["get"]
+
def get(self, machine):
details = tx.db.select("machines", where="name = ?", vals=[machine])[0]
# try:
return app.view.machine(details, root_ssh, admin_ssh)
+@app.control("machines/{machine}/config")
+class Machine:
+ """Configure one of your machines."""
+
+ owner_only = ["post"]
+
+ def post(self, machine):
+ config = web.form("webcfg").webcfg
+ details = tx.db.select("machines", where="name = ?", vals=[machine])[0]
+ root_ssh = web.host.Machine(details["ip_address"], "root", "admin_key").run
+ admin_ssh = web.host.Machine(details["ip_address"], "admin", "admin_key").run
+ admin_ssh("cat > app/run/webcfg.ini", stdin=config)
+ root_ssh("supervisorctl", "restart", "app", "queue")
+ return "saved"
+
+
@app.control("machines/{machine}/update")
class MachineBuild:
"""Manage your machine's system updates."""
--- a/webint_sites/templates/machine.html
+++ b/webint_sites/templates/machine.html
</a>\
<small>$size</small>
</pre>
+<form action=/machines/$machine["name"]/config method=post>
+<textarea name=webcfg>$:render("cat /home/admin/app/run/webcfg.ini")</textarea>
+</form>
<h4>Supervisor</h4>
$:render("supervisorctl status")