From fa23e4828f81bf16ee2303ff4c87128a795ffcbf Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 2 Nov 2018 19:53:24 +0100 Subject: [PATCH] Don't register package as application automatically. --- usr/bin/vmmgr | 14 +++++++------- usr/lib/python3.6/vmmgr/__init__.py | 17 ++++++++++------- usr/lib/python3.6/vmmgr/appmgr.py | 18 +++--------------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/usr/bin/vmmgr b/usr/bin/vmmgr index d607a8a..9e772b1 100755 --- a/usr/bin/vmmgr +++ b/usr/bin/vmmgr @@ -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() diff --git a/usr/lib/python3.6/vmmgr/__init__.py b/usr/lib/python3.6/vmmgr/__init__.py index d17edf5..05accb1 100644 --- a/usr/lib/python3.6/vmmgr/__init__.py +++ b/usr/lib/python3.6/vmmgr/__init__.py @@ -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): diff --git a/usr/lib/python3.6/vmmgr/appmgr.py b/usr/lib/python3.6/vmmgr/appmgr.py index 25af0b7..78710de 100644 --- a/usr/lib/python3.6/vmmgr/appmgr.py +++ b/usr/lib/python3.6/vmmgr/appmgr.py @@ -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):