delete domain

This commit is contained in:
qiaofeng1227 2023-05-17 11:52:53 +08:00
parent 5fc8e776a7
commit 6e30c575bc

View File

@ -95,33 +95,25 @@ def install_app(app_name, customer_name, app_version):
return ret return ret
def start_app(app_id): def start_app(app_id):
code, message = docker.check_app_id(app_id)
if code == None: info, flag = app_exits_in_docker(app_id)
info, flag = app_exits_in_docker(app_id) if flag:
if flag: app_path = info.split()[-1].rsplit('/', 1)[0]
app_path = info.split()[-1].rsplit('/', 1)[0] cmd = "docker compose -f " + app_path + "/docker-compose.yml start"
cmd = "docker compose -f " + app_path + "/docker-compose.yml start" shell_execute.execute_command_output_all(cmd)
shell_execute.execute_command_output_all(cmd)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "APP is not exist", "")
else: else:
raise CommandException(code, message, '') raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "APP is not exist", "")
def stop_app(app_id): def stop_app(app_id):
code, message = docker.check_app_id(app_id)
myLogger.info_logger(message)
if code == None:
info, flag = app_exits_in_docker(app_id)
if flag:
app_path = info.split()[-1].rsplit('/', 1)[0]
cmd = "docker compose -f " + app_path + "/docker-compose.yml stop"
shell_execute.execute_command_output_all(cmd)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "APP is not exist", "")
else:
myLogger.info_logger("check app failed")
raise CommandException(code, message, "")
info, flag = app_exits_in_docker(app_id)
if flag:
app_path = info.split()[-1].rsplit('/', 1)[0]
cmd = "docker compose -f " + app_path + "/docker-compose.yml stop"
shell_execute.execute_command_output_all(cmd)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "APP is not exist", "")
def restart_app(app_id): def restart_app(app_id):
code, message = docker.check_app_id(app_id) code, message = docker.check_app_id(app_id)
@ -143,32 +135,30 @@ def delete_app_failedjob(job_id):
failed.remove(job_id, delete_job=True) failed.remove(job_id, delete_job=True)
def uninstall_app(app_id): def uninstall_app(app_id):
code, message = docker.check_app_id(app_id)
if code == None: app_name = app_id.split('_')[0]
app_name = app_id.split('_')[0] customer_name = app_id.split('_')[1]
customer_name = app_id.split('_')[1] app_path = ""
app_path = "" info, code_exist = app_exits_in_docker(app_id)
info, code_exist = app_exits_in_docker(app_id) if code_exist:
if code_exist: app_path = info.split()[-1].rsplit('/', 1)[0]
app_path = info.split()[-1].rsplit('/', 1)[0] cmd = "docker compose -f " + app_path + "/docker-compose.yml down -v"
cmd = "docker compose -f " + app_path + "/docker-compose.yml down -v" lib_path = '/data/library/apps/' + app_name
lib_path = '/data/library/apps/' + app_name if app_path != lib_path:
if app_path != lib_path: cmd = cmd + " && sudo rm -rf " + app_path
cmd = cmd + " && sudo rm -rf " + app_path shell_execute.execute_command_output_all(cmd)
shell_execute.execute_command_output_all(cmd)
else:
if check_app_rq(app_id):
delete_app_failedjob(app_id)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "AppID is not exist", "")
# Force to delete
try:
cmd = " sudo rm -rf /data/apps/" + customer_name
shell_execute.execute_command_output_all(cmd)
except CommandException as ce:
myLogger.info_logger("Delete app compose exception")
else: else:
raise CommandException(code, message, "") if check_app_rq(app_id):
delete_app_failedjob(app_id)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "AppID is not exist", "")
# Force to delete
try:
cmd = " sudo rm -rf /data/apps/" + customer_name
shell_execute.execute_command_output_all(cmd)
except CommandException as ce:
myLogger.info_logger("Delete app compose exception")
def check_app(app_name, customer_name, app_version): def check_app(app_name, customer_name, app_version):
message = "" message = ""
@ -593,9 +583,11 @@ def app_domain_delete(app_id, domain):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
response = requests.delete(url, headers=headers) response = requests.delete(url, headers=headers)
myLogger.info_logger(response.json()) try:
if response.json().get("error"): if response.json().get("error"):
raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "")
except Exception:
myLogger.info_logger(response.json())
set_domain("", app_id) set_domain("", app_id)
else: else:
proxy_id = proxy["id"] proxy_id = proxy["id"]