Spread files to proper application structure
62
usr/bin/vmmgr
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from vmmgr import VMMgr
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='VM application manager')
|
||||||
|
subparsers = parser.add_subparsers()
|
||||||
|
|
||||||
|
parser_update_login = subparsers.add_parser('update-login')
|
||||||
|
parser_update_login.set_defaults(action='update-login')
|
||||||
|
parser_update_login.add_argument('app', help='Application name')
|
||||||
|
parser_update_login.add_argument('login', help='Administrative login')
|
||||||
|
parser_update_login.add_argument('password', help='Administrative password')
|
||||||
|
|
||||||
|
parser_rebuild_issue = subparsers.add_parser('rebuild-issue')
|
||||||
|
parser_rebuild_issue.set_defaults(action='rebuild-issue')
|
||||||
|
|
||||||
|
parser_prepare_container = subparsers.add_parser('prepare-container')
|
||||||
|
parser_prepare_container.add_argument('lxc', nargs=argparse.REMAINDER)
|
||||||
|
parser_prepare_container.set_defaults(action='prepare-container')
|
||||||
|
|
||||||
|
parser_register_container = subparsers.add_parser('register-container')
|
||||||
|
parser_register_container.add_argument('lxc', nargs=argparse.REMAINDER)
|
||||||
|
parser_register_container.set_defaults(action='register-container')
|
||||||
|
|
||||||
|
parser_unregister_container = subparsers.add_parser('unregister-container')
|
||||||
|
parser_unregister_container.add_argument('lxc', nargs=argparse.REMAINDER)
|
||||||
|
parser_unregister_container.set_defaults(action='unregister-container')
|
||||||
|
|
||||||
|
parser_register_proxy = subparsers.add_parser('register-proxy')
|
||||||
|
parser_register_proxy.set_defaults(action='register-proxy')
|
||||||
|
parser_register_proxy.add_argument('app', help='Application name')
|
||||||
|
|
||||||
|
parser_unregister_proxy = subparsers.add_parser('unregister-proxy')
|
||||||
|
parser_unregister_proxy.set_defaults(action='unregister-proxy')
|
||||||
|
parser_unregister_proxy.add_argument('app', help='Application name')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
mgr = VMMgr()
|
||||||
|
if args.action == 'update-login':
|
||||||
|
# Used by app install scripts
|
||||||
|
mgr.update_login(args.app, args.login, args.password)
|
||||||
|
elif args.action == 'rebuild-issue':
|
||||||
|
# Used on VM startup
|
||||||
|
mgr.rebuild_issue()
|
||||||
|
elif args.action == 'prepare-container':
|
||||||
|
# Used with LXC hooks
|
||||||
|
mgr.prepare_container()
|
||||||
|
elif args.action == 'register-container':
|
||||||
|
# Used with LXC hooks
|
||||||
|
mgr.register_container()
|
||||||
|
elif args.action == 'unregister-container':
|
||||||
|
# Used with LXC hooks
|
||||||
|
mgr.unregister_container()
|
||||||
|
elif args.action == 'register-proxy':
|
||||||
|
# Used in init scripts
|
||||||
|
mgr.register_proxy(args.app)
|
||||||
|
elif args.action == 'unregister-proxy':
|
||||||
|
# Used in init scripts
|
||||||
|
mgr.unregister_proxy(args.app)
|
@ -30,7 +30,7 @@ NGINX_TEMPLATE = '''server {{
|
|||||||
|
|
||||||
error_page 502 /502.html;
|
error_page 502 /502.html;
|
||||||
location = /502.html {{
|
location = /502.html {{
|
||||||
root /srv/vm/templates;
|
root /usr/share/vmmgr/templates;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
location = /vm-ping {{
|
location = /vm-ping {{
|
||||||
@ -65,12 +65,12 @@ server {{
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
location /static {{
|
location /static {{
|
||||||
root /srv/vm;
|
root /usr/share/vmmgr;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
error_page 502 /502.html;
|
error_page 502 /502.html;
|
||||||
location = /502.html {{
|
location = /502.html {{
|
||||||
root /srv/vm/templates;
|
root /usr/share/vmmgr/templates;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
location = /vm-ping {{
|
location = /vm-ping {{
|
@ -18,7 +18,7 @@ from threading import Lock
|
|||||||
|
|
||||||
from . import tools
|
from . import tools
|
||||||
|
|
||||||
PUB_FILE = '/srv/vm/packages.pub'
|
PUB_FILE = '/etc/vmmgr/packages.pub'
|
||||||
LXC_ROOT = '/var/lib/lxc'
|
LXC_ROOT = '/var/lib/lxc'
|
||||||
|
|
||||||
class ActionItem:
|
class ActionItem:
|
@ -3,7 +3,7 @@
|
|||||||
import json
|
import json
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
CONF_FILE = '/srv/vm/config.json'
|
CONF_FILE = '/etc/vmmgr/config.json'
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self):
|
def __init__(self):
|
@ -24,7 +24,7 @@ class WSGIApp(object):
|
|||||||
self.vmmgr = VMMgr()
|
self.vmmgr = VMMgr()
|
||||||
self.appmgr = AppMgr(self.vmmgr)
|
self.appmgr = AppMgr(self.vmmgr)
|
||||||
self.conf = self.vmmgr.conf
|
self.conf = self.vmmgr.conf
|
||||||
self.jinja_env = Environment(loader=FileSystemLoader('/srv/vm/templates'), autoescape=True, lstrip_blocks=True, trim_blocks=True)
|
self.jinja_env = Environment(loader=FileSystemLoader('/usr/share/vmmgr/templates'), autoescape=True, lstrip_blocks=True, trim_blocks=True)
|
||||||
self.jinja_env.globals.update(is_app_visible=self.is_app_visible)
|
self.jinja_env.globals.update(is_app_visible=self.is_app_visible)
|
||||||
self.jinja_env.globals.update(is_service_autostarted=tools.is_service_autostarted)
|
self.jinja_env.globals.update(is_service_autostarted=tools.is_service_autostarted)
|
||||||
self.jinja_env.globals.update(is_service_started=tools.is_service_started)
|
self.jinja_env.globals.update(is_service_started=tools.is_service_started)
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -2,9 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from vmmgr.wsgiapp import WSGIApp
|
||||||
sys.path.append('/srv/vm')
|
|
||||||
from mgr.wsgiapp import WSGIApp
|
|
||||||
|
|
||||||
application = WSGIApp()
|
application = WSGIApp()
|
||||||
|
|