Update manage.py

This commit is contained in:
qiaofeng1227 2023-05-15 16:03:11 +08:00 committed by GitHub
parent f5ae1088a3
commit 918ba14605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -535,7 +535,7 @@ def app_domain_list(app_id):
return domains
def app_domain_delete(app_id, domains):
def app_domain_delete(app_id, domain):
code, message = docker.check_app_id(app_id)
if code == None:
info, flag = app_exits_in_docker(app_id)
@ -546,67 +546,66 @@ def app_domain_delete(app_id, domains):
else:
raise CommandException(code, message, "")
old_all_domains = get_all_domains(app_id)
for domain in domains:
if domain not in old_all_domains:
myLogger.info_logger("delete domain is not binded")
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "Domain is not bind.", "")
myLogger.info_logger("Start to delete " + domain)
proxy = get_proxy_domain(app_id, domain)
if proxy != None:
myLogger.info_logger(proxy)
myLogger.info_logger("before update")
domains_old = proxy["domain_names"]
myLogger.info_logger(domains_old)
for domain in domains:
if domain in domains_old:
domains_old.remove(domain)
myLogger.info_logger("after update")
myLogger.info_logger(domains_old)
if len(domains_old) == 0:
proxy_id = proxy["id"]
token = get_token()
url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
headers = {
'Authorization': token,
'Content-Type': 'application/json'
}
requests.delete(url, headers=headers)
set_domain("", app_id)
else:
proxy_id = proxy["id"]
token = get_token()
url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
headers = {
'Authorization': token,
'Content-Type': 'application/json'
}
port = get_container_port(app_id.split('_')[1])
host = app_id.split('_')[1]
data = {
"domain_names": domains_old,
"forward_scheme": "http",
"forward_host": host,
"forward_port": port,
"access_list_id": "0",
"certificate_id": 0,
"meta": {
"letsencrypt_agree": False,
"dns_challenge": False
},
"advanced_config": "",
"locations": [],
"block_exploits": False,
"caching_enabled": False,
"allow_websocket_upgrade": False,
"http2_support": False,
"hsts_enabled": False,
"hsts_subdomains": False,
"ssl_forced": False
}
if domain not in old_all_domains:
myLogger.info_logger("delete domain is not binded")
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "Domain is not bind.", "")
requests.put(url, data=json.dumps(data), headers=headers)
#set_domain("", app_id)
myLogger.info_logger("Start to delete " + domain)
proxy = get_proxy_domain(app_id, domain)
if proxy != None:
myLogger.info_logger(proxy)
myLogger.info_logger("before update")
domains_old = proxy["domain_names"]
myLogger.info_logger(domains_old)
domains_old.remove(domain)
myLogger.info_logger("after update")
myLogger.info_logger(domains_old)
if len(domains_old) == 0:
proxy_id = proxy["id"]
token = get_token()
url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
headers = {
'Authorization': token,
'Content-Type': 'application/json'
}
requests.delete(url, headers=headers)
set_domain("", app_id)
else:
proxy_id = proxy["id"]
token = get_token()
url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
headers = {
'Authorization': token,
'Content-Type': 'application/json'
}
port = get_container_port(app_id.split('_')[1])
host = app_id.split('_')[1]
data = {
"domain_names": domains_old,
"forward_scheme": "http",
"forward_host": host,
"forward_port": port,
"access_list_id": "0",
"certificate_id": 0,
"meta": {
"letsencrypt_agree": False,
"dns_challenge": False
},
"advanced_config": "",
"locations": [],
"block_exploits": False,
"caching_enabled": False,
"allow_websocket_upgrade": False,
"http2_support": False,
"hsts_enabled": False,
"hsts_subdomains": False,
"ssl_forced": False
}
requests.put(url, data=json.dumps(data), headers=headers)
#set_domain("", app_id)
else:
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "Domain is not bind", "")