main #2
@ -1567,11 +1567,13 @@ def update_server_record(instance_ids):
|
||||
server.plan_price = float(plan['origin_price'])
|
||||
break
|
||||
|
||||
sync_firewall_rules(instance_id)
|
||||
# 保存更新
|
||||
server.save(ignore_permissions=True)
|
||||
jingrow.db.commit()
|
||||
|
||||
# 同步防火墙规则(在保存服务器信息之后)
|
||||
sync_firewall_rules(instance_id)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"message": "服务器信息更新成功",
|
||||
|
||||
@ -117,6 +117,16 @@ jingrow.ui.form.on("Jsite Server", {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
frm.add_custom_button(__('同步服务器数据'), function() {
|
||||
// 弹出确认对话框
|
||||
jingrow.confirm(
|
||||
__('确定要同步服务器数据吗?这将从阿里云同步最新的服务器信息,包括状态、IP地址、系统信息、规格和防火墙规则等。'),
|
||||
function() {
|
||||
sync_server_data(frm);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// 为password字段添加眼睛图标
|
||||
@ -258,3 +268,29 @@ function sync_firewall_rules(frm) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sync_server_data(frm) {
|
||||
jingrow.call({
|
||||
method: 'jcloud.api.aliyun_server_light.update_server_record',
|
||||
args: {
|
||||
instance_ids: JSON.stringify([frm.pg.instance_id])
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r.message && r.message.success) {
|
||||
jingrow.msgprint({
|
||||
title: __('成功'),
|
||||
message: r.message.message || __('服务器数据同步成功'),
|
||||
indicator: 'green'
|
||||
});
|
||||
// 刷新表单以显示最新的服务器数据
|
||||
frm.reload_pg();
|
||||
} else {
|
||||
jingrow.msgprint({
|
||||
title: __('错误'),
|
||||
message: r.message ? r.message.message : __('同步服务器数据失败'),
|
||||
indicator: 'red'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user