forked from uncloud/uncloud
6d0ce65f5c
To not have unwanted environment influence
38 lines
1 KiB
Python
Executable file
38 lines
1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import logging
|
|
import importlib
|
|
import sys
|
|
import os
|
|
|
|
COMMANDS = ['api', 'scheduler', 'host', 'filescanner', 'imagescanner', 'metadata']
|
|
|
|
if __name__ == "__main__":
|
|
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")
|
|
arg_parser.add_argument('component', choices=COMMANDS)
|
|
arg_parser.add_argument('component_args', nargs='*')
|
|
args = arg_parser.parse_args()
|
|
|
|
try:
|
|
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
|
|
|
|
main()
|
|
|
|
# except decouple.UndefinedValueError as e:
|
|
# print(e)
|
|
# sys.exit(1)
|
|
|
|
except Exception as e:
|
|
logging.exception(e)
|
|
print(e)
|