Initial commit (code only without large binaries)
This commit is contained in:
54
EdgeAPI/internal/db/models/node_model_ext_plus.go
Normal file
54
EdgeAPI/internal/db/models/node_model_ext_plus.go
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
)
|
||||
|
||||
// DecodeBackupIPs 解析备用IP
|
||||
func (this *Node) DecodeBackupIPs() []string {
|
||||
var result = []string{}
|
||||
if IsNotNull(this.BackupIPs) {
|
||||
err := json.Unmarshal(this.BackupIPs, &result)
|
||||
if err != nil {
|
||||
remotelogs.Error("Node", "DecodeBackupIPs(): "+err.Error())
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// DecodeActionStatus 解析动作状态
|
||||
func (this *Node) DecodeActionStatus() *nodeconfigs.NodeActionStatus {
|
||||
var status = &nodeconfigs.NodeActionStatus{}
|
||||
if len(this.ActionStatus) > 0 {
|
||||
err := json.Unmarshal(this.ActionStatus, status)
|
||||
if err != nil {
|
||||
remotelogs.Error("Node", "DecodeActionStatus(): "+err.Error())
|
||||
}
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// HasScheduleSettings 检查是否设置了调度
|
||||
func (this *Node) HasScheduleSettings() bool {
|
||||
if len(this.OfflineDay) > 0 {
|
||||
return true
|
||||
}
|
||||
if this.IsBackupForCluster || this.IsBackupForGroup {
|
||||
return true
|
||||
}
|
||||
if len(this.DecodeBackupIPs()) > 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
countActions, err := SharedNodeActionDAO.CountNodeActions(nil, nodeconfigs.NodeRoleNode, int64(this.Id))
|
||||
if err != nil {
|
||||
remotelogs.Error("Node", "HasScheduleSettings(): "+err.Error())
|
||||
return false
|
||||
}
|
||||
return countActions > 0
|
||||
}
|
||||
Reference in New Issue
Block a user