2018-11-01 11:36:49 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import argparse
|
2019-09-20 10:10:25 +02:00
|
|
|
|
2019-02-19 16:05:21 +01:00
|
|
|
from vmmgr.config import Config
|
|
|
|
from vmmgr.vmmgr import VMMgr
|
2018-11-01 11:36:49 +01:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='VM application manager')
|
|
|
|
subparsers = parser.add_subparsers()
|
|
|
|
|
2018-11-02 19:53:24 +01:00
|
|
|
parser_register_app = subparsers.add_parser('register-app')
|
|
|
|
parser_register_app.set_defaults(action='register-app')
|
2019-02-15 14:19:01 +01:00
|
|
|
parser_register_app.add_argument('app', help='Application name')
|
2019-02-21 00:10:38 +01:00
|
|
|
parser_register_app.add_argument('host', help='Application subdomain')
|
2019-02-15 14:19:01 +01:00
|
|
|
parser_register_app.add_argument('login', nargs='?', help='Admin login')
|
|
|
|
parser_register_app.add_argument('password', nargs='?', help='Admin password')
|
2018-11-01 11:36:49 +01:00
|
|
|
|
2019-02-19 19:17:05 +01:00
|
|
|
parser_unregister_app = subparsers.add_parser('unregister-app')
|
|
|
|
parser_unregister_app.set_defaults(action='unregister-app')
|
|
|
|
parser_unregister_app.add_argument('app', help='Application name')
|
|
|
|
|
2018-11-01 11:36:49 +01:00
|
|
|
parser_rebuild_issue = subparsers.add_parser('rebuild-issue')
|
|
|
|
parser_rebuild_issue.set_defaults(action='rebuild-issue')
|
|
|
|
|
|
|
|
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()
|
2019-02-19 16:05:21 +01:00
|
|
|
vmmgr = VMMgr(Config())
|
2018-11-02 19:53:24 +01:00
|
|
|
if args.action == 'register-app':
|
2019-02-19 19:17:05 +01:00
|
|
|
# Used by package install.sh script
|
2019-02-21 00:10:38 +01:00
|
|
|
vmmgr.register_app(args.app, args.host, args.login, args.password)
|
2019-02-19 19:17:05 +01:00
|
|
|
elif args.action == 'unregister-app':
|
|
|
|
# Used by package uninstall.sh script
|
|
|
|
vmmgr.unregister_app(args.app)
|
2018-11-01 11:36:49 +01:00
|
|
|
elif args.action == 'rebuild-issue':
|
2019-02-19 19:17:05 +01:00
|
|
|
# Used by inittab on VM startup
|
2018-12-20 14:56:37 +01:00
|
|
|
vmmgr.rebuild_issue()
|
2018-11-01 11:36:49 +01:00
|
|
|
elif args.action == 'register-proxy':
|
2019-02-19 19:17:05 +01:00
|
|
|
# Used in init scripts on application startup
|
2019-02-25 22:20:41 +01:00
|
|
|
vmmgr.register_proxy(args.app)
|
2018-11-01 11:36:49 +01:00
|
|
|
elif args.action == 'unregister-proxy':
|
2019-02-19 19:17:05 +01:00
|
|
|
# Used in init scripts on application stop
|
2019-02-19 16:05:21 +01:00
|
|
|
vmmgr.unregister_proxy(args.app)
|