Make register_app register all metadata

This commit is contained in:
Disassembler 2019-02-19 10:07:17 +01:00
parent bbdd91cd77
commit c213b0c0d8
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
2 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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}