diff --git a/api/proto/gosdnCLI.pb.go b/api/proto/gosdnCLI.pb.go index 2095a2771e811732b7ef6b56b75930e7e21d27e7..62d48d12717bcf3c036da4dfebc74546d248f3f4 100644 --- a/api/proto/gosdnCLI.pb.go +++ b/api/proto/gosdnCLI.pb.go @@ -1,13 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.23.0 -// protoc v3.13.0 -// source: cliInterface/gosdnCLI.proto +// protoc-gen-go v1.25.0-devel +// protoc v3.12.4 +// source: gosdnCLI.proto package gosdn import ( + context "context" proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -37,7 +42,7 @@ type HelloRequest struct { func (x *HelloRequest) Reset() { *x = HelloRequest{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[0] + mi := &file_gosdnCLI_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -50,7 +55,7 @@ func (x *HelloRequest) String() string { func (*HelloRequest) ProtoMessage() {} func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[0] + mi := &file_gosdnCLI_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -63,7 +68,7 @@ func (x *HelloRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{0} + return file_gosdnCLI_proto_rawDescGZIP(), []int{0} } func (x *HelloRequest) GetName() string { @@ -86,7 +91,7 @@ type HelloReply struct { func (x *HelloReply) Reset() { *x = HelloReply{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[1] + mi := &file_gosdnCLI_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -99,7 +104,7 @@ func (x *HelloReply) String() string { func (*HelloReply) ProtoMessage() {} func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[1] + mi := &file_gosdnCLI_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -112,7 +117,7 @@ func (x *HelloReply) ProtoReflect() protoreflect.Message { // Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. func (*HelloReply) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{1} + return file_gosdnCLI_proto_rawDescGZIP(), []int{1} } func (x *HelloReply) GetMessage() string { @@ -141,7 +146,7 @@ type ShutdownRequest struct { func (x *ShutdownRequest) Reset() { *x = ShutdownRequest{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[2] + mi := &file_gosdnCLI_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -154,7 +159,7 @@ func (x *ShutdownRequest) String() string { func (*ShutdownRequest) ProtoMessage() {} func (x *ShutdownRequest) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[2] + mi := &file_gosdnCLI_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -167,7 +172,7 @@ func (x *ShutdownRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ShutdownRequest.ProtoReflect.Descriptor instead. func (*ShutdownRequest) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{2} + return file_gosdnCLI_proto_rawDescGZIP(), []int{2} } func (x *ShutdownRequest) GetName() string { @@ -189,7 +194,7 @@ type ShutdownReply struct { func (x *ShutdownReply) Reset() { *x = ShutdownReply{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[3] + mi := &file_gosdnCLI_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -202,7 +207,7 @@ func (x *ShutdownReply) String() string { func (*ShutdownReply) ProtoMessage() {} func (x *ShutdownReply) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[3] + mi := &file_gosdnCLI_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -215,7 +220,7 @@ func (x *ShutdownReply) ProtoReflect() protoreflect.Message { // Deprecated: Use ShutdownReply.ProtoReflect.Descriptor instead. func (*ShutdownReply) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{3} + return file_gosdnCLI_proto_rawDescGZIP(), []int{3} } func (x *ShutdownReply) GetMessage() string { @@ -237,7 +242,7 @@ type TAPIRequest struct { func (x *TAPIRequest) Reset() { *x = TAPIRequest{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[4] + mi := &file_gosdnCLI_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -250,7 +255,7 @@ func (x *TAPIRequest) String() string { func (*TAPIRequest) ProtoMessage() {} func (x *TAPIRequest) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[4] + mi := &file_gosdnCLI_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -263,7 +268,7 @@ func (x *TAPIRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TAPIRequest.ProtoReflect.Descriptor instead. func (*TAPIRequest) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{4} + return file_gosdnCLI_proto_rawDescGZIP(), []int{4} } func (x *TAPIRequest) GetName() string { @@ -285,7 +290,7 @@ type TAPIReply struct { func (x *TAPIReply) Reset() { *x = TAPIReply{} if protoimpl.UnsafeEnabled { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[5] + mi := &file_gosdnCLI_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -298,7 +303,7 @@ func (x *TAPIReply) String() string { func (*TAPIReply) ProtoMessage() {} func (x *TAPIReply) ProtoReflect() protoreflect.Message { - mi := &file_cliInterface_gosdnCLI_proto_msgTypes[5] + mi := &file_gosdnCLI_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -311,7 +316,7 @@ func (x *TAPIReply) ProtoReflect() protoreflect.Message { // Deprecated: Use TAPIReply.ProtoReflect.Descriptor instead. func (*TAPIReply) Descriptor() ([]byte, []int) { - return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{5} + return file_gosdnCLI_proto_rawDescGZIP(), []int{5} } func (x *TAPIReply) GetMessage() string { @@ -321,105 +326,159 @@ func (x *TAPIReply) GetMessage() string { return "" } -var File_cliInterface_gosdnCLI_proto protoreflect.FileDescriptor - -var file_cliInterface_gosdnCLI_proto_rawDesc = []byte{ - 0x0a, 0x1b, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2f, 0x67, - 0x6f, 0x73, 0x64, 0x6e, 0x43, 0x4c, 0x49, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x63, - 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x22, 0x22, 0x0a, 0x0c, 0x48, - 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x44, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x6f, 0x53, 0x44, 0x4e, - 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x53, 0x44, - 0x4e, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x25, 0x0a, 0x0f, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, - 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x21, 0x0a, 0x0b, 0x54, 0x41, 0x50, 0x49, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x09, 0x54, 0x41, - 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x32, 0xea, 0x02, 0x0a, 0x07, 0x47, 0x72, 0x70, 0x63, 0x43, 0x6c, 0x69, 0x12, 0x42, 0x0a, - 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x1a, 0x2e, 0x63, 0x6c, 0x69, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x66, 0x61, 0x63, 0x65, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, - 0x00, 0x12, 0x48, 0x0a, 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x1d, 0x2e, - 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x75, - 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x63, - 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x75, 0x74, - 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0b, 0x54, - 0x41, 0x50, 0x49, 0x47, 0x65, 0x74, 0x45, 0x64, 0x67, 0x65, 0x12, 0x19, 0x2e, 0x63, 0x6c, 0x69, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, - 0x12, 0x47, 0x0a, 0x0f, 0x54, 0x41, 0x50, 0x49, 0x47, 0x65, 0x74, 0x45, 0x64, 0x67, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x12, 0x19, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, - 0x63, 0x65, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, - 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x41, - 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0b, 0x54, 0x41, 0x50, - 0x49, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x19, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, - 0x63, 0x65, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x50, - 0x0a, 0x1e, 0x64, 0x65, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x67, 0x6f, - 0x73, 0x64, 0x6e, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x42, 0x0c, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x50, 0x01, - 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, - 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x63, 0x6f, 0x63, 0x73, 0x6e, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +// The response message containing a string with a goSDN log +type LogReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Log string `protobuf:"bytes,1,opt,name=log,proto3" json:"log,omitempty"` +} + +func (x *LogReply) Reset() { + *x = LogReply{} + if protoimpl.UnsafeEnabled { + mi := &file_gosdnCLI_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LogReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogReply) ProtoMessage() {} + +func (x *LogReply) ProtoReflect() protoreflect.Message { + mi := &file_gosdnCLI_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogReply.ProtoReflect.Descriptor instead. +func (*LogReply) Descriptor() ([]byte, []int) { + return file_gosdnCLI_proto_rawDescGZIP(), []int{6} +} + +func (x *LogReply) GetLog() string { + if x != nil { + return x.Log + } + return "" +} + +var File_gosdnCLI_proto protoreflect.FileDescriptor + +var file_gosdnCLI_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x43, 0x4c, 0x49, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x44, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x6f, 0x53, 0x44, 0x4e, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x53, 0x44, 0x4e, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x25, + 0x0a, 0x0f, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x0d, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, + 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x22, 0x21, 0x0a, 0x0b, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x09, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, + 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x1c, 0x0a, 0x08, 0x4c, 0x6f, + 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x32, 0xe4, 0x02, 0x0a, 0x07, 0x47, 0x72, 0x70, + 0x63, 0x43, 0x6c, 0x69, 0x12, 0x34, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, + 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, + 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x68, + 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, + 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4c, 0x6f, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0b, 0x54, 0x41, 0x50, 0x49, 0x47, 0x65, + 0x74, 0x45, 0x64, 0x67, 0x65, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x41, + 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, + 0x0f, 0x54, 0x41, 0x50, 0x49, 0x47, 0x65, 0x74, 0x45, 0x64, 0x67, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x41, 0x50, + 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0b, 0x54, 0x41, 0x50, 0x49, + 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x41, 0x50, 0x49, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, + 0x50, 0x0a, 0x1e, 0x64, 0x65, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x67, + 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, + 0x65, 0x42, 0x0c, 0x63, 0x6c, 0x69, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x50, + 0x01, 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, + 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x63, 0x6f, 0x63, 0x73, 0x6e, 0x2f, 0x67, 0x6f, 0x73, 0x64, + 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_cliInterface_gosdnCLI_proto_rawDescOnce sync.Once - file_cliInterface_gosdnCLI_proto_rawDescData = file_cliInterface_gosdnCLI_proto_rawDesc + file_gosdnCLI_proto_rawDescOnce sync.Once + file_gosdnCLI_proto_rawDescData = file_gosdnCLI_proto_rawDesc ) -func file_cliInterface_gosdnCLI_proto_rawDescGZIP() []byte { - file_cliInterface_gosdnCLI_proto_rawDescOnce.Do(func() { - file_cliInterface_gosdnCLI_proto_rawDescData = protoimpl.X.CompressGZIP(file_cliInterface_gosdnCLI_proto_rawDescData) +func file_gosdnCLI_proto_rawDescGZIP() []byte { + file_gosdnCLI_proto_rawDescOnce.Do(func() { + file_gosdnCLI_proto_rawDescData = protoimpl.X.CompressGZIP(file_gosdnCLI_proto_rawDescData) }) - return file_cliInterface_gosdnCLI_proto_rawDescData -} - -var file_cliInterface_gosdnCLI_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_cliInterface_gosdnCLI_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: cliInterface.HelloRequest - (*HelloReply)(nil), // 1: cliInterface.HelloReply - (*ShutdownRequest)(nil), // 2: cliInterface.ShutdownRequest - (*ShutdownReply)(nil), // 3: cliInterface.ShutdownReply - (*TAPIRequest)(nil), // 4: cliInterface.TAPIRequest - (*TAPIReply)(nil), // 5: cliInterface.TAPIReply -} -var file_cliInterface_gosdnCLI_proto_depIdxs = []int32{ - 0, // 0: cliInterface.GrpcCli.SayHello:input_type -> cliInterface.HelloRequest - 2, // 1: cliInterface.GrpcCli.Shutdown:input_type -> cliInterface.ShutdownRequest - 4, // 2: cliInterface.GrpcCli.TAPIGetEdge:input_type -> cliInterface.TAPIRequest - 4, // 3: cliInterface.GrpcCli.TAPIGetEdgeNode:input_type -> cliInterface.TAPIRequest - 4, // 4: cliInterface.GrpcCli.TAPIGetLink:input_type -> cliInterface.TAPIRequest - 1, // 5: cliInterface.GrpcCli.SayHello:output_type -> cliInterface.HelloReply - 3, // 6: cliInterface.GrpcCli.Shutdown:output_type -> cliInterface.ShutdownReply - 5, // 7: cliInterface.GrpcCli.TAPIGetEdge:output_type -> cliInterface.TAPIReply - 5, // 8: cliInterface.GrpcCli.TAPIGetEdgeNode:output_type -> cliInterface.TAPIReply - 5, // 9: cliInterface.GrpcCli.TAPIGetLink:output_type -> cliInterface.TAPIReply - 5, // [5:10] is the sub-list for method output_type - 0, // [0:5] is the sub-list for method input_type + return file_gosdnCLI_proto_rawDescData +} + +var file_gosdnCLI_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_gosdnCLI_proto_goTypes = []interface{}{ + (*HelloRequest)(nil), // 0: proto.HelloRequest + (*HelloReply)(nil), // 1: proto.HelloReply + (*ShutdownRequest)(nil), // 2: proto.ShutdownRequest + (*ShutdownReply)(nil), // 3: proto.ShutdownReply + (*TAPIRequest)(nil), // 4: proto.TAPIRequest + (*TAPIReply)(nil), // 5: proto.TAPIReply + (*LogReply)(nil), // 6: proto.LogReply + (*empty.Empty)(nil), // 7: google.protobuf.Empty +} +var file_gosdnCLI_proto_depIdxs = []int32{ + 0, // 0: proto.GrpcCli.SayHello:input_type -> proto.HelloRequest + 2, // 1: proto.GrpcCli.Shutdown:input_type -> proto.ShutdownRequest + 7, // 2: proto.GrpcCli.CreateLogStream:input_type -> google.protobuf.Empty + 4, // 3: proto.GrpcCli.TAPIGetEdge:input_type -> proto.TAPIRequest + 4, // 4: proto.GrpcCli.TAPIGetEdgeNode:input_type -> proto.TAPIRequest + 4, // 5: proto.GrpcCli.TAPIGetLink:input_type -> proto.TAPIRequest + 1, // 6: proto.GrpcCli.SayHello:output_type -> proto.HelloReply + 3, // 7: proto.GrpcCli.Shutdown:output_type -> proto.ShutdownReply + 6, // 8: proto.GrpcCli.CreateLogStream:output_type -> proto.LogReply + 5, // 9: proto.GrpcCli.TAPIGetEdge:output_type -> proto.TAPIReply + 5, // 10: proto.GrpcCli.TAPIGetEdgeNode:output_type -> proto.TAPIReply + 5, // 11: proto.GrpcCli.TAPIGetLink:output_type -> proto.TAPIReply + 6, // [6:12] is the sub-list for method output_type + 0, // [0:6] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } -func init() { file_cliInterface_gosdnCLI_proto_init() } -func file_cliInterface_gosdnCLI_proto_init() { - if File_cliInterface_gosdnCLI_proto != nil { +func init() { file_gosdnCLI_proto_init() } +func file_gosdnCLI_proto_init() { + if File_gosdnCLI_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_cliInterface_gosdnCLI_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelloRequest); i { case 0: return &v.state @@ -431,7 +490,7 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } - file_cliInterface_gosdnCLI_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelloReply); i { case 0: return &v.state @@ -443,7 +502,7 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } - file_cliInterface_gosdnCLI_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShutdownRequest); i { case 0: return &v.state @@ -455,7 +514,7 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } - file_cliInterface_gosdnCLI_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShutdownReply); i { case 0: return &v.state @@ -467,7 +526,7 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } - file_cliInterface_gosdnCLI_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TAPIRequest); i { case 0: return &v.state @@ -479,7 +538,7 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } - file_cliInterface_gosdnCLI_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_gosdnCLI_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TAPIReply); i { case 0: return &v.state @@ -491,23 +550,337 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } + file_gosdnCLI_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LogReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_cliInterface_gosdnCLI_proto_rawDesc, + RawDescriptor: file_gosdnCLI_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_cliInterface_gosdnCLI_proto_goTypes, - DependencyIndexes: file_cliInterface_gosdnCLI_proto_depIdxs, - MessageInfos: file_cliInterface_gosdnCLI_proto_msgTypes, + GoTypes: file_gosdnCLI_proto_goTypes, + DependencyIndexes: file_gosdnCLI_proto_depIdxs, + MessageInfos: file_gosdnCLI_proto_msgTypes, }.Build() - File_cliInterface_gosdnCLI_proto = out.File - file_cliInterface_gosdnCLI_proto_rawDesc = nil - file_cliInterface_gosdnCLI_proto_goTypes = nil - file_cliInterface_gosdnCLI_proto_depIdxs = nil + File_gosdnCLI_proto = out.File + file_gosdnCLI_proto_rawDesc = nil + file_gosdnCLI_proto_goTypes = nil + file_gosdnCLI_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// GrpcCliClient is the client API for GrpcCli service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GrpcCliClient interface { + // Sends a greeting + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) + // Shutdown goSDN + Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) + // creates a stream to receive goSDN logs + CreateLogStream(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (GrpcCli_CreateLogStreamClient, error) + // By now solely TAPI specific calls can be issued from the grpc-cli + // TAPIGetEdge + TAPIGetEdge(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) + //TAPIGetEdgeNode + TAPIGetEdgeNode(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) + // TAPIGetLink + TAPIGetLink(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) +} + +type grpcCliClient struct { + cc grpc.ClientConnInterface +} + +func NewGrpcCliClient(cc grpc.ClientConnInterface) GrpcCliClient { + return &grpcCliClient{cc} +} + +func (c *grpcCliClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { + out := new(HelloReply) + err := c.cc.Invoke(ctx, "/proto.GrpcCli/SayHello", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *grpcCliClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) { + out := new(ShutdownReply) + err := c.cc.Invoke(ctx, "/proto.GrpcCli/Shutdown", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *grpcCliClient) CreateLogStream(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (GrpcCli_CreateLogStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_GrpcCli_serviceDesc.Streams[0], "/proto.GrpcCli/CreateLogStream", opts...) + if err != nil { + return nil, err + } + x := &grpcCliCreateLogStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GrpcCli_CreateLogStreamClient interface { + Recv() (*LogReply, error) + grpc.ClientStream +} + +type grpcCliCreateLogStreamClient struct { + grpc.ClientStream +} + +func (x *grpcCliCreateLogStreamClient) Recv() (*LogReply, error) { + m := new(LogReply) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *grpcCliClient) TAPIGetEdge(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { + out := new(TAPIReply) + err := c.cc.Invoke(ctx, "/proto.GrpcCli/TAPIGetEdge", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *grpcCliClient) TAPIGetEdgeNode(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { + out := new(TAPIReply) + err := c.cc.Invoke(ctx, "/proto.GrpcCli/TAPIGetEdgeNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *grpcCliClient) TAPIGetLink(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { + out := new(TAPIReply) + err := c.cc.Invoke(ctx, "/proto.GrpcCli/TAPIGetLink", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GrpcCliServer is the server API for GrpcCli service. +type GrpcCliServer interface { + // Sends a greeting + SayHello(context.Context, *HelloRequest) (*HelloReply, error) + // Shutdown goSDN + Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) + // creates a stream to receive goSDN logs + CreateLogStream(*empty.Empty, GrpcCli_CreateLogStreamServer) error + // By now solely TAPI specific calls can be issued from the grpc-cli + // TAPIGetEdge + TAPIGetEdge(context.Context, *TAPIRequest) (*TAPIReply, error) + //TAPIGetEdgeNode + TAPIGetEdgeNode(context.Context, *TAPIRequest) (*TAPIReply, error) + // TAPIGetLink + TAPIGetLink(context.Context, *TAPIRequest) (*TAPIReply, error) +} + +// UnimplementedGrpcCliServer can be embedded to have forward compatible implementations. +type UnimplementedGrpcCliServer struct { +} + +func (*UnimplementedGrpcCliServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (*UnimplementedGrpcCliServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") +} +func (*UnimplementedGrpcCliServer) CreateLogStream(*empty.Empty, GrpcCli_CreateLogStreamServer) error { + return status.Errorf(codes.Unimplemented, "method CreateLogStream not implemented") +} +func (*UnimplementedGrpcCliServer) TAPIGetEdge(context.Context, *TAPIRequest) (*TAPIReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TAPIGetEdge not implemented") +} +func (*UnimplementedGrpcCliServer) TAPIGetEdgeNode(context.Context, *TAPIRequest) (*TAPIReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TAPIGetEdgeNode not implemented") +} +func (*UnimplementedGrpcCliServer) TAPIGetLink(context.Context, *TAPIRequest) (*TAPIReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method TAPIGetLink not implemented") +} + +func RegisterGrpcCliServer(s *grpc.Server, srv GrpcCliServer) { + s.RegisterService(&_GrpcCli_serviceDesc, srv) +} + +func _GrpcCli_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HelloRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GrpcCliServer).SayHello(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GrpcCli/SayHello", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GrpcCliServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GrpcCli_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ShutdownRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GrpcCliServer).Shutdown(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GrpcCli/Shutdown", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GrpcCliServer).Shutdown(ctx, req.(*ShutdownRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GrpcCli_CreateLogStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(empty.Empty) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GrpcCliServer).CreateLogStream(m, &grpcCliCreateLogStreamServer{stream}) +} + +type GrpcCli_CreateLogStreamServer interface { + Send(*LogReply) error + grpc.ServerStream +} + +type grpcCliCreateLogStreamServer struct { + grpc.ServerStream +} + +func (x *grpcCliCreateLogStreamServer) Send(m *LogReply) error { + return x.ServerStream.SendMsg(m) +} + +func _GrpcCli_TAPIGetEdge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TAPIRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GrpcCliServer).TAPIGetEdge(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GrpcCli/TAPIGetEdge", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GrpcCliServer).TAPIGetEdge(ctx, req.(*TAPIRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GrpcCli_TAPIGetEdgeNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TAPIRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GrpcCliServer).TAPIGetEdgeNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GrpcCli/TAPIGetEdgeNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GrpcCliServer).TAPIGetEdgeNode(ctx, req.(*TAPIRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GrpcCli_TAPIGetLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TAPIRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GrpcCliServer).TAPIGetLink(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GrpcCli/TAPIGetLink", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GrpcCliServer).TAPIGetLink(ctx, req.(*TAPIRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _GrpcCli_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.GrpcCli", + HandlerType: (*GrpcCliServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _GrpcCli_SayHello_Handler, + }, + { + MethodName: "Shutdown", + Handler: _GrpcCli_Shutdown_Handler, + }, + { + MethodName: "TAPIGetEdge", + Handler: _GrpcCli_TAPIGetEdge_Handler, + }, + { + MethodName: "TAPIGetEdgeNode", + Handler: _GrpcCli_TAPIGetEdgeNode_Handler, + }, + { + MethodName: "TAPIGetLink", + Handler: _GrpcCli_TAPIGetLink_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "CreateLogStream", + Handler: _GrpcCli_CreateLogStream_Handler, + ServerStreams: true, + }, + }, + Metadata: "gosdnCLI.proto", } diff --git a/api/proto/gosdnCLI.proto b/api/proto/gosdnCLI.proto index fa76e03959152bed3829ff5f8e70b5379e3becca..0e3636675e4f584194cbad5414ddd28ba3156520 100644 --- a/api/proto/gosdnCLI.proto +++ b/api/proto/gosdnCLI.proto @@ -1,4 +1,5 @@ syntax = "proto3"; +import "google/protobuf/empty.proto"; option go_package = "gitlab.fbi.h-da.de/cocsn/gosdn"; option java_multiple_files = true; @@ -6,7 +7,7 @@ option java_package = "de.h-da.fbi.gosdn.cliInterface"; option java_outer_classname = "cliInterface"; -package cliInterface; +package proto; // The greeting service definition. service GrpcCli { @@ -14,6 +15,8 @@ service GrpcCli { rpc SayHello (HelloRequest) returns (HelloReply) {} // Shutdown goSDN rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {} + // creates a stream to receive goSDN logs + rpc CreateLogStream(google.protobuf.Empty) returns (stream LogReply) {} // By now solely TAPI specific calls can be issued from the grpc-cli // TAPIGetEdge @@ -55,4 +58,7 @@ message TAPIReply { string message = 1; } - +// The response message containing a string with a goSDN log +message LogReply { + string log = 1; +} diff --git a/api/proto/gosdnCLI_grpc.pb.go b/api/proto/gosdnCLI_grpc.pb.go deleted file mode 100644 index 600414a6a07222330fb9ebabee938dad31b82666..0000000000000000000000000000000000000000 --- a/api/proto/gosdnCLI_grpc.pb.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package gosdn - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// GrpcCliClient is the client API for GrpcCli service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GrpcCliClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) - // Shutdown goSDN - Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) - // By now solely TAPI specific calls can be issued from the grpc-cli - // TAPIGetEdge - TAPIGetEdge(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) - //TAPIGetEdgeNode - TAPIGetEdgeNode(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) - // TAPIGetLink - TAPIGetLink(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) -} - -type grpcCliClient struct { - cc grpc.ClientConnInterface -} - -func NewGrpcCliClient(cc grpc.ClientConnInterface) GrpcCliClient { - return &grpcCliClient{cc} -} - -func (c *grpcCliClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) { - out := new(ShutdownReply) - err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/Shutdown", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) TAPIGetEdge(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { - out := new(TAPIReply) - err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/TAPIGetEdge", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) TAPIGetEdgeNode(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { - out := new(TAPIReply) - err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/TAPIGetEdgeNode", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) TAPIGetLink(ctx context.Context, in *TAPIRequest, opts ...grpc.CallOption) (*TAPIReply, error) { - out := new(TAPIReply) - err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/TAPIGetLink", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GrpcCliServer is the server API for GrpcCli service. -// All implementations must embed UnimplementedGrpcCliServer -// for forward compatibility -type GrpcCliServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - // Shutdown goSDN - Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) - // By now solely TAPI specific calls can be issued from the grpc-cli - // TAPIGetEdge - TAPIGetEdge(context.Context, *TAPIRequest) (*TAPIReply, error) - //TAPIGetEdgeNode - TAPIGetEdgeNode(context.Context, *TAPIRequest) (*TAPIReply, error) - // TAPIGetLink - TAPIGetLink(context.Context, *TAPIRequest) (*TAPIReply, error) - mustEmbedUnimplementedGrpcCliServer() -} - -// UnimplementedGrpcCliServer must be embedded to have forward compatible implementations. -type UnimplementedGrpcCliServer struct { -} - -func (*UnimplementedGrpcCliServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (*UnimplementedGrpcCliServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") -} -func (*UnimplementedGrpcCliServer) TAPIGetEdge(context.Context, *TAPIRequest) (*TAPIReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method TAPIGetEdge not implemented") -} -func (*UnimplementedGrpcCliServer) TAPIGetEdgeNode(context.Context, *TAPIRequest) (*TAPIReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method TAPIGetEdgeNode not implemented") -} -func (*UnimplementedGrpcCliServer) TAPIGetLink(context.Context, *TAPIRequest) (*TAPIReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method TAPIGetLink not implemented") -} -func (*UnimplementedGrpcCliServer) mustEmbedUnimplementedGrpcCliServer() {} - -func RegisterGrpcCliServer(s *grpc.Server, srv GrpcCliServer) { - s.RegisterService(&_GrpcCli_serviceDesc, srv) -} - -func _GrpcCli_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cliInterface.GrpcCli/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ShutdownRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).Shutdown(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cliInterface.GrpcCli/Shutdown", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).Shutdown(ctx, req.(*ShutdownRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_TAPIGetEdge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TAPIRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).TAPIGetEdge(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cliInterface.GrpcCli/TAPIGetEdge", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).TAPIGetEdge(ctx, req.(*TAPIRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_TAPIGetEdgeNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TAPIRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).TAPIGetEdgeNode(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cliInterface.GrpcCli/TAPIGetEdgeNode", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).TAPIGetEdgeNode(ctx, req.(*TAPIRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_TAPIGetLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TAPIRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).TAPIGetLink(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cliInterface.GrpcCli/TAPIGetLink", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).TAPIGetLink(ctx, req.(*TAPIRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _GrpcCli_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cliInterface.GrpcCli", - HandlerType: (*GrpcCliServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _GrpcCli_SayHello_Handler, - }, - { - MethodName: "Shutdown", - Handler: _GrpcCli_Shutdown_Handler, - }, - { - MethodName: "TAPIGetEdge", - Handler: _GrpcCli_TAPIGetEdge_Handler, - }, - { - MethodName: "TAPIGetEdgeNode", - Handler: _GrpcCli_TAPIGetEdgeNode_Handler, - }, - { - MethodName: "TAPIGetLink", - Handler: _GrpcCli_TAPIGetLink_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cliInterface/gosdnCLI.proto", -} diff --git a/cmd/gosdn-tview/app/app.go b/cmd/gosdn-tview/app/app.go index e65af13c574abbc01551afc45e88323d4b36c2da..28a8bc9ed84aedf5c962f88d9035c4cbb2b43792 100644 --- a/cmd/gosdn-tview/app/app.go +++ b/cmd/gosdn-tview/app/app.go @@ -6,11 +6,13 @@ type view interface { GetContent() tview.Primitive } +//App is a GUI-Application bases on tview type App struct { app *tview.Application pages *tview.Pages } +//NewApp creates a new GUI-Application func NewApp() *App { a := &App{ app: tview.NewApplication(), @@ -18,33 +20,40 @@ func NewApp() *App { return a } +//SetRoot sets the root of the GUI-Application func (a *App) SetRoot(v view) { a.pages = v.GetContent().(*tview.Pages) a.app.SetRoot(a.pages, true) } +//SwitchPage switches to the given (as string) tview page func (a *App) SwitchPage(s string) { if a.pages.HasPage(s) { a.pages.SwitchToPage(s) } } +//AddPage adds a new view as page that can be switched to func (a *App) AddPage(name string, p view) { a.pages.AddPage(name, p.GetContent(), true, false) } +//Run starts the GUI-Application func (a *App) Run() error { return a.app.Run() } +//Stop stops the GUI-Application func (a *App) Stop() { a.app.Stop() } +//Draw calls tview.Draw() func (a *App) Draw() { a.app.Draw() } +//SetFocus sets the focus on new tview.Primitive func (a *App) SetFocus(v tview.Primitive) { a.app.SetFocus(v) } diff --git a/cmd/gosdn-tview/grpc/commands.go b/cmd/gosdn-tview/grpc/commands.go index 6eabf835326dcf0a08663bec21632fbc09384744..74d2b09558e9e5a51a1ee3427623c96ca7006dfd 100644 --- a/cmd/gosdn-tview/grpc/commands.go +++ b/cmd/gosdn-tview/grpc/commands.go @@ -4,17 +4,12 @@ import ( pb "code.fbi.h-da.de/cocsn/gosdn/api/proto" "code.fbi.h-da.de/cocsn/gosdn/log" "context" + "github.com/rivo/tview" grpc "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" "time" ) -type commandType int - -const ( - GoSDN commandType = iota - Database -) - const ( defaultName = "gosdn-cli" ) @@ -22,10 +17,10 @@ const ( type command struct { Name string Description string - //CommandType commandType - Function func(conn *grpc.ClientConn) string + Function func(conn *grpc.ClientConn) string } +//CommandList contains the specific goSDN gRPC calls var CommandList = []command{ {"hello", "test connection to goSDN controller", goSDNSayHello}, {"shutdown", "request goSDN controller to shutdown", goSDNShutdown}, @@ -35,11 +30,35 @@ var CommandList = []command{ {"tapigetlink", "get list of links", TAPIGetLink}, } +//Connect creates a new connection to the gRPC server func Connect() (*grpc.ClientConn, error) { - address := "localhost:55055" + address := "141.100.70.170:55066" return grpc.Dial(address, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second), grpc.WithBlock()) } +func GoSDNLogStream(conn *grpc.ClientConn, clv *tview.TextView) error { + var streamError error + c := pb.NewGrpcCliClient(conn) + stream, err := c.CreateLogStream(context.Background(), &emptypb.Empty{}) + if err != nil { + log.Error(err) + } + + go func(stream pb.GrpcCli_CreateLogStreamClient) { + for { + msg, err := stream.Recv() + if err != nil { + streamError = err + break + } + response := []byte(msg.Log + "\n") + clv.Write(response) + } + }(stream) + + return streamError +} + func goSDNSayHello(conn *grpc.ClientConn) string { c := pb.NewGrpcCliClient(conn) diff --git a/cmd/gosdn-tview/views/addPNDView.go b/cmd/gosdn-tview/views/addPNDView.go index 7fdf756110624cfc519a5be7596981c828e8a28c..14fcd475d3b8eb9d13ea4524dc17a00c081cf67f 100644 --- a/cmd/gosdn-tview/views/addPNDView.go +++ b/cmd/gosdn-tview/views/addPNDView.go @@ -5,10 +5,12 @@ import ( "github.com/rivo/tview" ) +//AddPNDView is an application view to create a new goSDN PND type AddPNDView struct { addPNDView *tview.Form } +//NewAddPNDView creates a new AddPNDView func NewAddPNDView(app *app.App) *AddPNDView { pndv := &AddPNDView{ addPNDView: tview.NewForm(), @@ -34,6 +36,7 @@ func NewAddPNDView(app *app.App) *AddPNDView { return pndv } +//GetContent returns the tview.Primitive belonging to the AddPNDView func (pndv *AddPNDView) GetContent() tview.Primitive { return pndv.addPNDView } diff --git a/cmd/gosdn-tview/views/commandsListView.go b/cmd/gosdn-tview/views/commandsListView.go index 2ab3f9452f436669a7f75c536a9775f68b29590a..761a171fa89346ea2c53a4334e55bfa2a3df6da6 100644 --- a/cmd/gosdn-tview/views/commandsListView.go +++ b/cmd/gosdn-tview/views/commandsListView.go @@ -7,10 +7,12 @@ import ( "google.golang.org/grpc" ) +//CommandListView is an application view to display all the goSDN commands type CommandListView struct { commandsList *tview.List } +//NewCommandListView creates a new CommandListView func NewCommandListView() *CommandListView { cv := &CommandListView{ commandsList: tview.NewList(), @@ -22,14 +24,18 @@ func NewCommandListView() *CommandListView { return cv } +//GetContent returns the tview.Primitive belonging to the CommandListView func (cv *CommandListView) GetContent() tview.Primitive { return cv.commandsList } +//GetCommands gets all goSDN commands from a command list and creates new +//tview.List items for each one of them. The specific gRPC functions are added +//as tview.Selected() function func (cv *CommandListView) GetCommands(app *app.App, rv *ResultAndInputView, conn *grpc.ClientConn) { //TODO: create own command in grpc -> commands - cv.commandsList.AddItem("AddPND", "closes the application", '!', func() { + cv.commandsList.AddItem("AddPND", "closes the application", 'a', func() { rv.ChangeContentView("addPND") app.SetFocus(rv.GetContent()) }) @@ -37,14 +43,19 @@ func (cv *CommandListView) GetCommands(app *app.App, rv *ResultAndInputView, for i, command := range commands.CommandList { f := command.Function cv.commandsList. - AddItem(command.Name, command.Description, rune('a'+i), func() { + AddItem(command.Name, command.Description, rune('b'+i), func() { r := f(conn) rv.SetContent(r) rv.ChangeContentView("result") }) } + cv.commandsList.AddItem("Show Log", "shows the log of goSDN", 'l', func() { + rv.ChangeContentView("log") + }) + cv.commandsList.AddItem("quit", "closes the application", 'q', func() { app.Stop() }) + } diff --git a/cmd/gosdn-tview/views/consoleLogView.go b/cmd/gosdn-tview/views/consoleLogView.go new file mode 100644 index 0000000000000000000000000000000000000000..55de041dfaeb065382b356f83385cfc745ced67b --- /dev/null +++ b/cmd/gosdn-tview/views/consoleLogView.go @@ -0,0 +1,42 @@ +package views + +import ( + commands "code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/grpc" + "github.com/rivo/tview" + "google.golang.org/grpc" +) + +//ConsoleLogView is an application view to create a view for goSDN log messages +type ConsoleLogView struct { + consoleLogView *tview.TextView +} + +//NewConsoleLogView creates a new ConsoleLogView +func NewConsoleLogView(conn *grpc.ClientConn) *ConsoleLogView { + clv := &ConsoleLogView{ + consoleLogView: tview.NewTextView(), + } + clv.consoleLogView. + SetDynamicColors(true). + SetTextAlign(tview.AlignCenter). + SetRegions(true). + SetBorder(true). + SetTitle("goSDN Logs") + + commands.GoSDNLogStream(conn, clv.consoleLogView) + + return clv +} + +//GetContent returns the tview.Primitive belonging to the ConsoleLogView +func (clv *ConsoleLogView) GetContent() tview.Primitive { + return clv.consoleLogView +} + +//Write implements the io.Writer interface via tview.textView.Write(). +//Gets a string and converts it to a byte slice and writes it to the textView +//buffer +func (clv *ConsoleLogView) Write(s string) (n int, err error) { + b := []byte(s) + return clv.consoleLogView.Write(b) +} diff --git a/cmd/gosdn-tview/views/datbaseStatusView.go b/cmd/gosdn-tview/views/datbaseStatusView.go index 2e9a268666a054fab89b5ddef1ed28dc6c65385f..6c217b416779ecb7ea7232ee0b310298a27d8ce2 100644 --- a/cmd/gosdn-tview/views/datbaseStatusView.go +++ b/cmd/gosdn-tview/views/datbaseStatusView.go @@ -6,10 +6,13 @@ import ( "time" ) +//DatabaseStatusView is an application view to display the current status of +//the database (e.g. connected, disconnected,...) type DatabaseStatusView struct { databaseStatusView *tview.TextView } +//NewDatabaseStatusView creates a new DatabaseStatusView func NewDatabaseStatusView(app *app.App) *DatabaseStatusView { dv := &DatabaseStatusView{ databaseStatusView: tview.NewTextView(), @@ -21,21 +24,25 @@ func NewDatabaseStatusView(app *app.App) *DatabaseStatusView { SetBorder(true). SetTitle("Database") + // run the periodical refresh in a new go routine go databaseTicker(dv) return dv } +//GetContent returns the tview.Primitive belonging to the DatabaseStatusView func (dv *DatabaseStatusView) GetContent() tview.Primitive { return dv.databaseStatusView } +//SetContent sets new string content for the DatabaseStatusView func (dv *DatabaseStatusView) SetContent(s string) { dv.databaseStatusView.Clear() dv.databaseStatusView.SetText(s) } func databaseTicker(dv *DatabaseStatusView) { + //TODO see gRPCStatusView! ticker := time.NewTicker(5 * time.Second) for t := range ticker.C { dv.SetContent(t.String()) diff --git a/cmd/gosdn-tview/views/footerView.go b/cmd/gosdn-tview/views/footerView.go index f998d7ba5e973a3233f0b00c1c2ff880697e531c..09ff7d7dd0771036655b5291f2a5c278dc6ce72a 100644 --- a/cmd/gosdn-tview/views/footerView.go +++ b/cmd/gosdn-tview/views/footerView.go @@ -6,12 +6,15 @@ import ( "google.golang.org/grpc" ) +//FooterView is an application view to display the footer of the application it +//consists multiple other application views type FooterView struct { footerView *tview.Flex databaseStatusView *DatabaseStatusView gRPCStatusView *GRPCStatusView } +//NewFooterView creates a new FooterView func NewFooterView(app *app.App, conn *grpc.ClientConn) *FooterView { fw := &FooterView{ @@ -30,6 +33,7 @@ func NewFooterView(app *app.App, conn *grpc.ClientConn) *FooterView { return fw } +//GetContent returns the tview.Primitive belonging to the FooterView func (fw *FooterView) GetContent() tview.Primitive { return fw.footerView } diff --git a/cmd/gosdn-tview/views/gRPCStatusView.go b/cmd/gosdn-tview/views/gRPCStatusView.go index 3e522db7f18237e8533970fdf29f98233b6aff0e..ef024aecc34363bc3a8edf67ff51ac574dab4e65 100644 --- a/cmd/gosdn-tview/views/gRPCStatusView.go +++ b/cmd/gosdn-tview/views/gRPCStatusView.go @@ -7,10 +7,13 @@ import ( "time" ) +//GRPCStatusView is an application view to display the current status of +//the gRPC server (e.g. connected, unavailable,...) type GRPCStatusView struct { gRPCStatusView *tview.TextView } +//NewGRPCStatusView creates a new GRPCStatusView func NewGRPCStatusView(app *app.App, conn *grpc.ClientConn) *GRPCStatusView { sv := &GRPCStatusView{ gRPCStatusView: tview.NewTextView(), @@ -23,8 +26,8 @@ func NewGRPCStatusView(app *app.App, conn *grpc.ClientConn) *GRPCStatusView { SetBorder(true). SetTitle("gRPC") - //TODO: maybe there is another way to do this. - // pretty ugly atm, since it re-draws every 5 seconds... + //TODO: gRPCs Health Check looks like a way better alternative here! + //--> no app.Draw() required anymore sv.gRPCStatusView.SetChangedFunc(func() { app.Draw() }) @@ -34,10 +37,12 @@ func NewGRPCStatusView(app *app.App, conn *grpc.ClientConn) *GRPCStatusView { return sv } +//GetContent returns the tview.Primitive belonging to the gRPCStatusView func (sv *GRPCStatusView) GetContent() tview.Primitive { return sv.gRPCStatusView } +//SetContent sets new string content for the gRPCStatusView func (sv *GRPCStatusView) SetContent(s string) { sv.gRPCStatusView.Clear() sv.gRPCStatusView.SetText(s) diff --git a/cmd/gosdn-tview/views/headerView.go b/cmd/gosdn-tview/views/headerView.go index 67034bb6492f01563321a8cd777323367689685b..7c68ef2b74442cd30e21ba7fc71bdcbc0a4203b0 100644 --- a/cmd/gosdn-tview/views/headerView.go +++ b/cmd/gosdn-tview/views/headerView.go @@ -9,11 +9,13 @@ var goSDNAscii = ` ____ ____ _ _ _ _ _ \__ |\___/____/|____/|_| \_| |_| |_|\___/ \___|_| |_|___/\___|_| |_|\__,_|_|\___| |____/ \__,_|_| |_| |_| |_|___/\__\__,_|\__,_|\__| |___/ ` +//HeaderView is an application view to display the header of the application type HeaderView struct { headerFlex *tview.Flex titleView *tview.TextView } +//NewHeaderView creates a new HeaderView func NewHeaderView() *HeaderView { //TODO: change to uses FlexBox if there is more to display in the header hv := &HeaderView{ @@ -27,6 +29,7 @@ func NewHeaderView() *HeaderView { return hv } +//GetContent returns the tview.Primitive belonging to the HeaderView func (hv *HeaderView) GetContent() tview.Primitive { return hv.titleView } diff --git a/cmd/gosdn-tview/views/mainView.go b/cmd/gosdn-tview/views/mainView.go index 6c95c811cc408ee1f5e5fa480ba33e573d044555..e14bef6dc1d4997d0e7327f276956a6bb6f70bc6 100644 --- a/cmd/gosdn-tview/views/mainView.go +++ b/cmd/gosdn-tview/views/mainView.go @@ -6,6 +6,9 @@ import ( "google.golang.org/grpc" ) +//MainView is an application view to display the main content of the application. +//It is the entry point for the application and contains all necessary views for +//for that purpose type MainView struct { pages *tview.Pages mainGrid *tview.Grid @@ -15,12 +18,13 @@ type MainView struct { footerView *FooterView } +//NewMainView creates a new MainView func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView { mv := &MainView{ pages: tview.NewPages(), mainGrid: tview.NewGrid(), commandsListView: NewCommandListView(), - resultAndInputView: NewResultAndInputView(app), + resultAndInputView: NewResultAndInputView(app, conn), headerView: NewHeaderView(), footerView: NewFooterView(app, conn), } @@ -40,6 +44,7 @@ func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView { return mv } +//GetContent returns the tview.Primitive belonging to the MainView func (mv *MainView) GetContent() tview.Primitive { return mv.pages } diff --git a/cmd/gosdn-tview/views/resultAndInputView.go b/cmd/gosdn-tview/views/resultAndInputView.go index 99ae89654349c6347281c34c7b2149a6e4c64463..67f83f2a3ea0b9a9444eb71a225209aa63ed667a 100644 --- a/cmd/gosdn-tview/views/resultAndInputView.go +++ b/cmd/gosdn-tview/views/resultAndInputView.go @@ -3,19 +3,25 @@ package views import ( "code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app" "github.com/rivo/tview" + "google.golang.org/grpc" ) +//ResultAndInputView is an application view to display different other views. +//Depending on the required features the views are changed. type ResultAndInputView struct { - pages *tview.Pages - resultView *tview.TextView - pndInputView *AddPNDView + pages *tview.Pages + resultView *tview.TextView + pndInputView *AddPNDView + consoleLogView *ConsoleLogView } -func NewResultAndInputView(app *app.App) *ResultAndInputView { +//NewResultAndInputView creates a new ResultAndInputView +func NewResultAndInputView(app *app.App, conn *grpc.ClientConn) *ResultAndInputView { rv := &ResultAndInputView{ - pages: tview.NewPages(), - pndInputView: NewAddPNDView(app), - resultView: tview.NewTextView(), + pages: tview.NewPages(), + pndInputView: NewAddPNDView(app), + resultView: tview.NewTextView(), + consoleLogView: NewConsoleLogView(conn), } rv.resultView. SetDynamicColors(true). @@ -26,19 +32,24 @@ func NewResultAndInputView(app *app.App) *ResultAndInputView { rv.pages. AddPage("result", rv.resultView, true, true). - AddPage("addPND", rv.pndInputView.GetContent(), true, false) + AddPage("addPND", rv.pndInputView.GetContent(), true, false). + AddPage("log", rv.consoleLogView.GetContent(), true, false) return rv } +//GetContent returns the tview.Primitive belonging to the ResultAndInputView func (rv *ResultAndInputView) GetContent() tview.Primitive { return rv.pages } +//ChangeContentView changes the current content (tview.Primitive) that is visible +//inside this view func (rv *ResultAndInputView) ChangeContentView(s string) { rv.pages.SwitchToPage(s) } +//SetContent sets new string content for the ResultAndInputView func (rv *ResultAndInputView) SetContent(s string) { rv.resultView.Clear() rv.resultView.SetText(s) diff --git a/nucleus/cli-handling.go b/nucleus/cli-handling.go index 5296e0e001312ef586cbdabec514d5a80f94820b..2afb6f6f3a87e1597b5179e16d813c0cad92ec7d 100644 --- a/nucleus/cli-handling.go +++ b/nucleus/cli-handling.go @@ -7,18 +7,42 @@ package nucleus import ( + "context" + "io" + "net" + "os" + "sync" + pb "code.fbi.h-da.de/cocsn/gosdn/api/proto" "code.fbi.h-da.de/cocsn/gosdn/log" "code.fbi.h-da.de/cocsn/gosdn/sbi/restconf/client/ciena" - "context" "google.golang.org/grpc" - "net" + "google.golang.org/protobuf/types/known/emptypb" ) +type LogConnection struct { + stream pb.GrpcCli_CreateLogStreamServer + id string + active bool + error chan error +} + // server is used to implement the grcp cli server type server struct { pb.UnimplementedGrpcCliServer - core *Core + core *Core + logConnections []*LogConnection +} + +var srv *server + +type buf []byte + +func (b *buf) Write(p []byte) (n int, err error) { + + reply := pb.LogReply{Log: string(p)} + srv.BroadcastLog(&reply) + return len(p), nil } func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { @@ -26,6 +50,47 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe return &pb.HelloReply{Message: "Hello " + in.GetName(), GoSDNInfo: "goSDN in version: DEVELOP"}, nil } +//GetLog creates a continuous stream between client and server to send goSDN logs +func (s *server) CreateLogStream(req *emptypb.Empty, stream pb.GrpcCli_CreateLogStreamServer) error { + conn := &LogConnection{ + stream: stream, + active: true, + error: make(chan error), + } + s.logConnections = append(s.logConnections, conn) + + return <-conn.error +} + +func (s *server) BroadcastLog(log *pb.LogReply) { + wait := sync.WaitGroup{} + done := make(chan int) + + for _, conn := range s.logConnections { + wait.Add(1) + + go func(conn *LogConnection) { + defer wait.Done() + if conn.active { + err := conn.stream.Send(log) + + if err != nil { + conn.active = false + conn.error <- err + } + } + }(conn) + } + + go func() { + //blocks until all send routines are finished + wait.Wait() + close(done) + }() + + <-done +} + func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.ShutdownReply, error) { log.Info("Shutdown Received: ", in.GetName()) s.core.IsRunning <- false @@ -33,6 +98,10 @@ func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.Shut } func getCLIGoing(core *Core) { + + var logConnections []*LogConnection + var logBuffer buf + log.Info("Starting: GetCLIGoing") // Boot-up the control interface for the cli cliControlListener, err := net.Listen("tcp", core.config.CliSocket) @@ -41,12 +110,17 @@ func getCLIGoing(core *Core) { } cliControlServer := grpc.NewServer() + srv = &server{core: core, logConnections: logConnections} + + //TODO: move? + wrt := io.MultiWriter(os.Stdout, &logBuffer) + log.Output(wrt) + + pb.RegisterGrpcCliServer(cliControlServer, srv) - pb.RegisterGrpcCliServer(cliControlServer, &server{core: core}) if err := cliControlServer.Serve(cliControlListener); err != nil { log.Fatal(err) } - log.Info("Started: GetCLIGoing") } // SBI specific calls, by now TAPI only