-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
executable file
·43 lines (36 loc) · 1.54 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import tornado.httpserver
import libvirt
import logging
import argparse
import utils
import handlers
def main():
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', type=int, default=1024)
parser.add_argument('-c', '--connect', dest='libvirt_connection_string', default='qemu:///system')
parser.add_argument('--enable-xheaders', default=False, action='store_true')
parser.add_argument('--load-edited-domain-xml', default=False, action='store_true',
help='Use this flag to make changes to Domain XML to be reflected immediately (opposed ' +
'to requiring a restart of the domain)')
parser.add_argument('--plugin', action='append', help='Load this plugin. This simply imports the module. ' +
'See example for more details')
args = parser.parse_args()
if args.plugin:
for plugin in args.plugin:
__import__(plugin)
application = tornado.web.Application(
handlers.routes,
machine_resolver=utils.machine_resolver.LibvirtMachineResolver(
libvirt.openReadOnly(args.libvirt_connection_string),
args.load_edited_domain_xml)
)
http_server = tornado.httpserver.HTTPServer(application)
http_server.xheaders = args.enable_xheaders
http_server.listen(args.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()