Don't register package as application automatically.

This commit is contained in:
Disassembler 2018-11-02 19:53:24 +01:00
parent 3a5258ff1f
commit fa23e4828f
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
3 changed files with 20 additions and 29 deletions

View File

@ -8,11 +8,11 @@ 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_register_app = subparsers.add_parser('register-app')
parser_register_app.set_defaults(action='register-app')
parser_register_app.add_argument('app', help='Application name')
parser_register_app.add_argument('login', help='Administrative login')
parser_register_app.add_argument('password', help='Administrative password')
parser_rebuild_issue = subparsers.add_parser('rebuild-issue')
parser_rebuild_issue.set_defaults(action='rebuild-issue')
@ -39,9 +39,9 @@ parser_unregister_proxy.add_argument('app', help='Application name')
args = parser.parse_args()
mgr = VMMgr()
if args.action == 'update-login':
if args.action == 'register-app':
# Used by app install scripts
mgr.update_login(args.app, args.login, args.password)
mgr.register_app(args.app, args.login, args.password)
elif args.action == 'rebuild-issue':
# Used on VM startup
mgr.rebuild_issue()

View File

@ -127,14 +127,17 @@ class VMMgr:
self.domain = self.conf['host']['domain']
self.port = self.conf['host']['port']
def update_login(self, app, login, password):
# Update login and password for an app in the configuration
if app not in self.conf['apps']:
def register_app(self, app, login, password):
# Register a newly installed application and update login and password
if app not in self.conf['packages']:
raise validator.InvalidValueException('app', app)
if login is not None:
self.conf['apps'][app]['login'] = login
if password is not None:
self.conf['apps'][app]['password'] = password
self.conf['apps'][app] = {
'title': metadata['title'],
'host': metadata['host'],
'login': login if login else 'N/A',
'password': password if password else 'N/A',
'visible': False
}
self.conf.save()
def show_tiles(self, app):

View File

@ -163,21 +163,9 @@ class AppMgr:
def register_package(self, name):
# Registers a package in local configuration
metadata = self.online_packages[name]
self.conf['packages'][name] = {
'deps': metadata['deps'],
'lxcpath': metadata['lxcpath'],
'version': metadata['version']
}
# If host definition is present, register the package as application
if 'host' in metadata:
self.conf['apps'][name] = {
'title': metadata['title'],
'host': metadata['host'],
'login': 'N/A',
'password': 'N/A',
'visible': False
}
metadata = self.online_packages[name].copy()
del metadata['sha512']
self.conf['packages'][name] = metadata
self.conf.save()
def unregister_package(self, name):