2017-12-19 20:43:20 +01:00
|
|
|
#!/usr/bin/python
|
2017-09-14 21:39:01 +02:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
import json
|
|
|
|
|
|
|
|
def main(args):
|
|
|
|
jsonfile = '/srv/portal/js/apps.json'
|
|
|
|
|
|
|
|
data = {}
|
|
|
|
with open(jsonfile, 'r') as f:
|
|
|
|
data = json.load(f)
|
|
|
|
if not args.app in data:
|
|
|
|
data[args.app] = {}
|
|
|
|
if args.url:
|
|
|
|
data[args.app]['url'] = args.url
|
|
|
|
if args.login:
|
|
|
|
data[args.app]['login'] = args.login
|
|
|
|
if args.password:
|
|
|
|
data[args.app]['password'] = args.password
|
2017-12-03 22:26:31 +01:00
|
|
|
if args.property:
|
|
|
|
for key, value in args.property:
|
|
|
|
data[args.app][key] = value
|
2017-09-14 21:39:01 +02:00
|
|
|
with open(jsonfile, 'w') as f:
|
|
|
|
json.dump(data, f)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = argparse.ArgumentParser(description='Spotter Cluster portal application manager')
|
|
|
|
parser.add_argument('app', help='Application ID.')
|
2017-09-14 22:10:00 +02:00
|
|
|
parser.add_argument('url', nargs='?', help='URL to the application. Use "{host}" as a host placeholder.')
|
|
|
|
parser.add_argument('login', nargs='?', help='Administrative login.')
|
|
|
|
parser.add_argument('password', nargs='?', help='Administrative password.')
|
2017-12-03 22:26:31 +01:00
|
|
|
parser.add_argument('-p', '--property', nargs=2, action='append', help='Add arbitrary key-value to the application properties')
|
2017-09-14 21:39:01 +02:00
|
|
|
main(parser.parse_args())
|