forked from uncloud/uncloud
Migrate sanity_check.py into the respective daemons
This commit is contained in:
parent
f9dbdc730a
commit
9517e73233
4 changed files with 22 additions and 35 deletions
|
@ -18,8 +18,6 @@ if __name__ == "__main__":
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
check()
|
|
||||||
|
|
||||||
if args.component == 'api':
|
if args.component == 'api':
|
||||||
from ucloud.api.main import main
|
from ucloud.api.main import main
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,17 @@ def maintenance(host):
|
||||||
if _vm:
|
if _vm:
|
||||||
running_vms.remove(_vm)
|
running_vms.remove(_vm)
|
||||||
|
|
||||||
|
def check():
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main(hostname):
|
def main(hostname):
|
||||||
|
check()
|
||||||
|
|
||||||
heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))
|
heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))
|
||||||
|
|
||||||
host_pool = HostPool(etcd_client, env_vars.get('HOST_PREFIX'))
|
host_pool = HostPool(etcd_client, env_vars.get('HOST_PREFIX'))
|
||||||
|
|
|
@ -18,6 +18,19 @@ def qemu_img_type(path):
|
||||||
qemu_img_info = json.loads(qemu_img_info.decode("utf-8"))
|
qemu_img_info = json.loads(qemu_img_info.decode("utf-8"))
|
||||||
return qemu_img_info["format"]
|
return qemu_img_info["format"]
|
||||||
|
|
||||||
|
def check():
|
||||||
|
""" check whether settings are sane, refuse to start if they aren't """
|
||||||
|
if env_vars.get('STORAGE_BACKEND') == 'filesystem' and not isdir(env_vars.get('IMAGE_DIR')):
|
||||||
|
print("You have set STORAGE_BACKEND to filesystem, but "
|
||||||
|
"{} does not exist. Refusing to start".format(env_vars.get('IMAGE_DIR')))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.check_output(['which', 'qemu-img'])
|
||||||
|
except Exception:
|
||||||
|
print("qemu-img missing")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# We want to get images entries that requests images to be created
|
# We want to get images entries that requests images to be created
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
import sys
|
|
||||||
import subprocess as sp
|
|
||||||
|
|
||||||
from os.path import isdir
|
|
||||||
from ucloud.config import env_vars
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
Loading…
Reference in a new issue