From c213b0c0d8bfec2d41354b48e1c10cf6e1142f07 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 19 Feb 2019 10:07:17 +0100 Subject: [PATCH] Make register_app register all metadata --- usr/bin/vmmgr | 3 +-- usr/lib/python3.6/vmmgr/vmmgr.py | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usr/bin/vmmgr b/usr/bin/vmmgr index acd9bc3..b5b3b76 100755 --- a/usr/bin/vmmgr +++ b/usr/bin/vmmgr @@ -10,7 +10,6 @@ subparsers = parser.add_subparsers() 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('host', help='Application subdomain') parser_register_app.add_argument('login', nargs='?', help='Admin login') parser_register_app.add_argument('password', nargs='?', help='Admin password') @@ -44,7 +43,7 @@ vmmgr = VMMgr(conf) lxcmgr = LXCMgr(conf) if args.action == 'register-app': # Used by app install scripts - vmmgr.register_app(args.app, args.host, args.login, args.password) + vmmgr.register_app(args.app, args.login, args.password) elif args.action == 'rebuild-issue': # Used on VM startup vmmgr.rebuild_issue() diff --git a/usr/lib/python3.6/vmmgr/vmmgr.py b/usr/lib/python3.6/vmmgr/vmmgr.py index 055ba4c..d38b4eb 100644 --- a/usr/lib/python3.6/vmmgr/vmmgr.py +++ b/usr/lib/python3.6/vmmgr/vmmgr.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import json import os import requests import shutil @@ -18,9 +19,11 @@ class VMMgr: self.domain = conf['host']['domain'] self.port = conf['host']['port'] - def register_app(self, app, host, login, password): - # Register newly installed application, its subdomain and credentials - self.conf['apps'][app] = {'host': host, + def register_app(self, app, login, password): + # Register newly installed application, its metadata and credentials + with open('/var/lib/lxcpkgs/{app}/meta'.format(app)) as f: + meta = json.load(f) + self.conf['apps'][app] = {**meta, 'login': login if login else 'N/A', 'password': password if password else 'N/A', 'visible': False}