diff --git a/cliInterface/gosdnCLI.pb.go b/cliInterface/gosdnCLI.pb.go index a7cec77003351d6a7234b2a963b75fc9e677c4cb..2095a2771e811732b7ef6b56b75930e7e21d27e7 100644 --- a/cliInterface/gosdnCLI.pb.go +++ b/cliInterface/gosdnCLI.pb.go @@ -79,7 +79,8 @@ type HelloReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + GoSDNInfo string `protobuf:"bytes,2,opt,name=goSDNInfo,proto3" json:"goSDNInfo,omitempty"` } func (x *HelloReply) Reset() { @@ -121,6 +122,13 @@ func (x *HelloReply) GetMessage() string { return "" } +func (x *HelloReply) GetGoSDNInfo() string { + if x != nil { + return x.GoSDNInfo + } + return "" +} + // Request to shutdown goSDN type ShutdownRequest struct { state protoimpl.MessageState @@ -217,6 +225,102 @@ func (x *ShutdownReply) GetMessage() string { return "" } +// Request with no meaning by now +type TAPIRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *TAPIRequest) Reset() { + *x = TAPIRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cliInterface_gosdnCLI_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TAPIRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TAPIRequest) ProtoMessage() {} + +func (x *TAPIRequest) ProtoReflect() protoreflect.Message { + mi := &file_cliInterface_gosdnCLI_proto_msgTypes[4] + 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 TAPIRequest.ProtoReflect.Descriptor instead. +func (*TAPIRequest) Descriptor() ([]byte, []int) { + return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{4} +} + +func (x *TAPIRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// The response message containing a string with no meaning by now +type TAPIReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *TAPIReply) Reset() { + *x = TAPIReply{} + if protoimpl.UnsafeEnabled { + mi := &file_cliInterface_gosdnCLI_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TAPIReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TAPIReply) ProtoMessage() {} + +func (x *TAPIReply) ProtoReflect() protoreflect.Message { + mi := &file_cliInterface_gosdnCLI_proto_msgTypes[5] + 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 TAPIReply.ProtoReflect.Descriptor instead. +func (*TAPIReply) Descriptor() ([]byte, []int) { + return file_cliInterface_gosdnCLI_proto_rawDescGZIP(), []int{5} +} + +func (x *TAPIReply) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_cliInterface_gosdnCLI_proto protoreflect.FileDescriptor var file_cliInterface_gosdnCLI_proto_rawDesc = []byte{ @@ -225,29 +329,49 @@ var file_cliInterface_gosdnCLI_proto_rawDesc = []byte{ 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, - 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, + 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, 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, 0x32, 0x97, 0x01, 0x0a, 0x07, 0x47, 0x72, - 0x65, 0x65, 0x74, 0x65, 0x72, 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, 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, + 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, } var ( @@ -262,20 +386,28 @@ func file_cliInterface_gosdnCLI_proto_rawDescGZIP() []byte { return file_cliInterface_gosdnCLI_proto_rawDescData } -var file_cliInterface_gosdnCLI_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +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.Greeter.SayHello:input_type -> cliInterface.HelloRequest - 2, // 1: cliInterface.Greeter.Shutdown:input_type -> cliInterface.ShutdownRequest - 1, // 2: cliInterface.Greeter.SayHello:output_type -> cliInterface.HelloReply - 3, // 3: cliInterface.Greeter.Shutdown:output_type -> cliInterface.ShutdownReply - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type + 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 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 @@ -335,6 +467,30 @@ func file_cliInterface_gosdnCLI_proto_init() { return nil } } + file_cliInterface_gosdnCLI_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TAPIRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cliInterface_gosdnCLI_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TAPIReply); 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{ @@ -342,7 +498,7 @@ func file_cliInterface_gosdnCLI_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cliInterface_gosdnCLI_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/cliInterface/gosdnCLI.proto b/cliInterface/gosdnCLI.proto index 2139a330110a5b8c9909083370de24f5d10bbeca..fa76e03959152bed3829ff5f8e70b5379e3becca 100644 --- a/cliInterface/gosdnCLI.proto +++ b/cliInterface/gosdnCLI.proto @@ -9,11 +9,19 @@ option java_outer_classname = "cliInterface"; package cliInterface; // The greeting service definition. -service Greeter { +service GrpcCli { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} // Shutdown goSDN rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {} + + // By now solely TAPI specific calls can be issued from the grpc-cli + // TAPIGetEdge + rpc TAPIGetEdge (TAPIRequest) returns (TAPIReply) {} + //TAPIGetEdgeNode + rpc TAPIGetEdgeNode (TAPIRequest) returns (TAPIReply) {} + // TAPIGetLink + rpc TAPIGetLink (TAPIRequest) returns (TAPIReply) {} } // The request message containing the user's name. @@ -24,6 +32,7 @@ message HelloRequest { // The response message containing the greetings message HelloReply { string message = 1; + string goSDNInfo = 2; } // Request to shutdown goSDN @@ -36,3 +45,14 @@ message ShutdownReply { string message = 1; } +// Request with no meaning by now +message TAPIRequest { + string name = 1; +} + +// The response message containing a string with no meaning by now +message TAPIReply { + string message = 1; +} + + diff --git a/cliInterface/gosdnCLI_grpc.pb.go b/cliInterface/gosdnCLI_grpc.pb.go index fc33744973ddcc04eaa456270648c3bcc16756be..600414a6a07222330fb9ebabee938dad31b82666 100644 --- a/cliInterface/gosdnCLI_grpc.pb.go +++ b/cliInterface/gosdnCLI_grpc.pb.go @@ -13,116 +13,232 @@ import ( // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// GreeterClient is the client API for Greeter service. +// 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 GreeterClient interface { +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 greeterClient struct { +type grpcCliClient struct { cc grpc.ClientConnInterface } -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} +func NewGrpcCliClient(cc grpc.ClientConnInterface) GrpcCliClient { + return &grpcCliClient{cc} } -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { +func (c *grpcCliClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { out := new(HelloReply) - err := c.cc.Invoke(ctx, "/cliInterface.Greeter/SayHello", in, out, opts...) + err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/SayHello", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *greeterClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) { +func (c *grpcCliClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownReply, error) { out := new(ShutdownReply) - err := c.cc.Invoke(ctx, "/cliInterface.Greeter/Shutdown", in, out, opts...) + err := c.cc.Invoke(ctx, "/cliInterface.GrpcCli/Shutdown", in, out, opts...) if err != nil { return nil, err } return out, nil } -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer +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 GreeterServer interface { +type GrpcCliServer interface { // Sends a greeting SayHello(context.Context, *HelloRequest) (*HelloReply, error) // Shutdown goSDN Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) - mustEmbedUnimplementedGreeterServer() + // 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() } -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { +// UnimplementedGrpcCliServer must be embedded to have forward compatible implementations. +type UnimplementedGrpcCliServer struct { } -func (*UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { +func (*UnimplementedGrpcCliServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") } -func (*UnimplementedGreeterServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) { +func (*UnimplementedGrpcCliServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") } -func (*UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} +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 RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { - s.RegisterService(&_Greeter_serviceDesc, srv) +func RegisterGrpcCliServer(s *grpc.Server, srv GrpcCliServer) { + s.RegisterService(&_GrpcCli_serviceDesc, srv) } -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +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.(GreeterServer).SayHello(ctx, in) + return srv.(GrpcCliServer).SayHello(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cliInterface.Greeter/SayHello", + FullMethod: "/cliInterface.GrpcCli/SayHello", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) + return srv.(GrpcCliServer).SayHello(ctx, req.(*HelloRequest)) } return interceptor(ctx, in, info, handler) } -func _Greeter_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +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.(GreeterServer).Shutdown(ctx, in) + 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.Greeter/Shutdown", + FullMethod: "/cliInterface.GrpcCli/TAPIGetEdge", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).Shutdown(ctx, req.(*ShutdownRequest)) + return srv.(GrpcCliServer).TAPIGetEdge(ctx, req.(*TAPIRequest)) } return interceptor(ctx, in, info, handler) } -var _Greeter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cliInterface.Greeter", - HandlerType: (*GreeterServer)(nil), +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: _Greeter_SayHello_Handler, + Handler: _GrpcCli_SayHello_Handler, }, { MethodName: "Shutdown", - Handler: _Greeter_Shutdown_Handler, + 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{}, diff --git a/database/database.go b/database/database.go index e761b779dc8400fca30ffba527eac536fa524a42..caefc09743776dcf6b5b3c07a5d062afa6f466f7 100644 --- a/database/database.go +++ b/database/database.go @@ -1,8 +1,7 @@ package database import ( - "log" - + "code.fbi.h-da.de/cocsn/gosdn/log" "github.com/neo4j/neo4j-go-driver/neo4j" ) @@ -74,7 +73,7 @@ func (d Database) StoreNodes(json string) { logError("failed storing Nodes into database", err) - log.Printf("successfully added Nodes into database") + log.Info("successfully added Nodes into database") } //StoreNodeEdgePoints stores the given node edge points (interfaces) @@ -101,7 +100,7 @@ func (d Database) StoreNodeEdgePoints(json string) { setNodeNodeEdgePointsRelation(session) - log.Printf("successfully added NodeEdgePoints into database") + log.Info("successfully added NodeEdgePoints into database") } @@ -121,12 +120,12 @@ func setNodeNodeEdgePointsRelation(session neo4j.Session) { logError("failed storing NodeNodeEdgePointsRelation into database", err) - log.Printf("successfully stored NodeNodeEdgePointsRelation into database") + log.Info("successfully stored NodeNodeEdgePointsRelation into database") } //logError logs error with custom and error message func logError(message string, err error) { if err != nil { - log.Fatalf("%v: %v", message, err) + log.Info("%v: %v", message, err) } } diff --git a/gosdn-cli/gosdn-cli.go b/gosdn-cli/gosdn-cli.go index da4cf175013b2ca484a6a57fe84fdb8e0a14df03..fe81e0ecbb0de4651e6c4ea01122be20861061af 100644 --- a/gosdn-cli/gosdn-cli.go +++ b/gosdn-cli/gosdn-cli.go @@ -121,7 +121,7 @@ func main() { func goSDNSayHello (conn *grpc.ClientConn) { - c := pb.NewGreeterClient(conn) + c := pb.NewGrpcCliClient(conn) // Contact the server and print out its response. name := defaultName @@ -134,19 +134,19 @@ func goSDNSayHello (conn *grpc.ClientConn) { if err != nil { log.Fatalf("could not say hello: %v", err) } - log.Printf("Greeting: %s", r.GetMessage()) + log.Printf("Greeting: %s", r.String()) } func goSDNShutdown (conn *grpc.ClientConn) { - c := pb.NewGreeterClient(conn) + c := pb.NewGrpcCliClient(conn) // Contact the server and print out its response. name := defaultName if len(os.Args) > 1 { - name = os.Args[1] + name = os.Args[0] } ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() diff --git a/log/logger.go b/log/logger.go new file mode 100644 index 0000000000000000000000000000000000000000..ab258d8b731c5b8692ee8afe37b9c18012b712b2 --- /dev/null +++ b/log/logger.go @@ -0,0 +1,98 @@ +package log + +import ( + "fmt" + "io" + "os" + "sync" + "time" +) + +var logger *Logger +var once sync.Once + +// Logger is a wrapper for log.Logger and provides +// methods to enable and disable logging. +type Logger struct { + Out io.Writer + Loglevel Level + lock sync.Mutex +} + +func get() *Logger { + once.Do(func() { + logger = &Logger{ + Out: os.Stdout, + Loglevel: INFO, + lock: sync.Mutex{}, + } + }) + return logger +} + +func Loglevel(level Level) { + l := get() + l.lock.Lock() + defer l.lock.Unlock() + l.Loglevel = level +} + +func Output(out io.Writer) { + l := get() + l.lock.Lock() + defer l.lock.Unlock() + l.Out = out +} + +func Debug(args ...interface{}) { + log(DEBUG, args) +} + +func Info(args ...interface{}) { + log(INFO, args) +} + +func Warn(args ...interface{}) { + log(WARNING, args) +} + +func Error(args ...interface{}) { + log(ERROR, args) +} + +func Fatal(args ...interface{}) { + log(FATAL, args) +} + +func Panic(args ...interface{}) { + log(PANIC, args) +} + +func log(level Level, args ...interface{}) { + l := get() + l.lock.Lock() + defer l.lock.Unlock() + if level <= l.Loglevel { + msg := fmt.Sprint(args...) + logMessage := time.Now().Format(time.RFC3339) + "\t" + prefix(level) + "\t" + msg + "\n" + l.Out.Write([]byte(logMessage)) + } +} + +func prefix(level Level) string { + switch level { + case PANIC: + return "PANIC" + case FATAL: + return "FATAL" + case ERROR: + return "ERROR" + case WARNING: + return "WARNING" + case INFO: + return "INFO" + case DEBUG: + return "DEBUG" + } + return "" +} diff --git a/log/loglevel.go b/log/loglevel.go new file mode 100644 index 0000000000000000000000000000000000000000..64a259cb408139a4a1089b5a0f6714244035bf9e --- /dev/null +++ b/log/loglevel.go @@ -0,0 +1,12 @@ +package log + +type Level uint8 + +const ( + PANIC Level = iota + FATAL + ERROR + WARNING + INFO + DEBUG +) diff --git a/main.go b/main.go index 66836589d998071df74049e746168c5c39424027..b04ddc031a21f6fa6c8d2a0ed4b9d438643f8dcb 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "code.fbi.h-da.de/cocsn/gosdn/log" "code.fbi.h-da.de/cocsn/gosdn/nucleus" "flag" ) @@ -15,8 +16,10 @@ func main() { flag.Parse() cliSocket := *cliListenAddr + ":" + *cliListenPort + log.Loglevel(log.DEBUG) // hand off to cmd for further processing nucleus.StartUp(cliSocket, *configFileName) + log.Info("Startup completed") nucleus.Run() // nothing to see here, please move on! diff --git a/nucleus/cli-handling.go b/nucleus/cli-handling.go index eb9005ef052b20c9727788eba99a13ef72c83829..d3422db41470abb39c33c772e73a14a842971e98 100644 --- a/nucleus/cli-handling.go +++ b/nucleus/cli-handling.go @@ -1,3 +1,10 @@ +/* + This file contains the grpc cli server-side calls. + Functions here should call other functions in charge of the + particular task. + */ + + package nucleus import ( @@ -8,16 +15,15 @@ import ( "net" ) -// server is used to implement helloworld.GreeterServer. +// server is used to implement the grcp cli server type server struct { - pb.UnimplementedGreeterServer + pb.UnimplementedGrpcCliServer core *Core } -// SayHello implements helloworld.GreeterServer func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { log.Printf("Received: %v", in.GetName()) - return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil + return &pb.HelloReply{Message: "Hello " + in.GetName(), GoSDNInfo: "goSDN in version: DEVELOP"}, nil } func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.ShutdownReply, error) { @@ -36,9 +42,27 @@ func getCLIGoing(core *Core) { cliControlServer := grpc.NewServer() - pb.RegisterGreeterServer(cliControlServer, &server{core: core}) + pb.RegisterGrpcCliServer(cliControlServer, &server{core: core}) if err := cliControlServer.Serve(cliControlListener); err != nil { log.Fatalf("failed to serve: %v", err) } log.Println("Started: GetCLIGoing") -} \ No newline at end of file +} + +// SBI specific calls, by now TAPI only +func (s *server) TAPIGetEdge(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIReply, error) { + log.Printf("Received: %v", in.GetName()) + s2 := s.core.clients["ciena-mcp"] + s2.GetConfig() + return &pb.TAPIReply{Message: "Done"}, nil +} + +func (s *server) TAPIGetEdgeNode(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIReply, error) { + log.Printf("Received: %v", in.GetName()) + return &pb.TAPIReply{Message: "Done"}, nil +} + +func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIReply, error) { + log.Printf("Received: %v", in.GetName()) + return &pb.TAPIReply{Message: "Done"}, nil +} diff --git a/nucleus/controller.go b/nucleus/controller.go index 79d686aacb769ee5408aef7d17d0d55564c82fa3..2b4cdb19219dc74bf77a48d02f3363df09d2ead3 100644 --- a/nucleus/controller.go +++ b/nucleus/controller.go @@ -2,10 +2,10 @@ package nucleus import ( "code.fbi.h-da.de/cocsn/gosdn/database" + "code.fbi.h-da.de/cocsn/gosdn/log" "code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces" "code.fbi.h-da.de/cocsn/gosdn/restconf/client/ciena" "github.com/BurntSushi/toml" - "log" "os" ) diff --git a/nucleus/nucleus-core.go b/nucleus/nucleus-core.go index d7caa47073f4a0b1c3581a305d2f1228bc81cd00..faf21776d23d8b1449078ee2b4cfba2797bc72fa 100644 --- a/nucleus/nucleus-core.go +++ b/nucleus/nucleus-core.go @@ -2,12 +2,11 @@ package nucleus import ( "code.fbi.h-da.de/cocsn/gosdn/database" + "code.fbi.h-da.de/cocsn/gosdn/log" "code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces" - "log" "time" ) - /* * This function is used to start the core of the controller and any auxiliary services. */ @@ -15,17 +14,17 @@ import ( // Next-up: backend database. func StartUp(socket, filename string) { - log.Println("This is the network superintendent...") - log.Println("Starting my ducks") + log.Info("This is the network superintendent...") + log.Info("Starting my ducks") // Init the Core core := Core{ - clients: make(map[string]interfaces.Client, 0), + clients: make(map[string]interfaces.Client), database: database.Database{}, } core.Init(socket, filename) // Start the GRCP CLI go getCLIGoing(&core) - log.Println("and ready for take off") + log.Info("and ready for take off") } @@ -39,8 +38,8 @@ func Run() { for isRunning { time.Sleep(10 * time.Second) - log.Println("Still alive...") + log.Debug("Still alive...") } - log.Println("Good bye....!") + log.Info("Good bye....!") } diff --git a/restconf/client/ciena/client.go b/restconf/client/ciena/client.go index 100ab056bf6e90ecb2bf991f8727460382ad140e..cb514e37a39720734a94f29763a54eda9b821e2f 100644 --- a/restconf/client/ciena/client.go +++ b/restconf/client/ciena/client.go @@ -1,7 +1,9 @@ package ciena import ( + "bytes" "code.fbi.h-da.de/cocsn/gosdn/database" + "code.fbi.h-da.de/cocsn/gosdn/log" "code.fbi.h-da.de/cocsn/gosdn/restconf/util" apiclient "code.fbi.h-da.de/cocsn/swagger/apis/mcp/client" "crypto/tls" @@ -16,7 +18,7 @@ type MCPClient struct { transport *httptransport.Runtime client *apiclient.ServiceTopologyTAPI database *database.Database - buf *[]byte + buffer *bytes.Buffer } func (c MCPClient) GetConfig() string { @@ -25,7 +27,7 @@ func (c MCPClient) GetConfig() string { } //NewMCPClient creates a client -func NewMCPClient(endpoint, username, password string, database *database.Database) MCPClient { +func NewMCPClient(endpoint, username, password string, database *database.Database) *MCPClient { // create the transport transport := httptransport.New(endpoint, "/", nil) transport.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} @@ -36,37 +38,37 @@ func NewMCPClient(endpoint, username, password string, database *database.Databa transport.DefaultAuthentication = basicAuth client := apiclient.New(transport, strfmt.Default) - buf := make([]byte, 0) - transport.Consumers[runtime.JSONMime] = util.YANGConsumer{Data: &buf} + buffer := new(bytes.Buffer) + transport.Consumers[runtime.JSONMime] = util.YANGConsumer{Data: buffer} - return MCPClient{ + return &MCPClient{ transport: transport, client: client, - database: database, - buf: &buf, + database: database, + buffer: buffer, } } func (c *MCPClient) GetConnections() error { - c.buf = nil + defer c.buffer.Reset() _, err := c.client.TapiConnectivityCore.GetTapiCoreContextConnection(nil) - c.database.StoreConnections(string(*c.buf)) - c.buf = nil + c.database.StoreConnections(c.buffer.String()) + log.Debug(c.buffer.Next(25)) return err } func (c *MCPClient) GetNodes() error { - c.buf = nil + defer c.buffer.Reset() _, err := c.client.TapiTopologyCore.GetTapiCoreContextTopologyMcpBaseTopologyNode(nil) - c.database.StoreNodes(string(*c.buf)) - c.buf = nil + c.database.StoreNodes(c.buffer.String()) + log.Debug(c.buffer.Next(25)) return err } func (c *MCPClient) GetNodeEdgePoints() error { - c.buf = nil + defer c.buffer.Reset() _, err := c.client.TapiTopologyCore.GetTapiCoreContextTopologyMcpBaseTopologyNodeEdgePoint(nil) - c.database.StoreNodeEdgePoints(string(*c.buf)) - c.buf = nil + c.database.StoreNodeEdgePoints(c.buffer.String()) + log.Debug(c.buffer.Next(25)) return err } diff --git a/restconf/util/unmarshal.go b/restconf/util/unmarshal.go index b044bd09ceb2385a7087850ed2c322db8ce4634c..2386eec8e18bc61e08b71fc7cc782ebe9318bb06 100644 --- a/restconf/util/unmarshal.go +++ b/restconf/util/unmarshal.go @@ -1,16 +1,15 @@ package util import ( + "bytes" "io" - "io/ioutil" ) type YANGConsumer struct { - Data *[]byte + Data *bytes.Buffer } func (yc YANGConsumer)Consume(reader io.Reader, _ interface{}) error { - var err error = nil - *yc.Data, err = ioutil.ReadAll(reader) + _,err := yc.Data.ReadFrom(reader) return err }