diff --git a/ControllerServer.py b/ControllerServer.py new file mode 100644 index 0000000..9371158 --- /dev/null +++ b/ControllerServer.py @@ -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/ + +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() \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..9742e8d --- /dev/null +++ b/templates/base.html @@ -0,0 +1,22 @@ + + + {% block title %}OVPL{% end %} + + + + +
+
+

{% block header %}OVPL{% end %}

+
+
+ {% block body %}{% end %} +
+ +
+ + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..0d02707 --- /dev/null +++ b/templates/index.html @@ -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 %} +
+

Lab ID:


+

Repo url:


+

Tag:


+
+
+{% end %}