Date: Tue, 4 Aug 2015 10:20:09 GMT From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289202 - in soc2015/kczekirda/www: . tpl Message-ID: <201508041020.t74AK9kY043393@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kczekirda Date: Tue Aug 4 10:20:09 2015 New Revision: 289202 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289202 Log: task management init Added: soc2015/kczekirda/www/tpl/add_task.tpl soc2015/kczekirda/www/tpl/delete_task.tpl Modified: soc2015/kczekirda/www/menu.py soc2015/kczekirda/www/tpl/main.tpl Modified: soc2015/kczekirda/www/menu.py ============================================================================== --- soc2015/kczekirda/www/menu.py Tue Aug 4 09:45:10 2015 (r289201) +++ soc2015/kczekirda/www/menu.py Tue Aug 4 10:20:09 2015 (r289202) @@ -6,8 +6,10 @@ database = 'cluster.sqlite' main_tpl = 'tpl/main.tpl' add_node_tpl = 'tpl/add_node.tpl' +add_task_tpl = 'tpl/add_task.tpl' edit_node_tpl = 'tpl/edit_node.tpl' delete_node_tpl = 'tpl/delete_node.tpl' +delete_task_tpl = 'tpl/delete_task.tpl' default = 'menu.ipxe' @route('/static/:path#.+#', name='static') @@ -24,13 +26,16 @@ conn = sqlite3.connect(database) c = conn.cursor() c.execute("SELECT * FROM nodes") - result = c.fetchall() + result_nodes = c.fetchall() + c.execute("SELECT * FROM tasks") + result_tasks = c.fetchall() c.close - output = template(main_tpl,rows=result) + output = template(main_tpl,rows_nodes=result_nodes,rows_tasks=result_tasks) return output else: conn = sqlite3.connect(database) conn.execute("CREATE TABLE nodes (id INTEGER PRIMARY KEY, host char(254) NOT NULL, mac char(20) NOT NULL, ip char(20) NOT NULL, boot char(50) NOT NULL)") + conn.execute("CREATE TABLE tasks (id INTEGER PRIMARY KEY, revision char(20) NOT NULL, host char(254), status char(20))") conn.commit() return redirect('/admin') @@ -87,6 +92,30 @@ return redirect('/admin') else: return template(add_node_tpl) + +@route('/admin/add_task', method='GET') +def add(): + if request.GET.get('add','').strip(): + revision = request.GET.get('revision','').strip() + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("INSERT INTO tasks (revision) VALUES (?)", (revision,)) + conn.commit() + c.close() + return redirect('/admin') + else: + return template(add_task_tpl) + +@route('/admin/delete_task/:revision', method='GET') +def delete(revision): + if request.GET.get('delete','').strip(): + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("DELETE FROM tasks WHERE revision LIKE '%s'" %revision) + conn.commit() + return redirect('/admin') + else: + return template(delete_task_tpl,revision=revision) @route('/menu/:mac', method='GET') def static(mac): Added: soc2015/kczekirda/www/tpl/add_task.tpl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/kczekirda/www/tpl/add_task.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -0,0 +1,12 @@ +<head> +<link rel="stylesheet" type="text/css" href="../../static/style.css"> +</head> +<title>Testing cluster management</title> +<div id="body"> +<h2>Add new task</h2> +<form action="/admin/add_task" method="GET"> +<p>revision<br/><input type="text" name="revision" value="" size="20" maxlenght="20"></p> +<p><input type="submit" id="btn" class="warning" name="add" value="Add"></p> +</form> +<p><a href="/admin">Back</a></p> +</div> Added: soc2015/kczekirda/www/tpl/delete_task.tpl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/kczekirda/www/tpl/delete_task.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -0,0 +1,11 @@ +<head> +<link rel="stylesheet" type="text/css" href="../../static/style.css"> +</head> +<title>Testing cluster management</title> +<div id="body"> +<h2>Delete task {{revision}}</h2> +<form action="/admin/delete_task/{{revision}}" method="GET"> +<input type="submit" id="btn" class="warning" name="delete" value="Delete"> +</form> +<p><a href="/admin">Back</a></p> +</div> Modified: soc2015/kczekirda/www/tpl/main.tpl ============================================================================== --- soc2015/kczekirda/www/tpl/main.tpl Tue Aug 4 09:45:10 2015 (r289201) +++ soc2015/kczekirda/www/tpl/main.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -3,10 +3,10 @@ </head> <title>Testing cluster management</title> <div id="body"> -<h2>Nodes</h2> <table border="0"> +<tr><td><h2>Nodes</h2></td></tr> <tr><th>ID</th><th>host</th><th>mac address</th><th>ip address</th><th>boot</th></tr> -%for row in rows: +%for row in rows_nodes: %id = row[0] %host = row[1] %mac = row[2] @@ -22,6 +22,22 @@ <td><a href="/admin/delete_node/{{id}}">Delete</a></td> </tr> %end +<tr><td><a href="/admin/add_node">Add node</a></td></tr> +<tr><td><h2>Tasks</h2></td></tr> +<tr><th>ID</th><th>revision</th><th>host</th><th>status</th></tr> +%for row in rows_tasks: + %id = row[0] + %revision = row[1] + %host = row[2] + %status = row[3] + <tr> + <td>{{id}}</td> + <td>{{revision}}</td> + <td>{{host}}</td> + <td>{{status}}</td> + <td><a href="/admin/delete_task/{{revision}}">Delete</a></td> + </tr> +%end +<tr><td><a href="/admin/add_task">Add task</a></td></tr> </table> -<p><a href="/admin/add_node">Add node</a></p> </div>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508041020.t74AK9kY043393>