FixServiceDevies
This commit is contained in:
@@ -19,6 +19,8 @@ from scheduler.scheduler import (
|
||||
remove_device_monitoring_job,
|
||||
reschedule_device_monitoring_job
|
||||
)
|
||||
from modules.monitor_config.service import create_default_monitor_config_service
|
||||
from modules.alert.service import create_default_alert_config_service
|
||||
|
||||
|
||||
def get_devices_service():
|
||||
@@ -62,11 +64,16 @@ def create_device_service(data):
|
||||
if existing_ip:
|
||||
raise DeviceIPAlreadyExistsException(data["ip_address"])
|
||||
|
||||
# 4. Insert DB (trả về thiết bị và cấu hình giám sát mặc định vừa tạo)
|
||||
new_device, monitor_config = insert_device(data)
|
||||
# 4. Insert DB (Chỉ lưu vào bảng device)
|
||||
new_device = insert_device(data)
|
||||
|
||||
# 5. Kích hoạt Job giám sát trên Background Scheduler
|
||||
# Truyền kèm cấu hình giám sát mặc định thay vì None để Scheduler lập lịch
|
||||
# 5. Tạo cấu hình giám sát mặc định (thuộc module monitor_config)
|
||||
monitor_config = create_default_monitor_config_service(new_device["id"])
|
||||
|
||||
# 6. Tạo cấu hình cảnh báo mặc định (thuộc module alert)
|
||||
create_default_alert_config_service(new_device["id"])
|
||||
|
||||
# 7. Kích hoạt Job giám sát trên Background Scheduler
|
||||
add_device_monitoring_job(new_device["id"], monitor_config)
|
||||
|
||||
return new_device
|
||||
|
||||
Reference in New Issue
Block a user