From 2ae06a4e4741b4c443b71dab59eba3abcec4ba2b Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 10 Apr 2020 11:20:24 +0200 Subject: [PATCH] Add register-prop to allow custom VMMgr app property definition --- usr/bin/vmmgr | 12 ++++++++++++ usr/lib/python3.8/vmmgr/config.py | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/usr/bin/vmmgr b/usr/bin/vmmgr index 21091f8..37ac1d6 100755 --- a/usr/bin/vmmgr +++ b/usr/bin/vmmgr @@ -13,6 +13,10 @@ def unregister_app(app): # Used by package uninstall.sh script vmmgr.unregister_app(app) +def register_prop(app, key, value): + # Used by package install.sh script + config.set_app(app, key, value) + def rebuild_issue(): # Used by inittab on VM startup vmmgr.rebuild_issue() @@ -38,6 +42,12 @@ 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') +parser_register_prop = subparsers.add_parser('register-prop') +parser_register_prop.set_defaults(action=register_prop) +parser_register_prop.add_argument('app', help='Application name') +parser_register_prop.add_argument('key', help='Property name') +parser_register_prop.add_argument('value', help='Property value') + parser_rebuild_issue = subparsers.add_parser('rebuild-issue') parser_rebuild_issue.set_defaults(action=rebuild_issue) @@ -49,6 +59,8 @@ if args.action is register_app: register_app(args.app, args.host, args.login, args.password) elif args.action is unregister_app: unregister_app(args.app) +elif args.action is register_prop: + register_prop(args.app, args.key, args.value) elif args.action is rebuild_issue: rebuild_issue() elif args.action is init: diff --git a/usr/lib/python3.8/vmmgr/config.py b/usr/lib/python3.8/vmmgr/config.py index d803152..ffe1176 100644 --- a/usr/lib/python3.8/vmmgr/config.py +++ b/usr/lib/python3.8/vmmgr/config.py @@ -35,16 +35,16 @@ def get_host(): return data['host'] @locked(paths.CONF_LOCK) -def register_app(name, definition): +def register_app(app, definition): load() - data['apps'][name] = definition + data['apps'][app] = definition save() @locked(paths.CONF_LOCK) -def unregister_app(name): +def unregister_app(app): load() try: - del data['apps'][name] + del data['apps'][app] save() except KeyError: pass @@ -56,10 +56,10 @@ def set_host(key, value): save() @locked(paths.CONF_LOCK) -def set_app(name, key, value): +def set_app(app, key, value): load() try: - data['apps'][name][key] = value + data['apps'][app][key] = value save() except KeyError: pass