2019-11-25 06:52:36 +00:00
|
|
|
import sys
|
|
|
|
import subprocess as sp
|
|
|
|
|
|
|
|
from os.path import isdir
|
2019-12-03 10:40:41 +00:00
|
|
|
from ucloud.config import env_vars
|
2019-11-25 06:52:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check():
|
|
|
|
#########################
|
|
|
|
# ucloud-image-scanner #
|
|
|
|
#########################
|
|
|
|
if env_vars.get('STORAGE_BACKEND') == 'filesystem' and not isdir(env_vars.get('IMAGE_DIR')):
|
|
|
|
print("You have set STORAGE_BACKEND to filesystem. So,"
|
|
|
|
"the {} must exists. But, it don't".format(env_vars.get('IMAGE_DIR')))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
sp.check_output(['which', 'qemu-img'])
|
|
|
|
except Exception:
|
|
|
|
print("qemu-img missing")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
###############
|
|
|
|
# ucloud-host #
|
|
|
|
###############
|
|
|
|
|
|
|
|
if env_vars.get('STORAGE_BACKEND') == 'filesystem' and not isdir(env_vars.get('VM_DIR')):
|
|
|
|
print("You have set STORAGE_BACKEND to filesystem. So, the vm directory mentioned"
|
|
|
|
" in .env file must exists. But, it don't.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
check()
|