From ca85f71f2b3701df41c8db7d8daa8464a657ddd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Wed, 18 Aug 2021 17:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9IP=E5=8F=AF=E4=BB=A5=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/nodeconfigs/node_ip_addr.go | 13 ++++ pkg/nodeconfigs/node_value_item.go | 9 +++ pkg/rpc/pb/service_node_ip_address.pb.go | 71 +++++++++++++------- pkg/rpc/protos/service_node_ip_address.proto | 2 + 4 files changed, 70 insertions(+), 25 deletions(-) create mode 100644 pkg/nodeconfigs/node_ip_addr.go diff --git a/pkg/nodeconfigs/node_ip_addr.go b/pkg/nodeconfigs/node_ip_addr.go new file mode 100644 index 0000000..765b889 --- /dev/null +++ b/pkg/nodeconfigs/node_ip_addr.go @@ -0,0 +1,13 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package nodeconfigs + +type NodeIPAddr struct { + Id int64 `json:"id"` + Name string `json:"name"` + Thresholds []*NodeValueThresholdConfig `json:"thresholds"` + IP string `json:"ip"` + IsOn bool `json:"isOn"` + IsUp bool `json:"isUp"` + CanAccess bool `json:"canAccess"` +} diff --git a/pkg/nodeconfigs/node_value_item.go b/pkg/nodeconfigs/node_value_item.go index da28b47..752635b 100644 --- a/pkg/nodeconfigs/node_value_item.go +++ b/pkg/nodeconfigs/node_value_item.go @@ -306,3 +306,12 @@ func UnmarshalNodeValue(valueJSON []byte) string { } return result } + +// NodeValueThresholdConfig 阈值 +type NodeValueThresholdConfig struct { + Item NodeValueItem `json:"item"` + Operator NodeValueOperator `json:"operator"` + Value int64 `json:"value"` + Duration int `json:"duration"` + DurationUnit NodeValueDurationUnit `json:"durationUnit"` +} diff --git a/pkg/rpc/pb/service_node_ip_address.pb.go b/pkg/rpc/pb/service_node_ip_address.pb.go index e049058..36d9aca 100644 --- a/pkg/rpc/pb/service_node_ip_address.pb.go +++ b/pkg/rpc/pb/service_node_ip_address.pb.go @@ -35,11 +35,12 @@ type CreateNodeIPAddressRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` - Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` - CanAccess bool `protobuf:"varint,5,opt,name=canAccess,proto3" json:"canAccess,omitempty"` + NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` + Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` + CanAccess bool `protobuf:"varint,5,opt,name=canAccess,proto3" json:"canAccess,omitempty"` + ThresholdsJSON []byte `protobuf:"bytes,6,opt,name=thresholdsJSON,proto3" json:"thresholdsJSON,omitempty"` } func (x *CreateNodeIPAddressRequest) Reset() { @@ -109,6 +110,13 @@ func (x *CreateNodeIPAddressRequest) GetCanAccess() bool { return false } +func (x *CreateNodeIPAddressRequest) GetThresholdsJSON() []byte { + if x != nil { + return x.ThresholdsJSON + } + return nil +} + type CreateNodeIPAddressResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -162,11 +170,12 @@ type UpdateNodeIPAddressRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AddressId int64 `protobuf:"varint,1,opt,name=addressId,proto3" json:"addressId,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"` - CanAccess bool `protobuf:"varint,4,opt,name=canAccess,proto3" json:"canAccess,omitempty"` - IsOn bool `protobuf:"varint,5,opt,name=isOn,proto3" json:"isOn,omitempty"` + AddressId int64 `protobuf:"varint,1,opt,name=addressId,proto3" json:"addressId,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"` + CanAccess bool `protobuf:"varint,4,opt,name=canAccess,proto3" json:"canAccess,omitempty"` + IsOn bool `protobuf:"varint,5,opt,name=isOn,proto3" json:"isOn,omitempty"` + ThresholdsJSON []byte `protobuf:"bytes,6,opt,name=thresholdsJSON,proto3" json:"thresholdsJSON,omitempty"` } func (x *UpdateNodeIPAddressRequest) Reset() { @@ -236,6 +245,13 @@ func (x *UpdateNodeIPAddressRequest) GetIsOn() bool { return false } +func (x *UpdateNodeIPAddressRequest) GetThresholdsJSON() []byte { + if x != nil { + return x.ThresholdsJSON + } + return nil +} + // 修改IP地址所属节点 type UpdateNodeIPAddressNodeIdRequest struct { state protoimpl.MessageState @@ -679,7 +695,7 @@ var file_service_node_ip_address_proto_rawDesc = []byte{ 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x8a, 0x01, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, + 0x74, 0x6f, 0x22, 0xb2, 0x01, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, @@ -687,20 +703,25 @@ var file_service_node_ip_address_proto_rawDesc = []byte{ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, - 0x3b, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, - 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1c, 0x0a, - 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x69, - 0x73, 0x4f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x22, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, + 0x26, 0x0a, 0x0e, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x73, 0x4a, 0x53, 0x4f, + 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, + 0x6c, 0x64, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x22, 0x3b, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x49, 0x64, 0x22, 0xb8, 0x01, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x63, 0x61, 0x6e, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x74, 0x68, 0x72, 0x65, 0x73, + 0x68, 0x6f, 0x6c, 0x64, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0e, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x22, 0x58, 0x0a, 0x20, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x50, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x64, diff --git a/pkg/rpc/protos/service_node_ip_address.proto b/pkg/rpc/protos/service_node_ip_address.proto index baa61c9..6e9115f 100644 --- a/pkg/rpc/protos/service_node_ip_address.proto +++ b/pkg/rpc/protos/service_node_ip_address.proto @@ -36,6 +36,7 @@ message CreateNodeIPAddressRequest { string name = 3; string ip = 4; bool canAccess = 5; + bytes thresholdsJSON = 6; } message CreateNodeIPAddressResponse { @@ -49,6 +50,7 @@ message UpdateNodeIPAddressRequest { string ip = 3; bool canAccess = 4; bool isOn = 5; + bytes thresholdsJSON = 6; } // 修改IP地址所属节点