mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-23 18:00:27 +08:00
实现健康检查配置、立即执行健康检查
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package ipaddressutils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
// 保存一组IP地址
|
||||
func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64, ipAddressesJSON []byte) error {
|
||||
addresses := []maps.Map{}
|
||||
err := json.Unmarshal(ipAddressesJSON, &addresses)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, addr := range addresses {
|
||||
addrId := addr.GetInt64("id")
|
||||
if addrId > 0 {
|
||||
_, err = parentAction.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(parentAction.AdminContext(), &pb.UpdateNodeIPAddressRequest{
|
||||
AddressId: addrId,
|
||||
Ip: addr.GetString("ip"),
|
||||
Name: addr.GetString("name"),
|
||||
CanAccess: addr.GetBool("canAccess"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
_, err = parentAction.RPC().NodeIPAddressRPC().CreateNodeIPAddress(parentAction.AdminContext(), &pb.CreateNodeIPAddressRequest{
|
||||
NodeId: nodeId,
|
||||
Name: addr.GetString("name"),
|
||||
Ip: addr.GetString("ip"),
|
||||
CanAccess: addr.GetBool("canAccess"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user