uncloud/scripts/ucloud
2019-12-08 12:28:25 +01:00

35 lines
891 B
Python
Executable file

#!/usr/bin/env python3
import argparse
import logging
import importlib
# For the exception
import decouple
import sys
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('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")
main()
except decouple.UndefinedValueError as e:
print(e)
sys.exit(1)
except Exception as e:
logging.exception(e)
print(e)