uncloud/scripts/ucloud

39 lines
1 KiB
Text
Raw Normal View History

#!/usr/bin/env python3
import argparse
import logging
2019-12-08 11:28:25 +00:00
import importlib
import sys
import os
2019-12-08 11:28:25 +00:00
COMMANDS = ['api', 'scheduler', 'host', 'filescanner', 'imagescanner', 'metadata']
if __name__ == "__main__":
2019-12-08 11:28:25 +00:00
log = logging.getLogger("ucloud")
arg_parser = argparse.ArgumentParser(prog='ucloud',
description='Open Source Cloud Management Software')
arg_parser.add_argument('-c', '--conf-dir', help="Configuration directory")
2019-12-08 11:28:25 +00:00
arg_parser.add_argument('component', choices=COMMANDS)
arg_parser.add_argument('component_args', nargs='*')
args = arg_parser.parse_args()
try:
2019-12-08 11:28:25 +00:00
name = args.component
mod = importlib.import_module("ucloud.{}.main".format(name))
main = getattr(mod, "main")
if args.conf_dir:
print("setting conf")
os.environ['UCLOUD_CONF_DIR'] = args.conf_dir
2019-12-08 11:28:25 +00:00
main()
# except decouple.UndefinedValueError as e:
# print(e)
# sys.exit(1)
except Exception as e:
logging.exception(e)
print(e)