Efforts to make ucloud a python package
This commit is contained in:
parent
bbe09667a6
commit
1e7300b56e
71 changed files with 241 additions and 1043 deletions
59
bin/ucloud
Normal file
59
bin/ucloud
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import multiprocessing as mp
|
||||
import logging
|
||||
|
||||
from os.path import join as join_path
|
||||
from ucloud.sanity_checks import check
|
||||
|
||||
if __name__ == "__main__":
|
||||
arg_parser = argparse.ArgumentParser(prog='ucloud',
|
||||
description='Open Source Cloud Management Software')
|
||||
arg_parser.add_argument('component',
|
||||
choices=['api', 'scheduler', 'host',
|
||||
'filescanner', 'imagescanner',
|
||||
'metadata'])
|
||||
arg_parser.add_argument('component_args', nargs='*')
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
filename=join_path("logs.txt"),
|
||||
filemode="a",
|
||||
format="%(name)s %(asctime)s: %(levelname)s - %(message)s",
|
||||
datefmt="%d-%b-%y %H:%M:%S",
|
||||
)
|
||||
try:
|
||||
check()
|
||||
|
||||
if args.component == 'api':
|
||||
from ucloud.api.main import main
|
||||
|
||||
main()
|
||||
elif args.component == 'host':
|
||||
from ucloud.host.main import main
|
||||
|
||||
hostname = args.component_args
|
||||
mp.set_start_method('spawn')
|
||||
main(*hostname)
|
||||
elif args.component == 'scheduler':
|
||||
from ucloud.scheduler.main import main
|
||||
|
||||
main()
|
||||
elif args.component == 'filescanner':
|
||||
from ucloud.filescanner.main import main
|
||||
|
||||
main()
|
||||
elif args.component == 'imagescanner':
|
||||
from ucloud.imagescanner.main import main
|
||||
|
||||
main()
|
||||
elif args.component == 'metadata':
|
||||
from ucloud.metadata.main import main
|
||||
|
||||
main()
|
||||
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
print(e)
|
||||
Loading…
Add table
Add a link
Reference in a new issue