删除同步域名信息相关的调试日志
This commit is contained in:
parent
7e7976942a
commit
7a4bd92710
@ -2616,28 +2616,21 @@ def west_domain_modify_dns_server(**data):
|
|||||||
@jingrow.whitelist()
|
@jingrow.whitelist()
|
||||||
def sync_domain_info_from_west(**data):
|
def sync_domain_info_from_west(**data):
|
||||||
"""从西部数据同步域名信息"""
|
"""从西部数据同步域名信息"""
|
||||||
jingrow.log_error("域名同步", f"开始同步域名信息,参数: {data}")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = get_west_client()
|
client = get_west_client()
|
||||||
if not client:
|
if not client:
|
||||||
jingrow.log_error("域名同步", "API客户端初始化失败")
|
|
||||||
return {"status": "error", "message": "API客户端初始化失败"}
|
return {"status": "error", "message": "API客户端初始化失败"}
|
||||||
|
|
||||||
domain = data.get('domain')
|
domain = data.get('domain')
|
||||||
if not domain:
|
if not domain:
|
||||||
jingrow.log_error("域名同步", "缺少域名参数")
|
|
||||||
return {"status": "error", "message": "缺少域名参数"}
|
return {"status": "error", "message": "缺少域名参数"}
|
||||||
|
|
||||||
jingrow.log_error("域名同步", f"开始同步域名: {domain}")
|
|
||||||
|
|
||||||
# 获取域名DNS记录 - 参考get_west_domain_dns_records使用分页API
|
# 获取域名DNS记录 - 参考get_west_domain_dns_records使用分页API
|
||||||
dns_response = client.get_dns_records_paginated(domain, 1000, 1) # 获取足够多的记录
|
dns_response = client.get_dns_records_paginated(domain, 1000, 1) # 获取足够多的记录
|
||||||
jingrow.log_error("域名同步", f"域名DNS记录响应: {dns_response}")
|
|
||||||
|
|
||||||
# 获取域名实名信息
|
# 获取域名实名信息
|
||||||
real_info_response = client.get_domain_real_info(domain)
|
real_info_response = client.get_domain_real_info(domain)
|
||||||
jingrow.log_error("域名同步", f"域名实名信息响应: {real_info_response}")
|
|
||||||
|
|
||||||
# 处理DNS记录 - 参考get_west_domain_dns_records的处理方式
|
# 处理DNS记录 - 参考get_west_domain_dns_records的处理方式
|
||||||
dns_data = {}
|
dns_data = {}
|
||||||
@ -2655,31 +2648,28 @@ def sync_domain_info_from_west(**data):
|
|||||||
|
|
||||||
# 更新本地域名记录
|
# 更新本地域名记录
|
||||||
try:
|
try:
|
||||||
domain_doc = jingrow.get_pg("Jsite Domain", {"domain": domain})
|
domain_pg = jingrow.get_pg("Jsite Domain", {"domain": domain})
|
||||||
if not domain_doc:
|
if not domain_pg:
|
||||||
return {"status": "error", "message": "本地未找到该域名记录"}
|
return {"status": "error", "message": "本地未找到该域名记录"}
|
||||||
|
|
||||||
# 更新基本信息 - 从实名信息中获取
|
# 更新基本信息 - 从实名信息中获取
|
||||||
if real_data:
|
if real_data:
|
||||||
domain_doc.registration_date = real_data.get("regdate")
|
domain_pg.registration_date = real_data.get("regdate")
|
||||||
domain_doc.end_date = real_data.get("rexpiredate")
|
domain_pg.end_date = real_data.get("rexpiredate")
|
||||||
domain_doc.status = "Active" if real_data.get("status") == "ok" else "Expired"
|
domain_pg.status = "Active" if real_data.get("status") == "ok" else "Expired"
|
||||||
|
|
||||||
# 更新DNS服务器信息
|
# 更新DNS服务器信息
|
||||||
domain_doc.dns_host1 = real_data.get("dns_host1", "")
|
domain_pg.dns_host1 = real_data.get("dns_host1", "")
|
||||||
domain_doc.dns_host2 = real_data.get("dns_host2", "")
|
domain_pg.dns_host2 = real_data.get("dns_host2", "")
|
||||||
domain_doc.dns_host3 = real_data.get("dns_host3", "")
|
domain_pg.dns_host3 = real_data.get("dns_host3", "")
|
||||||
domain_doc.dns_host4 = real_data.get("dns_host4", "")
|
domain_pg.dns_host4 = real_data.get("dns_host4", "")
|
||||||
domain_doc.dns_host5 = real_data.get("dns_host5", "")
|
domain_pg.dns_host5 = real_data.get("dns_host5", "")
|
||||||
domain_doc.dns_host6 = real_data.get("dns_host6", "")
|
domain_pg.dns_host6 = real_data.get("dns_host6", "")
|
||||||
|
|
||||||
jingrow.log_error("域名同步", f"更新基本信息: 注册日期={real_data.get('regdate')}, 到期日期={real_data.get('rexpiredate')}")
|
|
||||||
|
|
||||||
# 更新DNS解析记录
|
# 更新DNS解析记录
|
||||||
if dns_data and "items" in dns_data:
|
if dns_data and "items" in dns_data:
|
||||||
jingrow.log_error("域名同步", f"正在更新DNS解析记录,共{len(dns_data.get('items', []))}条记录")
|
|
||||||
# 清空现有DNS解析记录
|
# 清空现有DNS解析记录
|
||||||
domain_doc.dns_resolution = []
|
domain_pg.dns_resolution = []
|
||||||
|
|
||||||
# 添加新的DNS解析记录
|
# 添加新的DNS解析记录
|
||||||
for record in dns_data.get("items", []):
|
for record in dns_data.get("items", []):
|
||||||
@ -2690,7 +2680,7 @@ def sync_domain_info_from_west(**data):
|
|||||||
|
|
||||||
# 只有当必需字段都有值时才添加记录
|
# 只有当必需字段都有值时才添加记录
|
||||||
if host and record_type and value:
|
if host and record_type and value:
|
||||||
domain_doc.append("dns_resolution", {
|
domain_pg.append("dns_resolution", {
|
||||||
"type": record_type,
|
"type": record_type,
|
||||||
"host": host,
|
"host": host,
|
||||||
"value": value,
|
"value": value,
|
||||||
@ -2700,16 +2690,9 @@ def sync_domain_info_from_west(**data):
|
|||||||
"record_id": record.get("id", ""),
|
"record_id": record.get("id", ""),
|
||||||
"record_status": record.get("status", "")
|
"record_status": record.get("status", "")
|
||||||
})
|
})
|
||||||
jingrow.log_error("域名同步", f"添加DNS记录: {host} {record_type} {value}")
|
|
||||||
else:
|
|
||||||
jingrow.log_error("域名同步", f"跳过无效DNS记录: {record}")
|
|
||||||
|
|
||||||
jingrow.log_error("域名同步", f"DNS解析记录更新完成")
|
|
||||||
|
|
||||||
# 保存更新
|
# 保存更新
|
||||||
domain_doc.save()
|
domain_pg.save()
|
||||||
|
|
||||||
jingrow.log_error("域名同步", f"域名 {domain} 同步成功")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
@ -2721,11 +2704,9 @@ def sync_domain_info_from_west(**data):
|
|||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
jingrow.log_error("域名信息同步失败", f"域名: {domain}, 错误: {str(e)}")
|
|
||||||
return {"status": "error", "message": f"更新本地记录失败: {str(e)}"}
|
return {"status": "error", "message": f"更新本地记录失败: {str(e)}"}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
jingrow.log_error("域名信息同步失败", f"域名: {domain}, 错误: {str(e)}")
|
|
||||||
return {"status": "error", "message": f"同步失败: {str(e)}"}
|
return {"status": "error", "message": f"同步失败: {str(e)}"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,35 +6,21 @@ jingrow.ui.form.on("Jsite Domain", {
|
|||||||
// 添加同步按钮到右上角
|
// 添加同步按钮到右上角
|
||||||
frm.add_custom_button(__('同步域名信息'), function() {
|
frm.add_custom_button(__('同步域名信息'), function() {
|
||||||
sync_domain_info(frm);
|
sync_domain_info(frm);
|
||||||
}, __('操作'));
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 同步域名信息函数
|
// 同步域名信息函数
|
||||||
function sync_domain_info(frm) {
|
function sync_domain_info(frm) {
|
||||||
console.log('=== 开始同步域名信息 ===');
|
|
||||||
console.log('当前记录:', frm.pg);
|
|
||||||
console.log('域名字段:', frm.pg.domain);
|
|
||||||
|
|
||||||
if (!frm.pg.domain) {
|
if (!frm.pg.domain) {
|
||||||
console.log('❌ 域名字段为空');
|
|
||||||
jingrow.msgprint(__('当前记录没有域名信息'));
|
jingrow.msgprint(__('当前记录没有域名信息'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('✅ 域名字段存在:', frm.pg.domain);
|
|
||||||
|
|
||||||
// 显示加载状态
|
// 显示加载状态
|
||||||
frm.dashboard.clear_headline();
|
frm.dashboard.clear_headline();
|
||||||
frm.dashboard.set_headline(__('正在同步域名信息...'));
|
frm.dashboard.set_headline(__('正在同步域名信息...'));
|
||||||
|
|
||||||
console.log('准备调用API,参数:', {
|
|
||||||
method: 'jcloud.api.domain_west.sync_domain_info_from_west',
|
|
||||||
args: {
|
|
||||||
domain: frm.pg.domain
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 调用API同步域名信息
|
// 调用API同步域名信息
|
||||||
jingrow.call({
|
jingrow.call({
|
||||||
method: 'jcloud.api.domain_west.sync_domain_info_from_west',
|
method: 'jcloud.api.domain_west.sync_domain_info_from_west',
|
||||||
@ -42,22 +28,19 @@ function sync_domain_info(frm) {
|
|||||||
domain: frm.pg.domain
|
domain: frm.pg.domain
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
console.log('API调用成功,响应:', r);
|
|
||||||
frm.dashboard.clear_headline();
|
frm.dashboard.clear_headline();
|
||||||
|
|
||||||
// 检查响应结构
|
// 检查响应结构
|
||||||
if (r && r.message && r.message.status === 'success') {
|
if (r && r.message && r.message.status === 'success') {
|
||||||
console.log('✅ 同步成功');
|
|
||||||
jingrow.msgprint({
|
jingrow.msgprint({
|
||||||
title: __('同步成功'),
|
title: __('同步成功'),
|
||||||
message: __('域名信息已成功从西部数据同步'),
|
message: __('域名信息已成功同步'),
|
||||||
indicator: 'green'
|
indicator: 'green'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 刷新页面以显示更新后的数据
|
// 刷新页面以显示更新后的数据
|
||||||
frm.refresh();
|
frm.refresh();
|
||||||
} else {
|
} else {
|
||||||
console.log('❌ 同步失败:', r);
|
|
||||||
jingrow.msgprint({
|
jingrow.msgprint({
|
||||||
title: __('同步失败'),
|
title: __('同步失败'),
|
||||||
message: (r && r.message && r.message.message) || __('同步域名信息时发生错误'),
|
message: (r && r.message && r.message.message) || __('同步域名信息时发生错误'),
|
||||||
@ -66,7 +49,6 @@ function sync_domain_info(frm) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(err) {
|
error: function(err) {
|
||||||
console.log('❌ API调用失败:', err);
|
|
||||||
frm.dashboard.clear_headline();
|
frm.dashboard.clear_headline();
|
||||||
jingrow.msgprint({
|
jingrow.msgprint({
|
||||||
title: __('同步失败'),
|
title: __('同步失败'),
|
||||||
@ -75,6 +57,4 @@ function sync_domain_info(frm) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('API调用已发送');
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user