-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcli.py
More file actions
48 lines (42 loc) · 1.39 KB
/
cli.py
File metadata and controls
48 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
import logging
import sys
import yaml
from pathlib import Path
from ceph_devstack import config, logger, parse_args, VERBOSE
from ceph_devstack.requirements import check_requirements
from ceph_devstack.resources.ceph import CephDevStack
def main():
args = parse_args(sys.argv[1:])
config.load(args.config_file)
if args.verbose:
for handler in logging.getLogger("root").handlers:
if not isinstance(handler, logging.FileHandler):
handler.setLevel(VERBOSE)
if args.command == "show-conf":
print(yaml.safe_dump(config))
return
config["args"] = vars(args)
data_path = Path(config["data_dir"]).expanduser()
data_path.mkdir(parents=True, exist_ok=True)
obj = CephDevStack()
async def run():
if not await asyncio.gather(
check_requirements(),
obj.check_requirements(),
):
logger.error("Requirements not met!")
sys.exit(1)
if args.command == "doctor":
return
elif args.command == "wait":
return await obj.wait(container_name=args.container)
elif args.command == "teuthology-log":
return await obj.teuthology_log(args)
else:
await obj.apply(args.command)
return 0
try:
sys.exit(asyncio.run(run()))
except KeyboardInterrupt:
logger.debug("Exiting!")