-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Controller Server and supporting template files
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/python | ||
|
||
# Services exposed by the VM Manager | ||
# The REST url : | ||
# http://host-name/api/1.0/disk-usage | ||
# http://host-name/api/1.0/running-time | ||
# http://host-name/api/1.0/mem-usage | ||
# http://host-name/api/1.0/running-processes | ||
# http://host-name/api/1.0/cpu-load | ||
# http://host-name/api/1.0/execute/<command> | ||
|
||
import urlparse | ||
import os | ||
|
||
# bunch of tornado imports | ||
import tornado.httpserver | ||
import tornado.ioloop | ||
import tornado.options | ||
import tornado.web | ||
from tornado.options import define, options | ||
|
||
import Controller | ||
|
||
|
||
define("port", default=8000, help="run on the given port", type=int) | ||
|
||
|
||
class MainHandler(tornado.web.RequestHandler): | ||
def get(self): | ||
self.render('index.html') | ||
|
||
def post(self): | ||
post_data = dict(urlparse.parse_qsl(self.request.body)) | ||
c = Controller.Controller() | ||
self.write(c.test_lab(post_data['lab_id'], post_data['lab_src_url'], post_data.get('version', None))) | ||
|
||
|
||
if __name__ == "__main__": | ||
tornado.options.parse_command_line() | ||
app = tornado.web.Application( | ||
handlers=[ | ||
(r"/", MainHandler) | ||
], | ||
template_path=os.path.join(os.path.dirname(__file__), "templates"), | ||
static_path=os.path.join(os.path.dirname(__file__), "static"), | ||
debug = True) | ||
http_server = tornado.httpserver.HTTPServer(app) | ||
http_server.listen(options.port) | ||
tornado.ioloop.IOLoop.instance().start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<html> | ||
<head> | ||
<title>{% block title %}OVPL{% end %}</title> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css"> | ||
<style type="text/css">{% block CSS %}{% end %}</style> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<header> | ||
<h1>{% block header %}OVPL{% end %}</h1> | ||
</header> | ||
<div id="main"> | ||
{% block body %}{% end %} | ||
</div> | ||
<footer> | ||
{% block footer %} | ||
<a href="http://github.com/vlead/ovpl">OVPL - Github</a> | ||
{% end %} | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block CSS %} | ||
body { | ||
text-align: center; | ||
font-family: georgia; | ||
} | ||
|
||
#container { | ||
margin: 0 auto; | ||
width: 960px; | ||
} | ||
|
||
h1 { | ||
font-size: 40px | ||
} | ||
|
||
p { | ||
font-size: 20px | ||
} | ||
{% end %} | ||
|
||
{% block title %} | ||
Controller - OVPL | ||
{% end %} | ||
|
||
{% block header %} | ||
Test Your Lab! | ||
{% end %} | ||
|
||
{% block body %} | ||
<form action="/" method="post"> | ||
<p> Lab ID: <input type="text" name="lab_id" id="lab_id"></p><br> | ||
<p> Repo url: <input type="text" name="lab_src_url" id="lab_src_url"></p><br> | ||
<p> Tag: <input type="text" name="version" id="version"></p><br> | ||
<input type="submit"><br /> | ||
</form> | ||
{% end %} |