diff --git a/api/proto/gosdnCLI.pb.go b/api/proto/gosdnCLI.pb.go deleted file mode 100644 index e6b62456650a6a4ca00bb9def32281e9752180f1..0000000000000000000000000000000000000000 --- a/api/proto/gosdnCLI.pb.go +++ /dev/null @@ -1,1851 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 -// source: gosdnCLI.proto - -package gosdn - -import ( - context "context" - 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" - emptypb "google.golang.org/protobuf/types/known/emptypb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[0] - 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 HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - 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() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[1] - 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 HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *HelloReply) GetGoSDNInfo() string { - if x != nil { - return x.GoSDNInfo - } - return "" -} - -// Request to shutdown goSDN -type ShutdownRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *ShutdownRequest) Reset() { - *x = ShutdownRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ShutdownRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ShutdownRequest) ProtoMessage() {} - -func (x *ShutdownRequest) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[2] - 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 ShutdownRequest.ProtoReflect.Descriptor instead. -func (*ShutdownRequest) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{2} -} - -func (x *ShutdownRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing some shutdown notes of goSDN -type ShutdownReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *ShutdownReply) Reset() { - *x = ShutdownReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ShutdownReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ShutdownReply) ProtoMessage() {} - -func (x *ShutdownReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[3] - 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 ShutdownReply.ProtoReflect.Descriptor instead. -func (*ShutdownReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{3} -} - -func (x *ShutdownReply) GetMessage() string { - if x != nil { - return x.Message - } - 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_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_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_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_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_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_gosdnCLI_proto_rawDescGZIP(), []int{5} -} - -func (x *TAPIReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -// -type CreatePNDRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Sbi string `protobuf:"bytes,3,opt,name=sbi,proto3" json:"sbi,omitempty"` -} - -func (x *CreatePNDRequest) Reset() { - *x = CreatePNDRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreatePNDRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePNDRequest) ProtoMessage() {} - -func (x *CreatePNDRequest) 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 CreatePNDRequest.ProtoReflect.Descriptor instead. -func (*CreatePNDRequest) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{6} -} - -func (x *CreatePNDRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CreatePNDRequest) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *CreatePNDRequest) GetSbi() string { - if x != nil { - return x.Sbi - } - return "" -} - -type AllSBINamesReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SbiNames []string `protobuf:"bytes,1,rep,name=sbiNames,proto3" json:"sbiNames,omitempty"` -} - -func (x *AllSBINamesReply) Reset() { - *x = AllSBINamesReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AllSBINamesReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AllSBINamesReply) ProtoMessage() {} - -func (x *AllSBINamesReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[7] - 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 AllSBINamesReply.ProtoReflect.Descriptor instead. -func (*AllSBINamesReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{7} -} - -func (x *AllSBINamesReply) GetSbiNames() []string { - if x != nil { - return x.SbiNames - } - return nil -} - -// -type CreatePNDReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *CreatePNDReply) Reset() { - *x = CreatePNDReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreatePNDReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePNDReply) ProtoMessage() {} - -func (x *CreatePNDReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[8] - 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 CreatePNDReply.ProtoReflect.Descriptor instead. -func (*CreatePNDReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{8} -} - -func (x *CreatePNDReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -// -type AllPNDsReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Pnds []*PND `protobuf:"bytes,1,rep,name=pnds,proto3" json:"pnds,omitempty"` -} - -func (x *AllPNDsReply) Reset() { - *x = AllPNDsReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AllPNDsReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AllPNDsReply) ProtoMessage() {} - -func (x *AllPNDsReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[9] - 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 AllPNDsReply.ProtoReflect.Descriptor instead. -func (*AllPNDsReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{9} -} - -func (x *AllPNDsReply) GetPnds() []*PND { - if x != nil { - return x.Pnds - } - return nil -} - -type PND struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - Sbi string `protobuf:"bytes,4,opt,name=sbi,proto3" json:"sbi,omitempty"` - Devices []*Device `protobuf:"bytes,5,rep,name=devices,proto3" json:"devices,omitempty"` -} - -func (x *PND) Reset() { - *x = PND{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PND) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PND) ProtoMessage() {} - -func (x *PND) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[10] - 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 PND.ProtoReflect.Descriptor instead. -func (*PND) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{10} -} - -func (x *PND) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *PND) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *PND) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *PND) GetSbi() string { - if x != nil { - return x.Sbi - } - return "" -} - -func (x *PND) GetDevices() []*Device { - if x != nil { - return x.Devices - } - return nil -} - -type Device struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *Device) Reset() { - *x = Device{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Device) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Device) ProtoMessage() {} - -func (x *Device) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[11] - 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 Device.ProtoReflect.Descriptor instead. -func (*Device) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{11} -} - -func (x *Device) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *Device) GetAddress() string { - if x != nil { - return x.Address - } - return "" -} - -func (x *Device) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *Device) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type AddDeviceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UuidPND string `protobuf:"bytes,1,opt,name=uuidPND,proto3" json:"uuidPND,omitempty"` - Device *Device `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` -} - -func (x *AddDeviceRequest) Reset() { - *x = AddDeviceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddDeviceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddDeviceRequest) ProtoMessage() {} - -func (x *AddDeviceRequest) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[12] - 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 AddDeviceRequest.ProtoReflect.Descriptor instead. -func (*AddDeviceRequest) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{12} -} - -func (x *AddDeviceRequest) GetUuidPND() string { - if x != nil { - return x.UuidPND - } - return "" -} - -func (x *AddDeviceRequest) GetDevice() *Device { - if x != nil { - return x.Device - } - return nil -} - -type AddDeviceReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *AddDeviceReply) Reset() { - *x = AddDeviceReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddDeviceReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddDeviceReply) ProtoMessage() {} - -func (x *AddDeviceReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[13] - 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 AddDeviceReply.ProtoReflect.Descriptor instead. -func (*AddDeviceReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{13} -} - -func (x *AddDeviceReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type DeviceGetRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UuidPND string `protobuf:"bytes,1,opt,name=uuidPND,proto3" json:"uuidPND,omitempty"` - UuidDevice string `protobuf:"bytes,2,opt,name=uuidDevice,proto3" json:"uuidDevice,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` -} - -func (x *DeviceGetRequest) Reset() { - *x = DeviceGetRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeviceGetRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeviceGetRequest) ProtoMessage() {} - -func (x *DeviceGetRequest) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[14] - 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 DeviceGetRequest.ProtoReflect.Descriptor instead. -func (*DeviceGetRequest) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{14} -} - -func (x *DeviceGetRequest) GetUuidPND() string { - if x != nil { - return x.UuidPND - } - return "" -} - -func (x *DeviceGetRequest) GetUuidDevice() string { - if x != nil { - return x.UuidDevice - } - return "" -} - -func (x *DeviceGetRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -type DeviceGetReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *DeviceGetReply) Reset() { - *x = DeviceGetReply{} - if protoimpl.UnsafeEnabled { - mi := &file_gosdnCLI_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeviceGetReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeviceGetReply) ProtoMessage() {} - -func (x *DeviceGetReply) ProtoReflect() protoreflect.Message { - mi := &file_gosdnCLI_proto_msgTypes[15] - 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 DeviceGetReply.ProtoReflect.Descriptor instead. -func (*DeviceGetReply) Descriptor() ([]byte, []int) { - return file_gosdnCLI_proto_rawDescGZIP(), []int{15} -} - -func (x *DeviceGetReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -// 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[16] - 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[16] - 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{16} -} - -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, 0x5a, 0x0a, 0x10, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x50, 0x4e, 0x44, 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, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x62, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x73, 0x62, 0x69, 0x22, 0x2e, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x53, 0x42, 0x49, - 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x62, - 0x69, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x62, - 0x69, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x2a, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x50, 0x4e, 0x44, 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, 0x2e, 0x0a, 0x0c, 0x41, 0x6c, 0x6c, 0x50, 0x4e, 0x44, 0x73, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x70, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x4e, 0x44, 0x52, 0x04, 0x70, 0x6e, - 0x64, 0x73, 0x22, 0x8a, 0x01, 0x0a, 0x03, 0x50, 0x4e, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x62, 0x69, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x73, 0x62, 0x69, 0x12, 0x27, 0x0a, 0x07, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x22, - 0x6e, 0x0a, 0x06, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, - 0x53, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x75, 0x69, 0x64, 0x50, 0x4e, 0x44, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x75, 0x69, 0x64, 0x50, 0x4e, 0x44, 0x12, 0x25, 0x0a, - 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x06, 0x64, 0x65, - 0x76, 0x69, 0x63, 0x65, 0x22, 0x2a, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, - 0x65, 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, 0x60, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x75, 0x69, 0x64, 0x50, 0x4e, 0x44, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x75, 0x69, 0x64, 0x50, 0x4e, 0x44, 0x12, 0x1e, - 0x0a, 0x0a, 0x75, 0x75, 0x69, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x75, 0x75, 0x69, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x22, 0x2a, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 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, 0xb0, 0x05, 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, 0x12, 0x3d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x4e, 0x44, - 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, - 0x4e, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x4e, 0x44, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x4e, 0x44, 0x73, - 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, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x41, 0x6c, 0x6c, 0x50, 0x4e, 0x44, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, - 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x53, 0x42, 0x49, 0x4e, 0x61, 0x6d, 0x65, - 0x73, 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, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x53, 0x42, 0x49, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x44, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x16, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x44, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, - 0x65, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 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_gosdnCLI_proto_rawDescOnce sync.Once - file_gosdnCLI_proto_rawDescData = file_gosdnCLI_proto_rawDesc -) - -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_gosdnCLI_proto_rawDescData -} - -var file_gosdnCLI_proto_msgTypes = make([]protoimpl.MessageInfo, 17) -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 - (*CreatePNDRequest)(nil), // 6: proto.CreatePNDRequest - (*AllSBINamesReply)(nil), // 7: proto.AllSBINamesReply - (*CreatePNDReply)(nil), // 8: proto.CreatePNDReply - (*AllPNDsReply)(nil), // 9: proto.AllPNDsReply - (*PND)(nil), // 10: proto.PND - (*Device)(nil), // 11: proto.Device - (*AddDeviceRequest)(nil), // 12: proto.AddDeviceRequest - (*AddDeviceReply)(nil), // 13: proto.AddDeviceReply - (*DeviceGetRequest)(nil), // 14: proto.DeviceGetRequest - (*DeviceGetReply)(nil), // 15: proto.DeviceGetReply - (*LogReply)(nil), // 16: proto.LogReply - (*emptypb.Empty)(nil), // 17: google.protobuf.Empty -} -var file_gosdnCLI_proto_depIdxs = []int32{ - 10, // 0: proto.AllPNDsReply.pnds:type_name -> proto.PND - 11, // 1: proto.PND.devices:type_name -> proto.Device - 11, // 2: proto.AddDeviceRequest.device:type_name -> proto.Device - 0, // 3: proto.GrpcCli.SayHello:input_type -> proto.HelloRequest - 2, // 4: proto.GrpcCli.Shutdown:input_type -> proto.ShutdownRequest - 17, // 5: proto.GrpcCli.CreateLogStream:input_type -> google.protobuf.Empty - 4, // 6: proto.GrpcCli.TAPIGetEdge:input_type -> proto.TAPIRequest - 4, // 7: proto.GrpcCli.TAPIGetEdgeNode:input_type -> proto.TAPIRequest - 4, // 8: proto.GrpcCli.TAPIGetLink:input_type -> proto.TAPIRequest - 6, // 9: proto.GrpcCli.CreatePND:input_type -> proto.CreatePNDRequest - 17, // 10: proto.GrpcCli.GetAllPNDs:input_type -> google.protobuf.Empty - 17, // 11: proto.GrpcCli.GetAllSBINames:input_type -> google.protobuf.Empty - 12, // 12: proto.GrpcCli.AddDevice:input_type -> proto.AddDeviceRequest - 14, // 13: proto.GrpcCli.HandleDeviceGetRequest:input_type -> proto.DeviceGetRequest - 1, // 14: proto.GrpcCli.SayHello:output_type -> proto.HelloReply - 3, // 15: proto.GrpcCli.Shutdown:output_type -> proto.ShutdownReply - 16, // 16: proto.GrpcCli.CreateLogStream:output_type -> proto.LogReply - 5, // 17: proto.GrpcCli.TAPIGetEdge:output_type -> proto.TAPIReply - 5, // 18: proto.GrpcCli.TAPIGetEdgeNode:output_type -> proto.TAPIReply - 5, // 19: proto.GrpcCli.TAPIGetLink:output_type -> proto.TAPIReply - 8, // 20: proto.GrpcCli.CreatePND:output_type -> proto.CreatePNDReply - 9, // 21: proto.GrpcCli.GetAllPNDs:output_type -> proto.AllPNDsReply - 7, // 22: proto.GrpcCli.GetAllSBINames:output_type -> proto.AllSBINamesReply - 13, // 23: proto.GrpcCli.AddDevice:output_type -> proto.AddDeviceReply - 15, // 24: proto.GrpcCli.HandleDeviceGetRequest:output_type -> proto.DeviceGetReply - 14, // [14:25] is the sub-list for method output_type - 3, // [3:14] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_gosdnCLI_proto_init() } -func file_gosdnCLI_proto_init() { - if File_gosdnCLI_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_gosdnCLI_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShutdownRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShutdownReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_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_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 - } - } - file_gosdnCLI_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePNDRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllSBINamesReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePNDReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllPNDsReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PND); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Device); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddDeviceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddDeviceReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeviceGetRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeviceGetReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_gosdnCLI_proto_msgTypes[16].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_gosdnCLI_proto_rawDesc, - NumEnums: 0, - NumMessages: 17, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_gosdnCLI_proto_goTypes, - DependencyIndexes: file_gosdnCLI_proto_depIdxs, - MessageInfos: file_gosdnCLI_proto_msgTypes, - }.Build() - 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 *emptypb.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) - // CreatePND - CreatePND(ctx context.Context, in *CreatePNDRequest, opts ...grpc.CallOption) (*CreatePNDReply, error) - // GetAllPNDs - GetAllPNDs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*AllPNDsReply, error) - // GetAllSBIs - GetAllSBINames(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*AllSBINamesReply, error) - // AddDevice - AddDevice(ctx context.Context, in *AddDeviceRequest, opts ...grpc.CallOption) (*AddDeviceReply, error) - // HandleDeviceGetRequest - HandleDeviceGetRequest(ctx context.Context, in *DeviceGetRequest, opts ...grpc.CallOption) (*DeviceGetReply, 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 *emptypb.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 -} - -func (c *grpcCliClient) CreatePND(ctx context.Context, in *CreatePNDRequest, opts ...grpc.CallOption) (*CreatePNDReply, error) { - out := new(CreatePNDReply) - err := c.cc.Invoke(ctx, "/proto.GrpcCli/CreatePND", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) GetAllPNDs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*AllPNDsReply, error) { - out := new(AllPNDsReply) - err := c.cc.Invoke(ctx, "/proto.GrpcCli/GetAllPNDs", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) GetAllSBINames(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*AllSBINamesReply, error) { - out := new(AllSBINamesReply) - err := c.cc.Invoke(ctx, "/proto.GrpcCli/GetAllSBINames", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) AddDevice(ctx context.Context, in *AddDeviceRequest, opts ...grpc.CallOption) (*AddDeviceReply, error) { - out := new(AddDeviceReply) - err := c.cc.Invoke(ctx, "/proto.GrpcCli/AddDevice", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *grpcCliClient) HandleDeviceGetRequest(ctx context.Context, in *DeviceGetRequest, opts ...grpc.CallOption) (*DeviceGetReply, error) { - out := new(DeviceGetReply) - err := c.cc.Invoke(ctx, "/proto.GrpcCli/HandleDeviceGetRequest", 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(*emptypb.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) - // CreatePND - CreatePND(context.Context, *CreatePNDRequest) (*CreatePNDReply, error) - // GetAllPNDs - GetAllPNDs(context.Context, *emptypb.Empty) (*AllPNDsReply, error) - // GetAllSBIs - GetAllSBINames(context.Context, *emptypb.Empty) (*AllSBINamesReply, error) - // AddDevice - AddDevice(context.Context, *AddDeviceRequest) (*AddDeviceReply, error) - // HandleDeviceGetRequest - HandleDeviceGetRequest(context.Context, *DeviceGetRequest) (*DeviceGetReply, 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(*emptypb.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 (*UnimplementedGrpcCliServer) CreatePND(context.Context, *CreatePNDRequest) (*CreatePNDReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreatePND not implemented") -} -func (*UnimplementedGrpcCliServer) GetAllPNDs(context.Context, *emptypb.Empty) (*AllPNDsReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAllPNDs not implemented") -} -func (*UnimplementedGrpcCliServer) GetAllSBINames(context.Context, *emptypb.Empty) (*AllSBINamesReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAllSBINames not implemented") -} -func (*UnimplementedGrpcCliServer) AddDevice(context.Context, *AddDeviceRequest) (*AddDeviceReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddDevice not implemented") -} -func (*UnimplementedGrpcCliServer) HandleDeviceGetRequest(context.Context, *DeviceGetRequest) (*DeviceGetReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method HandleDeviceGetRequest 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(emptypb.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) -} - -func _GrpcCli_CreatePND_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreatePNDRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).CreatePND(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.GrpcCli/CreatePND", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).CreatePND(ctx, req.(*CreatePNDRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_GetAllPNDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).GetAllPNDs(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.GrpcCli/GetAllPNDs", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).GetAllPNDs(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_GetAllSBINames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).GetAllSBINames(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.GrpcCli/GetAllSBINames", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).GetAllSBINames(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_AddDevice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddDeviceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).AddDevice(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.GrpcCli/AddDevice", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).AddDevice(ctx, req.(*AddDeviceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GrpcCli_HandleDeviceGetRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeviceGetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GrpcCliServer).HandleDeviceGetRequest(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.GrpcCli/HandleDeviceGetRequest", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GrpcCliServer).HandleDeviceGetRequest(ctx, req.(*DeviceGetRequest)) - } - 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, - }, - { - MethodName: "CreatePND", - Handler: _GrpcCli_CreatePND_Handler, - }, - { - MethodName: "GetAllPNDs", - Handler: _GrpcCli_GetAllPNDs_Handler, - }, - { - MethodName: "GetAllSBINames", - Handler: _GrpcCli_GetAllSBINames_Handler, - }, - { - MethodName: "AddDevice", - Handler: _GrpcCli_AddDevice_Handler, - }, - { - MethodName: "HandleDeviceGetRequest", - Handler: _GrpcCli_HandleDeviceGetRequest_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 deleted file mode 100644 index 355d8e7455f009d2b35e8bc34c079ce31466bbdd..0000000000000000000000000000000000000000 --- a/api/proto/gosdnCLI.proto +++ /dev/null @@ -1,125 +0,0 @@ -syntax = "proto3"; -import "google/protobuf/empty.proto"; - -option go_package = "gitlab.fbi.h-da.de/cocsn/gosdn"; - -package proto; - -// The greeting service definition. -service GrpcCli { - // Sends a greeting - 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 - rpc TAPIGetEdge (TAPIRequest) returns (TAPIReply) {} - //TAPIGetEdgeNode - rpc TAPIGetEdgeNode (TAPIRequest) returns (TAPIReply) {} - // TAPIGetLink - rpc TAPIGetLink (TAPIRequest) returns (TAPIReply) {} - // CreatePND - rpc CreatePND (CreatePNDRequest) returns (CreatePNDReply) {} - // GetAllPNDs - rpc GetAllPNDs(google.protobuf.Empty) returns (AllPNDsReply) {} - // GetAllSBIs - rpc GetAllSBINames(google.protobuf.Empty) returns (AllSBINamesReply) {} - // AddDevice - rpc AddDevice(AddDeviceRequest) returns (AddDeviceReply) {} - // HandleDeviceGetRequest - rpc HandleDeviceGetRequest(DeviceGetRequest) returns (DeviceGetReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; - string goSDNInfo = 2; -} - -// Request to shutdown goSDN -message ShutdownRequest { - string name = 1; -} - -// The response message containing some shutdown notes of goSDN -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; -} - -// -message CreatePNDRequest { - string name = 1; - string description = 2; - string sbi = 3; -} - -message AllSBINamesReply { - repeated string sbiNames = 1; -} - -// -message CreatePNDReply { - string message = 1; -} - -// -message AllPNDsReply { - repeated PND pnds = 1; -} - -message PND { - string uuid = 1; - string name = 2; - string description = 3; - string sbi = 4; - repeated Device devices = 5; -} - -message Device { - string uuid = 1; - string address = 2; - string username = 3; - string password = 4; -} - -message AddDeviceRequest { - string uuidPND = 1; - Device device = 2; -} - -message AddDeviceReply { - string message = 1; -} - -message DeviceGetRequest { - string uuidPND = 1; - string uuidDevice = 2; - string path = 3; -} - -message DeviceGetReply { - string message = 1; -} - -// The response message containing a string with a goSDN log -message LogReply { - string log = 1; -} diff --git a/cli/path_traversal.go b/cli/path_traversal.go index 19bcadf591409a5af70cf41f041f9db8a0e9d6af..06f2dbf3709cbcc99539fac03a299daad0bcab2d 100644 --- a/cli/path_traversal.go +++ b/cli/path_traversal.go @@ -1,16 +1,14 @@ package cli import ( - "code.fbi.h-da.de/cocsn/gosdn/nucleus/util" - "code.fbi.h-da.de/cocsn/yang-models/generated/openconfig" + "code.fbi.h-da.de/cocsn/gosdn/nucleus/util/path" log "github.com/sirupsen/logrus" ) func PathTraversal() error { log.SetLevel(log.DebugLevel) - schema, _ := openconfig.Schema() - paths := util.NewPaths() - if err := paths.ParseSchema(schema, "device"); err != nil { + paths, err := path.ParseSchema(schema, "device") + if err != nil { return err } @@ -18,7 +16,7 @@ func PathTraversal() error { v.Print() } - p := paths.StringBuilder() + p := path.Strings(paths) log.Debug(p) return nil } diff --git a/cmd/gosdn/gosdn b/cmd/gosdn/gosdn new file mode 100755 index 0000000000000000000000000000000000000000..645db8da274b5591f64db0ac267ff48df21c2714 Binary files /dev/null and b/cmd/gosdn/gosdn differ diff --git a/mocks/GrpcCliClient.go b/mocks/GrpcCliClient.go deleted file mode 100644 index f52bffb70d5518b1b140fd2b2436632b104a5f0a..0000000000000000000000000000000000000000 --- a/mocks/GrpcCliClient.go +++ /dev/null @@ -1,349 +0,0 @@ -// Code generated by mockery v2.6.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - gosdn "code.fbi.h-da.de/cocsn/gosdn/api/proto" - emptypb "google.golang.org/protobuf/types/known/emptypb" - - grpc "google.golang.org/grpc" - - mock "github.com/stretchr/testify/mock" -) - -// GrpcCliClient is an autogenerated mock type for the GrpcCliClient type -type GrpcCliClient struct { - mock.Mock -} - -// AddDevice provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) AddDevice(ctx context.Context, in *gosdn.AddDeviceRequest, opts ...grpc.CallOption) (*gosdn.AddDeviceReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.AddDeviceReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.AddDeviceRequest, ...grpc.CallOption) *gosdn.AddDeviceReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AddDeviceReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.AddDeviceRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreateLogStream provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) CreateLogStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (gosdn.GrpcCli_CreateLogStreamClient, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 gosdn.GrpcCli_CreateLogStreamClient - if rf, ok := ret.Get(0).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) gosdn.GrpcCli_CreateLogStreamClient); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gosdn.GrpcCli_CreateLogStreamClient) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreatePND provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) CreatePND(ctx context.Context, in *gosdn.CreatePNDRequest, opts ...grpc.CallOption) (*gosdn.CreatePNDReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.CreatePNDReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.CreatePNDRequest, ...grpc.CallOption) *gosdn.CreatePNDReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.CreatePNDReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.CreatePNDRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAllPNDs provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) GetAllPNDs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*gosdn.AllPNDsReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.AllPNDsReply - if rf, ok := ret.Get(0).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) *gosdn.AllPNDsReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AllPNDsReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAllSBINames provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) GetAllSBINames(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*gosdn.AllSBINamesReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.AllSBINamesReply - if rf, ok := ret.Get(0).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) *gosdn.AllSBINamesReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AllSBINamesReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *emptypb.Empty, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// HandleDeviceGetRequest provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) HandleDeviceGetRequest(ctx context.Context, in *gosdn.DeviceGetRequest, opts ...grpc.CallOption) (*gosdn.DeviceGetReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.DeviceGetReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.DeviceGetRequest, ...grpc.CallOption) *gosdn.DeviceGetReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.DeviceGetReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.DeviceGetRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SayHello provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) SayHello(ctx context.Context, in *gosdn.HelloRequest, opts ...grpc.CallOption) (*gosdn.HelloReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.HelloReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.HelloRequest, ...grpc.CallOption) *gosdn.HelloReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.HelloReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.HelloRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Shutdown provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) Shutdown(ctx context.Context, in *gosdn.ShutdownRequest, opts ...grpc.CallOption) (*gosdn.ShutdownReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.ShutdownReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.ShutdownRequest, ...grpc.CallOption) *gosdn.ShutdownReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.ShutdownReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.ShutdownRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetEdge provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) TAPIGetEdge(ctx context.Context, in *gosdn.TAPIRequest, opts ...grpc.CallOption) (*gosdn.TAPIReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) *gosdn.TAPIReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetEdgeNode provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) TAPIGetEdgeNode(ctx context.Context, in *gosdn.TAPIRequest, opts ...grpc.CallOption) (*gosdn.TAPIReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) *gosdn.TAPIReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetLink provides a mock function with given fields: ctx, in, opts -func (_m *GrpcCliClient) TAPIGetLink(ctx context.Context, in *gosdn.TAPIRequest, opts ...grpc.CallOption) (*gosdn.TAPIReply, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) *gosdn.TAPIReply); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/GrpcCliServer.go b/mocks/GrpcCliServer.go deleted file mode 100644 index e7b36e9e24f5c42ad7b927157fb3b9d6a7856927..0000000000000000000000000000000000000000 --- a/mocks/GrpcCliServer.go +++ /dev/null @@ -1,261 +0,0 @@ -// Code generated by mockery v2.6.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - gosdn "code.fbi.h-da.de/cocsn/gosdn/api/proto" - emptypb "google.golang.org/protobuf/types/known/emptypb" - - mock "github.com/stretchr/testify/mock" -) - -// GrpcCliServer is an autogenerated mock type for the GrpcCliServer type -type GrpcCliServer struct { - mock.Mock -} - -// AddDevice provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) AddDevice(_a0 context.Context, _a1 *gosdn.AddDeviceRequest) (*gosdn.AddDeviceReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.AddDeviceReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.AddDeviceRequest) *gosdn.AddDeviceReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AddDeviceReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.AddDeviceRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreateLogStream provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) CreateLogStream(_a0 *emptypb.Empty, _a1 gosdn.GrpcCli_CreateLogStreamServer) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*emptypb.Empty, gosdn.GrpcCli_CreateLogStreamServer) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// CreatePND provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) CreatePND(_a0 context.Context, _a1 *gosdn.CreatePNDRequest) (*gosdn.CreatePNDReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.CreatePNDReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.CreatePNDRequest) *gosdn.CreatePNDReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.CreatePNDReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.CreatePNDRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAllPNDs provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) GetAllPNDs(_a0 context.Context, _a1 *emptypb.Empty) (*gosdn.AllPNDsReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.AllPNDsReply - if rf, ok := ret.Get(0).(func(context.Context, *emptypb.Empty) *gosdn.AllPNDsReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AllPNDsReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *emptypb.Empty) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAllSBINames provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) GetAllSBINames(_a0 context.Context, _a1 *emptypb.Empty) (*gosdn.AllSBINamesReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.AllSBINamesReply - if rf, ok := ret.Get(0).(func(context.Context, *emptypb.Empty) *gosdn.AllSBINamesReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.AllSBINamesReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *emptypb.Empty) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// HandleDeviceGetRequest provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) HandleDeviceGetRequest(_a0 context.Context, _a1 *gosdn.DeviceGetRequest) (*gosdn.DeviceGetReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.DeviceGetReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.DeviceGetRequest) *gosdn.DeviceGetReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.DeviceGetReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.DeviceGetRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SayHello provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) SayHello(_a0 context.Context, _a1 *gosdn.HelloRequest) (*gosdn.HelloReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.HelloReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.HelloRequest) *gosdn.HelloReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.HelloReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.HelloRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Shutdown provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) Shutdown(_a0 context.Context, _a1 *gosdn.ShutdownRequest) (*gosdn.ShutdownReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.ShutdownReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.ShutdownRequest) *gosdn.ShutdownReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.ShutdownReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.ShutdownRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetEdge provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) TAPIGetEdge(_a0 context.Context, _a1 *gosdn.TAPIRequest) (*gosdn.TAPIReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest) *gosdn.TAPIReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetEdgeNode provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) TAPIGetEdgeNode(_a0 context.Context, _a1 *gosdn.TAPIRequest) (*gosdn.TAPIReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest) *gosdn.TAPIReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// TAPIGetLink provides a mock function with given fields: _a0, _a1 -func (_m *GrpcCliServer) TAPIGetLink(_a0 context.Context, _a1 *gosdn.TAPIRequest) (*gosdn.TAPIReply, error) { - ret := _m.Called(_a0, _a1) - - var r0 *gosdn.TAPIReply - if rf, ok := ret.Get(0).(func(context.Context, *gosdn.TAPIRequest) *gosdn.TAPIReply); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.TAPIReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *gosdn.TAPIRequest) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/mocks/GrpcCli_CreateLogStreamClient.go b/mocks/GrpcCli_CreateLogStreamClient.go deleted file mode 100644 index 8e8c0cc1f5a445354decaa4c491e9faa8938c6b5..0000000000000000000000000000000000000000 --- a/mocks/GrpcCli_CreateLogStreamClient.go +++ /dev/null @@ -1,137 +0,0 @@ -// Code generated by mockery v2.6.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - gosdn "code.fbi.h-da.de/cocsn/gosdn/api/proto" - metadata "google.golang.org/grpc/metadata" - - mock "github.com/stretchr/testify/mock" -) - -// GrpcCli_CreateLogStreamClient is an autogenerated mock type for the GrpcCli_CreateLogStreamClient type -type GrpcCli_CreateLogStreamClient struct { - mock.Mock -} - -// CloseSend provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamClient) CloseSend() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Context provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamClient) Context() context.Context { - ret := _m.Called() - - var r0 context.Context - if rf, ok := ret.Get(0).(func() context.Context); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(context.Context) - } - } - - return r0 -} - -// Header provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamClient) Header() (metadata.MD, error) { - ret := _m.Called() - - var r0 metadata.MD - if rf, ok := ret.Get(0).(func() metadata.MD); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(metadata.MD) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Recv provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamClient) Recv() (*gosdn.LogReply, error) { - ret := _m.Called() - - var r0 *gosdn.LogReply - if rf, ok := ret.Get(0).(func() *gosdn.LogReply); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gosdn.LogReply) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RecvMsg provides a mock function with given fields: m -func (_m *GrpcCli_CreateLogStreamClient) RecvMsg(m interface{}) error { - ret := _m.Called(m) - - var r0 error - if rf, ok := ret.Get(0).(func(interface{}) error); ok { - r0 = rf(m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendMsg provides a mock function with given fields: m -func (_m *GrpcCli_CreateLogStreamClient) SendMsg(m interface{}) error { - ret := _m.Called(m) - - var r0 error - if rf, ok := ret.Get(0).(func(interface{}) error); ok { - r0 = rf(m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Trailer provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamClient) Trailer() metadata.MD { - ret := _m.Called() - - var r0 metadata.MD - if rf, ok := ret.Get(0).(func() metadata.MD); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(metadata.MD) - } - } - - return r0 -} diff --git a/mocks/GrpcCli_CreateLogStreamServer.go b/mocks/GrpcCli_CreateLogStreamServer.go deleted file mode 100644 index 6141c33a47ffc2e7707b088e70f426f9f661824d..0000000000000000000000000000000000000000 --- a/mocks/GrpcCli_CreateLogStreamServer.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by mockery v2.6.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - gosdn "code.fbi.h-da.de/cocsn/gosdn/api/proto" - metadata "google.golang.org/grpc/metadata" - - mock "github.com/stretchr/testify/mock" -) - -// GrpcCli_CreateLogStreamServer is an autogenerated mock type for the GrpcCli_CreateLogStreamServer type -type GrpcCli_CreateLogStreamServer struct { - mock.Mock -} - -// Context provides a mock function with given fields: -func (_m *GrpcCli_CreateLogStreamServer) Context() context.Context { - ret := _m.Called() - - var r0 context.Context - if rf, ok := ret.Get(0).(func() context.Context); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(context.Context) - } - } - - return r0 -} - -// RecvMsg provides a mock function with given fields: m -func (_m *GrpcCli_CreateLogStreamServer) RecvMsg(m interface{}) error { - ret := _m.Called(m) - - var r0 error - if rf, ok := ret.Get(0).(func(interface{}) error); ok { - r0 = rf(m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Send provides a mock function with given fields: _a0 -func (_m *GrpcCli_CreateLogStreamServer) Send(_a0 *gosdn.LogReply) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(*gosdn.LogReply) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendHeader provides a mock function with given fields: _a0 -func (_m *GrpcCli_CreateLogStreamServer) SendHeader(_a0 metadata.MD) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SendMsg provides a mock function with given fields: m -func (_m *GrpcCli_CreateLogStreamServer) SendMsg(m interface{}) error { - ret := _m.Called(m) - - var r0 error - if rf, ok := ret.Get(0).(func(interface{}) error); ok { - r0 = rf(m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetHeader provides a mock function with given fields: _a0 -func (_m *GrpcCli_CreateLogStreamServer) SetHeader(_a0 metadata.MD) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetTrailer provides a mock function with given fields: _a0 -func (_m *GrpcCli_CreateLogStreamServer) SetTrailer(_a0 metadata.MD) { - _m.Called(_a0) -} diff --git a/nucleus/cli-handling.go b/nucleus/cli-handling.go deleted file mode 100644 index 55136026e9ebd4af850f43e5647b6425f596f86e..0000000000000000000000000000000000000000 --- a/nucleus/cli-handling.go +++ /dev/null @@ -1,307 +0,0 @@ -/* - This file contains the grpc cli server-side calls. - Functions here should call other functions in charge of the - particular task. -*/ - -package nucleus - -import ( - "context" - "errors" - "io" - "net" - "os" - "sync" - - "github.com/google/uuid" - "github.com/spf13/viper" - - pb "code.fbi.h-da.de/cocsn/gosdn/api/proto" - "code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi" - gpb "github.com/openconfig/gnmi/proto/gnmi" - log "github.com/sirupsen/logrus" - "google.golang.org/grpc" - "google.golang.org/grpc/health" - healthpb "google.golang.org/grpc/health/grpc_health_v1" - "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 - 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) { - log.Info("Received: ", in.GetName()) - return &pb.HelloReply{Message: "Hello " + in.GetName(), GoSDNInfo: "goSDN in version: DEVELOP"}, nil -} - -// CreateLogStream 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 - return &pb.ShutdownReply{Message: "Shutdown " + in.GetName()}, nil -} - -func getCLIGoing(core *Core) { - - var ( - logConnections []*logConnection - logBuffer buf - system = "" - ) - - log.Info("Starting: GetCLIGoing") - // Boot-up the control interface for the cli - cliControlListener, err := net.Listen("tcp", viper.GetString("socket")) - if err != nil { - log.Fatal(err) - } - - cliControlServer := grpc.NewServer() - healthCheck := health.NewServer() - srv = &server{core: core, logConnections: logConnections} - - //TODO: move? - wrt := io.MultiWriter(os.Stdout, &logBuffer) - log.SetOutput(wrt) - - healthpb.RegisterHealthServer(cliControlServer, healthCheck) - pb.RegisterGrpcCliServer(cliControlServer, srv) - - healthCheck.SetServingStatus(system, healthpb.HealthCheckResponse_SERVING) - - if err := cliControlServer.Serve(cliControlListener); err != nil { - log.Fatal(err) - } -} - -// CreatePND creates a new PND and adds it to the principalNetworkDomain map of -// the core -func (s *server) CreatePND(ctx context.Context, in *pb.CreatePNDRequest) (*pb.CreatePNDReply, error) { - log.Info("Received: Create a PND with the name", in.GetName()) - sbi, err := s.core.sbic.get(uuid.New()) - if err != nil { - return nil, err - } - id := uuid.New() - pnd, err := NewPND(in.GetName(), in.GetDescription(), id, sbi.(SouthboundInterface)) - if err != nil { - log.Error(err) - return &pb.CreatePNDReply{Message: err.Error()}, err - } - if err := s.core.pndc.add(pnd); err != nil { - return nil, err - } - - return &pb.CreatePNDReply{Message: "Created new PND: " + id.String()}, nil -} - -// deprecated -// Subject to change, using discontinued full device access -// GetAllPNDs is a request to get all currently registered PNDs and returns a slim -// variant of PNDs and their respective devices -func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDsReply, error) { - log.Info("Received: Get all PNDs") - var pnds []*pb.PND - for _, uuidPND := range s.core.pndc.UUIDs() { - pnd, err := s.core.pndc.get(uuidPND) - if err != nil { - log.Error(err) - continue - } - var devices []*pb.Device - for uuidDevice, d := range pnd.(*pndImplementation).devices.store { - device, ok := d.(*Device) - if !ok { - log.Error(&ErrInvalidTypeAssertion{ - v: d, - t: "Device", - }) - } - tmpDevice := pb.Device{ - Uuid: uuidDevice.String(), - Address: device.Transport.GetOptions().(TransportOptions).GetAddress(), - Username: device.Transport.GetOptions().(TransportOptions).GetUsername(), - Password: device.Transport.GetOptions().(TransportOptions).GetPassword(), - } - devices = append(devices, &tmpDevice) - } - sbi, err := s.core.sbic.get(pnd.GetSBIs().(*sbiStore).UUIDs()[0]) - if err != nil { - log.Error(err) - continue - } - tmpPND := pb.PND{ - Uuid: uuidPND.String(), - Name: pnd.GetName(), - Description: pnd.GetDescription(), - Sbi: sbi.SbiIdentifier(), - Devices: devices, - } - pnds = append(pnds, &tmpPND) - } - return &pb.AllPNDsReply{Pnds: pnds}, nil -} - -// GetAllSBINames returns all registered SBIs from core. -func (s *server) GetAllSBINames(ctx context.Context, in *emptypb.Empty) (*pb.AllSBINamesReply, error) { - var sbiNames []string - for _, uuidDevice := range s.core.sbic.UUIDs() { - s, err := s.core.sbic.get(uuidDevice) - if err != nil { - log.Error(err) - continue - } - sbiNames = append(sbiNames, s.SbiIdentifier()) - } - return &pb.AllSBINamesReply{SbiNames: sbiNames}, nil -} - -// AddDevice adds a new Device to a specific PND -// currently this is only working with gnmi transports -func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.AddDeviceReply, error) { - log.Info("Received: AddDevice") - uuidPND, err := uuid.Parse(in.UuidPND) - if err != nil { - return &pb.AddDeviceReply{Message: err.Error()}, err - } - pnd, err := s.core.pndc.get(uuidPND) - if err != nil { - log.Error(err) - return &pb.AddDeviceReply{Message: err.Error()}, err - } - // TODO: Add notion of default SBI to PND or solve differently - uuidSbi := pnd.GetSBIs().(*sbiStore).UUIDs()[0] - sbi, err := s.core.sbic.get(uuidSbi) - if err != nil { - log.Error(err) - return &pb.AddDeviceReply{Message: err.Error()}, err - } - - newDevice, err := NewDevice(sbi, - &GnmiTransportOptions{ - Config: gnmi.Config{ - Addr: in.Device.Address, - Username: in.Device.Username, - Password: in.Device.Password, - Encoding: gpb.Encoding_JSON_IETF, - }, - SetNode: sbi.SetNode(), - }) - if err != nil { - log.Info(err) - return &pb.AddDeviceReply{Message: err.Error()}, err - } - - err = pnd.AddDevice(newDevice) - if err != nil { - log.Error(err) - return &pb.AddDeviceReply{Message: err.Error()}, err - } - - return &pb.AddDeviceReply{Message: "Added new Device: " + newDevice.Uuid.String()}, err -} - -// HandleDeviceGetRequest handles a GET request via pnd.Request() -func (s *server) HandleDeviceGetRequest(ctx context.Context, in *pb.DeviceGetRequest) (*pb.DeviceGetReply, error) { - log.Info("Received: HandleDeviceGetRequest") - uuidPND, err := uuid.Parse(in.GetUuidPND()) - if err != nil { - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - uuidDevice, err := uuid.Parse(in.GetUuidDevice()) - if err != nil { - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - pnd, err := s.core.pndc.get(uuidPND) - if err != nil { - err := errors.New("Couldnt find PND: UUID is wrong") - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - //check if the device exists - if !pnd.ContainsDevice(uuidDevice) { - err := errors.New("Couldnt find device: UUID is wrong") - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - - //GET request for the provided path - err = pnd.Request(uuidDevice, in.GetPath()) - if err != nil { - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - - d, err := pnd.MarshalDevice(uuidDevice) - if err != nil { - log.Info(err) - return &pb.DeviceGetReply{Message: err.Error()}, err - } - - return &pb.DeviceGetReply{Message: d}, nil -} diff --git a/nucleus/cli-handling_test.go b/nucleus/cli-handling_test.go deleted file mode 100644 index 522de1a0cfa12cea3ac919e23f5696865e7159f1..0000000000000000000000000000000000000000 --- a/nucleus/cli-handling_test.go +++ /dev/null @@ -1,377 +0,0 @@ -package nucleus - -import ( - pb "code.fbi.h-da.de/cocsn/gosdn/api/proto" - "context" - "google.golang.org/protobuf/types/known/emptypb" - "reflect" - "testing" -) - -func Test_buf_Write(t *testing.T) { - type args struct { - p []byte - } - tests := []struct { - name string - b buf - args args - wantN int - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotN, err := tt.b.Write(tt.args.p) - if (err != nil) != tt.wantErr { - t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr) - return - } - if gotN != tt.wantN { - t.Errorf("Write() gotN = %v, want %v", gotN, tt.wantN) - } - }) - } -} - -func Test_getCLIGoing(t *testing.T) { - type args struct { - core *Core - } - tests := []struct { - name string - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - }) - } -} - -func Test_server_AddDevice(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *pb.AddDeviceRequest - } - tests := []struct { - name string - fields fields - args args - want *pb.AddDeviceReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.AddDevice(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("AddDevice() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("AddDevice() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_BroadcastLog(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - log *pb.LogReply - } - tests := []struct { - name string - fields fields - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _ = &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - }) - } -} - -func Test_server_CreateLogStream(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - req *emptypb.Empty - stream pb.GrpcCli_CreateLogStreamServer - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - if err := s.CreateLogStream(tt.args.req, tt.args.stream); (err != nil) != tt.wantErr { - t.Errorf("CreateLogStream() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func Test_server_CreatePND(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *pb.CreatePNDRequest - } - tests := []struct { - name string - fields fields - args args - want *pb.CreatePNDReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.CreatePND(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("CreatePND() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("CreatePND() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_GetAllPNDs(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *emptypb.Empty - } - tests := []struct { - name string - fields fields - args args - want *pb.AllPNDsReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.GetAllPNDs(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("GetAllPNDs() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetAllPNDs() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_GetAllSBINames(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *emptypb.Empty - } - tests := []struct { - name string - fields fields - args args - want *pb.AllSBINamesReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.GetAllSBINames(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("GetAllSBINames() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetAllSBINames() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_HandleDeviceGetRequest(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *pb.DeviceGetRequest - } - tests := []struct { - name string - fields fields - args args - want *pb.DeviceGetReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.HandleDeviceGetRequest(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("HandleDeviceGetRequest() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("HandleDeviceGetRequest() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_SayHello(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *pb.HelloRequest - } - tests := []struct { - name string - fields fields - args args - want *pb.HelloReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.SayHello(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("SayHello() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("SayHello() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_server_Shutdown(t *testing.T) { - type fields struct { - UnimplementedGrpcCliServer pb.UnimplementedGrpcCliServer - core *Core - logConnections []*logConnection - } - type args struct { - ctx context.Context - in *pb.ShutdownRequest - } - tests := []struct { - name string - fields fields - args args - want *pb.ShutdownReply - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - s := &server{ - UnimplementedGrpcCliServer: tt.fields.UnimplementedGrpcCliServer, - core: tt.fields.core, - logConnections: tt.fields.logConnections, - } - got, err := s.Shutdown(tt.args.ctx, tt.args.in) - if (err != nil) != tt.wantErr { - t.Errorf("Shutdown() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Shutdown() got = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/nucleus/gnmi_transport_test.go b/nucleus/gnmi_transport_test.go index 206e231a9d1666022f7ef6fa83b2b43ded9ac858..888a01a7b49f1274c87dfad854fc70b2cd1977a3 100644 --- a/nucleus/gnmi_transport_test.go +++ b/nucleus/gnmi_transport_test.go @@ -3,18 +3,18 @@ package nucleus import ( "code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi" "code.fbi.h-da.de/cocsn/gosdn/mocks" - "code.fbi.h-da.de/cocsn/gosdn/nucleus/util" + "code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto" "code.fbi.h-da.de/cocsn/gosdn/test" "code.fbi.h-da.de/cocsn/yang-models/generated/openconfig" "context" "errors" log "github.com/golang/glog" - "github.com/golang/protobuf/proto" gpb "github.com/openconfig/gnmi/proto/gnmi" "github.com/openconfig/gnmi/proto/gnmi_ext" "github.com/openconfig/goyang/pkg/yang" "github.com/openconfig/ygot/ytypes" "github.com/stretchr/testify/mock" + pb "google.golang.org/protobuf/proto" "os" "reflect" "testing" @@ -23,22 +23,22 @@ import ( // TestMain bootstraps all tests. Humongous beast // TODO: Move somewhere more sensible func TestMain(m *testing.M) { - gnmiMessages = map[string]proto.Message{ - "../test/cap-resp-arista-ceos": &gpb.CapabilityResponse{}, - "../test/req-full-node": &gpb.GetRequest{}, - "../test/req-full-node-arista-ceos": &gpb.GetRequest{}, - "../test/req-interfaces-arista-ceos": &gpb.GetRequest{}, - "../test/req-interfaces-interface-arista-ceos": &gpb.GetRequest{}, - "../test/req-interfaces-wildcard": &gpb.GetRequest{}, - "../test/resp-full-node": &gpb.GetResponse{}, - "../test/resp-full-node-arista-ceos": &gpb.GetResponse{}, - "../test/resp-interfaces-arista-ceos": &gpb.GetResponse{}, - "../test/resp-interfaces-interface-arista-ceos": &gpb.GetResponse{}, - "../test/resp-interfaces-wildcard": &gpb.GetResponse{}, - "../test/resp-set-system-config-hostname": &gpb.SetResponse{}, + gnmiMessages = map[string]pb.Message{ + "../test/proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{}, + "../test/proto/req-full-node": &gpb.GetRequest{}, + "../test/proto/req-full-node-arista-ceos": &gpb.GetRequest{}, + "../test/proto/req-interfaces-arista-ceos": &gpb.GetRequest{}, + "../test/proto/req-interfaces-interface-arista-ceos": &gpb.GetRequest{}, + "../test/proto/req-interfaces-wildcard": &gpb.GetRequest{}, + "../test/proto/resp-full-node": &gpb.GetResponse{}, + "../test/proto/resp-full-node-arista-ceos": &gpb.GetResponse{}, + "../test/proto/resp-interfaces-arista-ceos": &gpb.GetResponse{}, + "../test/proto/resp-interfaces-interface-arista-ceos": &gpb.GetResponse{}, + "../test/proto/resp-interfaces-wildcard": &gpb.GetResponse{}, + "../test/proto/resp-set-system-config-hostname": &gpb.SetResponse{}, } for k, v := range gnmiMessages { - if err := util.Read(k, v); err != nil { + if err := proto.Read(k, v); err != nil { log.Fatalf("error parsing %v: %v", k, err) } } @@ -96,7 +96,7 @@ func newGnmiTransportOptions() *GnmiTransportOptions { } } -var gnmiMessages map[string]proto.Message +var gnmiMessages map[string]pb.Message var gnmiConfig *gnmi.Config var startGnmiTarget chan string var stopGnmiTarget chan bool @@ -297,7 +297,7 @@ func TestGnmi_ProcessResponse(t *testing.T) { name: "Interfaces Interface", fields: fields{Sbi: &OpenConfig{}}, args: args{ - path: "../test/resp-interfaces-interface-arista-ceos", + path: "../test/proto/resp-interfaces-interface-arista-ceos", root: &openconfig.Device{}, }, wantErr: true, @@ -306,7 +306,7 @@ func TestGnmi_ProcessResponse(t *testing.T) { name: "Interfaces Wildcard", fields: fields{Sbi: &OpenConfig{}}, args: args{ - path: "../test/resp-interfaces-wildcard", + path: "../test/proto/resp-interfaces-wildcard", root: &openconfig.Device{}, }, wantErr: false, @@ -315,7 +315,7 @@ func TestGnmi_ProcessResponse(t *testing.T) { name: "Root", fields: fields{Sbi: &OpenConfig{}}, args: args{ - path: "../test/resp-full-node-arista-ceos", + path: "../test/proto/resp-full-node-arista-ceos", root: &openconfig.Device{}, }, wantErr: false, @@ -432,10 +432,10 @@ func TestGnmi_Type(t *testing.T) { func TestGnmi_getWithRequest(t *testing.T) { transport := mockTransport() - reqFullNode := gnmiMessages["../test/req-full-node"].(*gpb.GetRequest) - reqInterfacesWildcard := gnmiMessages["../test/req-interfaces-wildcard"].(*gpb.GetRequest) - respFullNode := gnmiMessages["../test/resp-full-node"].(*gpb.GetResponse) - respInterfacesWildcard := gnmiMessages["../test/resp-interfaces-wildcard"].(*gpb.GetResponse) + reqFullNode := gnmiMessages["../test/proto/req-full-node"].(*gpb.GetRequest) + reqInterfacesWildcard := gnmiMessages["../test/proto/req-interfaces-wildcard"].(*gpb.GetRequest) + respFullNode := gnmiMessages["../test/proto/resp-full-node"].(*gpb.GetResponse) + respInterfacesWildcard := gnmiMessages["../test/proto/resp-interfaces-wildcard"].(*gpb.GetResponse) transport.client.(*mocks.GNMIClient). On("Get", mockContext, reqFullNode). diff --git a/nucleus/integration_test.go b/nucleus/integration_test.go index c57e2827f36abb7541cf4ec9b5b0df967e91cd62..26e543bb1bb7b8e61d61c3b5b6179b7b28420128 100644 --- a/nucleus/integration_test.go +++ b/nucleus/integration_test.go @@ -82,7 +82,7 @@ func TestGnmi_SetIntegration(t *testing.T) { }, }, }, - want: gnmiMessages["../test/resp-set-system-config-hostname"], + want: gnmiMessages["../test/proto/resp-set-system-config-hostname"], wantErr: false, }, } @@ -191,21 +191,21 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) { name: "supported models", fields: fields{opt: opt}, args: args{ctx: context.Background()}, - want: gnmiMessages["../test/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedModels, + want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedModels, wantErr: false, }, { name: "supported encodings", fields: fields{opt: opt}, args: args{ctx: context.Background()}, - want: gnmiMessages["../test/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedEncodings, + want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedEncodings, wantErr: false, }, { name: "gnmi version", fields: fields{opt: opt}, args: args{ctx: context.Background()}, - want: gnmiMessages["../test/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).GNMIVersion, + want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).GNMIVersion, wantErr: false, }, { diff --git a/nucleus/nucleus-core.go b/nucleus/nucleus-core.go index 8d87968f4f04db14fcec88fd695f62b3f67086c8..99dcb95046e730d787ee3f7308279aa113aa0217 100644 --- a/nucleus/nucleus-core.go +++ b/nucleus/nucleus-core.go @@ -17,7 +17,6 @@ func StartAndRun(IsRunningChannel chan bool) error { return err } // Start the GRCP CLI - go getCLIGoing(&core) go core.Shutdown() log.Info("and ready for take off") diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go index 951f7979c30723e9b2ff281f30c69588529eea93..c4ebf28f299bb84d8f4ae6cfd14f1efaec7327d2 100644 --- a/nucleus/southbound_test.go +++ b/nucleus/southbound_test.go @@ -1,11 +1,10 @@ package nucleus import ( - "code.fbi.h-da.de/cocsn/gosdn/nucleus/util" + "code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto" "code.fbi.h-da.de/cocsn/yang-models/generated/openconfig" "github.com/google/uuid" gpb "github.com/openconfig/gnmi/proto/gnmi" - "github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ytypes" log "github.com/sirupsen/logrus" "reflect" @@ -137,14 +136,14 @@ func Test_unmarshal(t *testing.T) { name: "fail", args: args{ goStruct: &openconfig.Device{}, - path: "../test/resp-interfaces-interface-arista-ceos", + path: "../test/proto/resp-interfaces-interface-arista-ceos", }, wantErr: true, }, { name: "root w/opts", args: args{ - path: "../test/resp-full-node-arista-ceos", + path: "../test/proto/resp-full-node-arista-ceos", goStruct: &openconfig.Device{}, opt: []ytypes.UnmarshalOpt{&ytypes.IgnoreExtraFields{}}, }, @@ -153,7 +152,7 @@ func Test_unmarshal(t *testing.T) { { name: "root w/o opts", args: args{ - path: "../test/resp-full-node-arista-ceos", + path: "../test/proto/resp-full-node-arista-ceos", goStruct: &openconfig.Device{}, opt: nil, }, @@ -162,7 +161,7 @@ func Test_unmarshal(t *testing.T) { { name: "interfaces w/opts", args: args{ - path: "../test/resp-interfaces-arista-ceos", + path: "../test/proto/resp-interfaces-arista-ceos", goStruct: &openconfig.Device{}, opt: []ytypes.UnmarshalOpt{&ytypes.IgnoreExtraFields{}}, }, @@ -171,7 +170,7 @@ func Test_unmarshal(t *testing.T) { { name: "interfaces w/o opts", args: args{ - path: "../test/resp-interfaces-arista-ceos", + path: "../test/proto/resp-interfaces-arista-ceos", goStruct: &openconfig.Device{}, opt: nil, }, @@ -181,7 +180,7 @@ func Test_unmarshal(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { resp := &gpb.GetResponse{} - err := util.Read(tt.args.path, resp) + err := proto.Read(tt.args.path, resp) if err != nil { t.Error(err) } @@ -196,34 +195,3 @@ func Test_unmarshal(t *testing.T) { }) } } - -func Test_iter(t *testing.T) { - type args struct { - a ygot.GoStruct - fields []string - } - tests := []struct { - name string - args args - wantB ygot.GoStruct - wantField string - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotB, gotField, err := iter(tt.args.a, tt.args.fields) - if (err != nil) != tt.wantErr { - t.Errorf("iter() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(gotB, tt.wantB) { - t.Errorf("iter() gotB = %v, want %v", gotB, tt.wantB) - } - if gotField != tt.wantField { - t.Errorf("iter() gotField = %v, want %v", gotField, tt.wantField) - } - }) - } -} diff --git a/nucleus/util/message_tools_test.go b/nucleus/util/message_tools_test.go deleted file mode 100644 index dd3707a7143206870549141ca6f19bc5db0e5fe6..0000000000000000000000000000000000000000 --- a/nucleus/util/message_tools_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package util - -import ( - "github.com/golang/protobuf/proto" - "testing" -) - -func TestRead(t *testing.T) { - type args struct { - filename string - message proto.Message - } - tests := []struct { - name string - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := Read(tt.args.filename, tt.args.message); (err != nil) != tt.wantErr { - t.Errorf("Read() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestWrite(t *testing.T) { - type args struct { - message proto.Message - filename string - } - tests := []struct { - name string - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := Write(tt.args.message, tt.args.filename); (err != nil) != tt.wantErr { - t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/nucleus/util/path_traversal.go b/nucleus/util/path/path_traversal.go similarity index 50% rename from nucleus/util/path_traversal.go rename to nucleus/util/path/path_traversal.go index cbcdd9bbc4d4768715e36cb7a5dd5f48a40934e3..c8951b0731e5579e973964f7e29a61bd1680989b 100644 --- a/nucleus/util/path_traversal.go +++ b/nucleus/util/path/path_traversal.go @@ -1,4 +1,4 @@ -package util +package path import ( "fmt" @@ -10,37 +10,48 @@ import ( const DELIM = "/" -type PathElement struct { - Children []*PathElement +// PathElement represents a node in a path containing its name and possible child nodes +type Element struct { + Children []*Element Name string } -func (p *PathElement) Print() { - printPE(0, p) +// Print prints the path element to stdout. It calls printElement recursively +func (p *Element) Print() { + printElement(0, p) } -func printPE(indent int, pe *PathElement) { +func printElement(indent int, pe *Element) { for i := 0; i < indent; i++ { fmt.Print(" ") } fmt.Println(pe.Name) if len(pe.Children) > 0 { for _, p := range pe.Children { - printPE(indent+1, p) + printElement(indent+1, p) } } } -func NewPaths() Paths { - return make(map[string]*PathElement) +// ParseSchema takes a YANG schema and parses it into paths +func ParseSchema(schema *ytypes.Schema, root string) (map[string]*Element, error) { + paths := make(map[string]*Element) + tree := schema.SchemaTree + for k, v := range tree { + if v.Parent != nil { + if v.Parent.Name == root { + path := processEntry(v) + paths[k] = path + } + } + } + return paths, nil } -type Paths map[string]*PathElement - -func processEntry(e *yang.Entry) *PathElement { +func processEntry(e *yang.Entry) *Element { if e.Dir != nil { - elem := &PathElement{ - Children: make([]*PathElement, len(e.Dir)), + elem := &Element{ + Children: make([]*Element, len(e.Dir)), Name: e.Name, } i := 0 @@ -50,47 +61,36 @@ func processEntry(e *yang.Entry) *PathElement { } return elem } - leaf := &PathElement{ + leaf := &Element{ Name: e.Name, } return leaf } -func (p Paths) ParseSchema(schema *ytypes.Schema, root string) error { - tree := schema.SchemaTree - for k, v := range tree { - if v.Parent != nil { - if v.Parent.Name == root { - path := processEntry(v) - p[k] = path - } - } - } - return nil -} - -func (p Paths) StringBuilder() []string { - paths := make([]string, 0) +// Strings constructs a slice containg all possible root to leaf paths. +// Calls stringBuilder internally +func Strings(paths map[string]*Element) []string { + p := make([]string, 0) ch := make(chan string) stop := make(chan bool) val := make(chan []string) go appendix(ch, stop, val) - for _, v := range p { + for _, v := range paths { var b strings.Builder stringBuilder(ch, &b, v) } stop <- true - paths = <-val - return paths + p = <-val + return p } -func appendix(c chan string, stop chan bool, p chan []string) { - paths := make([]string, 0) +func appendix(c chan string, stop chan bool, pathChan chan []string) { + p := make([]string, 0) var sig bool for { select { case path := <-c: - paths = append(paths, path) + p = append(p, path) log.Debug(path) case sig = <-stop: log.Debugf("Signal received: %v", sig) @@ -100,10 +100,10 @@ func appendix(c chan string, stop chan bool, p chan []string) { break } } - p <- paths + pathChan <- p } -func stringBuilder(ch chan string, b *strings.Builder, v *PathElement) { +func stringBuilder(ch chan string, b *strings.Builder, v *Element) { if b.Len() == 0 { b.WriteString(DELIM) } @@ -111,9 +111,9 @@ func stringBuilder(ch chan string, b *strings.Builder, v *PathElement) { if v.Children != nil { b.WriteString(DELIM) for _, c := range v.Children { - var b_cpy strings.Builder - b_cpy.WriteString(b.String()) - stringBuilder(ch, &b_cpy, c) + var bCpy strings.Builder + bCpy.WriteString(b.String()) + stringBuilder(ch, &bCpy, c) } } else { log.Debug("leaf") diff --git a/nucleus/util/path/path_traversal_test.go b/nucleus/util/path/path_traversal_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2193eb4e494a1204d9c5c964efcb8498314eaf2f --- /dev/null +++ b/nucleus/util/path/path_traversal_test.go @@ -0,0 +1,238 @@ +package path + +import ( + model "code.fbi.h-da.de/cocsn/gosdn/test/yang" + "github.com/openconfig/goyang/pkg/yang" + "github.com/openconfig/ygot/ytypes" + log "github.com/sirupsen/logrus" + "os" + "reflect" + "testing" +) + +var schema *ytypes.Schema + +func TestMain(m *testing.M) { + testSetupPath() + os.Exit(m.Run()) +} + +func testSetupPath() { + var err error + schema, err = model.Schema() + if err != nil { + log.Fatal(err) + } +} + +func TestParseSchema(t *testing.T) { + + type args struct { + schema *ytypes.Schema + root string + } + tests := []struct { + name string + args args + want map[string]*Element + wantErr bool + }{ + { + name: "default", + args: args{ + schema: schema, + root: "device", + }, + want: map[string]*Element{ + "Test_Container1": { + Children: []*Element{ + { + Children: []*Element{ + { + Children: nil, + Name: "leaf-list1", + }, + { + Children: nil, + Name: "leaf1", + }, + { + Children: nil, + Name: "leaf2", + }, + }, + Name: "list1", + }, + }, + Name: "container1", + }, + "Test_Container2": { + Children: []*Element{ + { + Children: []*Element{ + { + Children: nil, + Name: "leaf-list1", + }, + { + Children: nil, + Name: "leaf1", + }, + { + Children: nil, + Name: "leaf2", + }, + }, + Name: "list1", + }, + }, + Name: "container2", + }, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ParseSchema(tt.args.schema, tt.args.root) + if (err != nil) != tt.wantErr { + t.Errorf("ParseSchema() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("ParseSchema() got = %v, want %v", got, tt.want) + } + }) + } +} + +func TestStrings(t *testing.T) { + type args struct { + paths map[string]*Element + } + tests := []struct { + name string + args args + want []string + }{ + { + name: "default", + args: args{ + paths: map[string]*Element{ + "Test_Container1": { + Children: []*Element{ + { + Children: []*Element{ + { + Children: nil, + Name: "leaf-list1", + }, + { + Children: nil, + Name: "leaf1", + }, + { + Children: nil, + Name: "leaf2", + }, + }, + Name: "list1", + }, + }, + Name: "container1", + }, + "Test_Container2": { + Children: []*Element{ + { + Children: []*Element{ + { + Children: nil, + Name: "leaf-list1", + }, + { + Children: nil, + Name: "leaf1", + }, + { + Children: nil, + Name: "leaf2", + }, + }, + Name: "list1", + }, + }, + Name: "container2", + }, + }, + }, + want: []string{ + "/container1/list1/leaf-list1", + "/container1/list1/leaf1", + "/container1/list1/leaf2", + "/container2/list1/leaf-list1", + "/container2/list1/leaf1", + "/container2/list1/leaf2", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Strings(tt.args.paths); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Strings() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_processEntry(t *testing.T) { + type args struct { + e *yang.Entry + } + tests := []struct { + name string + args args + want *Element + }{ + { + name: "leaf", + args: args{e: schema.SchemaTree["Test_Container1_List1"].Dir["leaf1"]}, + want: &Element{ + Children: nil, + Name: "leaf1", + }, + }, + { + name: "intermediate", + args: args{schema.SchemaTree["Test_Container1"]}, + want: &Element{ + Children: []*Element{ + { + Children: []*Element{ + { + Children: nil, + Name: "leaf-list1", + }, + { + Children: nil, + Name: "leaf1", + }, + { + Children: nil, + Name: "leaf2", + }, + }, + Name: "list1", + }, + }, + Name: "container1", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := processEntry(tt.args.e); !reflect.DeepEqual(got, tt.want) { + t.Errorf("processEntry() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/nucleus/util/path_traversal_test.go b/nucleus/util/path_traversal_test.go deleted file mode 100644 index c7d868219f5edd141ec2d256a5fc84542fa4471d..0000000000000000000000000000000000000000 --- a/nucleus/util/path_traversal_test.go +++ /dev/null @@ -1 +0,0 @@ -package util diff --git a/nucleus/util/message_tools.go b/nucleus/util/proto/message.go similarity index 94% rename from nucleus/util/message_tools.go rename to nucleus/util/proto/message.go index 30ba145ad3b4ee76bc5da4c48f0250afcd3f30fe..5057f1f0808f57e408d580f613ef8ab519500503 100644 --- a/nucleus/util/message_tools.go +++ b/nucleus/util/proto/message.go @@ -1,8 +1,8 @@ -package util +package proto import ( "fmt" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" "io/ioutil" ) @@ -30,7 +30,6 @@ func Read(filename string, message proto.Message) error { if err != nil { return fmt.Errorf("cannot read binary data from file: %w", err) } - err = proto.Unmarshal(data, message) if err != nil { return fmt.Errorf("cannot unmarshal binary to proto message: %w", err) diff --git a/nucleus/util/proto/message_test.go b/nucleus/util/proto/message_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3f756d3aef8ad5c467a2572d793e374bb2802c30 --- /dev/null +++ b/nucleus/util/proto/message_test.go @@ -0,0 +1,130 @@ +package proto + +import ( + gpb "github.com/openconfig/gnmi/proto/gnmi" + pb "google.golang.org/protobuf/proto" + "os" + "reflect" + "strings" + "testing" +) + +func TestMain(m *testing.M) { + gnmiPaths = map[string]pb.Message{ + "../../../test/proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{}, + "../../../test/proto/req-full-node": &gpb.GetRequest{}, + "../../../test/proto/req-full-node-arista-ceos": &gpb.GetRequest{}, + "../../../test/proto/req-interfaces-arista-ceos": &gpb.GetRequest{}, + "../../../test/proto/req-interfaces-interface-arista-ceos": &gpb.GetRequest{}, + "../../../test/proto/req-interfaces-wildcard": &gpb.GetRequest{}, + "../../../test/proto/resp-full-node": &gpb.GetResponse{}, + "../../../test/proto/resp-full-node-arista-ceos": &gpb.GetResponse{}, + "../../../test/proto/resp-interfaces-arista-ceos": &gpb.GetResponse{}, + "../../../test/proto/resp-interfaces-interface-arista-ceos": &gpb.GetResponse{}, + "../../../test/proto/resp-interfaces-wildcard": &gpb.GetResponse{}, + "../../../test/proto/resp-set-system-config-hostname": &gpb.SetResponse{}, + } + os.Exit(m.Run()) +} + +var gnmiPaths map[string]pb.Message + +func TestRead(t *testing.T) { + type args struct { + filename string + message pb.Message + } + type test struct { + name string + args args + want reflect.Type + wantErr bool + } + var tests []test + for k, v := range gnmiPaths { + name := strings.Split(k, "/")[5] + tests = append(tests, test{ + name: name, + args: args{ + filename: k, + message: v, + }, + want: reflect.TypeOf(v), + wantErr: false, + }) + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := Read(tt.args.filename, tt.args.message); (err != nil) != tt.wantErr { + t.Errorf("Read() error = %v, wantErr %v", err, tt.wantErr) + return + } + got := reflect.TypeOf(tt.args.message) + if got != tt.want { + t.Errorf("Read() got Type %v, want Type %v", got, tt.want) + } + }) + } +} + +func TestWrite(t *testing.T) { + for k, v := range gnmiPaths { + if err := Read(k, v); err != nil { + t.Error(err) + } + } + type args struct { + message pb.Message + filename string + } + type test struct { + name string + args args + want pb.Message + wantErr bool + } + var tests []test + for k, v := range gnmiPaths { + name := strings.Split(k, "/")[5] + tests = append(tests, test{ + name: name, + args: args{ + message: v, + filename: name + "_test", + }, + want: v, + wantErr: false, + }) + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := Write(tt.args.message, tt.args.filename); (err != nil) != tt.wantErr { + t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr) + } + var got pb.Message + switch tt.want.(type) { + case *gpb.GetResponse: + got = &gpb.GetResponse{} + case *gpb.GetRequest: + got = &gpb.GetRequest{} + case *gpb.SetResponse: + got = &gpb.SetResponse{} + case *gpb.SetRequest: + got = &gpb.SetRequest{} + case *gpb.CapabilityResponse: + got = &gpb.CapabilityResponse{} + default: + t.Error("no test case for message type") + return + } + err := Read(tt.args.filename, got) + if err != nil { + t.Error(err) + } + if reflect.DeepEqual(got, tt.want) { + t.Errorf("Write() got %v, want %v", got, tt.want) + } + }) + } +} diff --git a/test/cap-resp-arista-ceos b/test/proto/cap-resp-arista-ceos similarity index 100% rename from test/cap-resp-arista-ceos rename to test/proto/cap-resp-arista-ceos diff --git a/test/req-full-node b/test/proto/req-full-node similarity index 100% rename from test/req-full-node rename to test/proto/req-full-node diff --git a/test/req-full-node-arista-ceos b/test/proto/req-full-node-arista-ceos similarity index 100% rename from test/req-full-node-arista-ceos rename to test/proto/req-full-node-arista-ceos diff --git a/test/req-interfaces-arista-ceos b/test/proto/req-interfaces-arista-ceos similarity index 100% rename from test/req-interfaces-arista-ceos rename to test/proto/req-interfaces-arista-ceos diff --git a/test/req-interfaces-interface-arista-ceos b/test/proto/req-interfaces-interface-arista-ceos similarity index 100% rename from test/req-interfaces-interface-arista-ceos rename to test/proto/req-interfaces-interface-arista-ceos diff --git a/test/req-interfaces-wildcard b/test/proto/req-interfaces-wildcard similarity index 100% rename from test/req-interfaces-wildcard rename to test/proto/req-interfaces-wildcard diff --git a/test/resp-full-node b/test/proto/resp-full-node similarity index 100% rename from test/resp-full-node rename to test/proto/resp-full-node diff --git a/test/resp-full-node-arista-ceos b/test/proto/resp-full-node-arista-ceos similarity index 100% rename from test/resp-full-node-arista-ceos rename to test/proto/resp-full-node-arista-ceos diff --git a/test/resp-interfaces-arista-ceos b/test/proto/resp-interfaces-arista-ceos similarity index 100% rename from test/resp-interfaces-arista-ceos rename to test/proto/resp-interfaces-arista-ceos diff --git a/test/resp-interfaces-interface-arista-ceos b/test/proto/resp-interfaces-interface-arista-ceos similarity index 100% rename from test/resp-interfaces-interface-arista-ceos rename to test/proto/resp-interfaces-interface-arista-ceos diff --git a/test/resp-interfaces-wildcard b/test/proto/resp-interfaces-wildcard similarity index 100% rename from test/resp-interfaces-wildcard rename to test/proto/resp-interfaces-wildcard diff --git a/test/resp-set-system-config-hostname b/test/proto/resp-set-system-config-hostname similarity index 100% rename from test/resp-set-system-config-hostname rename to test/proto/resp-set-system-config-hostname diff --git a/test/yang/test-module.go b/test/yang/test-module.go new file mode 100644 index 0000000000000000000000000000000000000000..6d962be48d2728bc24285a89b8251d1cd380d600 --- /dev/null +++ b/test/yang/test-module.go @@ -0,0 +1,3 @@ +package yang + +//go:generate go run $GOPATH/src/github.com/openconfig/ygot/generator/generator.go -output_file ./yang.go -package_name=yang -generate_fakeroot -fakeroot_name=device test.yang diff --git a/test/yang/test.yang b/test/yang/test.yang new file mode 100644 index 0000000000000000000000000000000000000000..35254174203402213cb12bf196fdc20c061c2e6d --- /dev/null +++ b/test/yang/test.yang @@ -0,0 +1,66 @@ +module test { + yang-version 1.1; + namespace "urn:cocsn:params:xml:ns:yang:test"; + prefix coc; + + organization + "Darmstadt University of Applied Sciences"; + + description + "This YANG module is used to test YANG libs"; + + revision "2021-03-22" { + description + "Initial Revision"; + } + + container container1 { + list list1 { + key "leaf1"; + leaf leaf1 { + config false; + type string; + mandatory "true"; + description + "leaf1"; + } + leaf-list leaf-list1 { + config true; + type string; + description + "leaf-list1"; + } + leaf leaf2 { + config true; + type string; + description + "leaf2"; + } + } + } + + container container2 { + list list1 { + key "leaf1"; + leaf leaf1 { + config false; + type string; + mandatory "true"; + description + "leaf1"; + } + leaf-list leaf-list1 { + config true; + type string; + description + "leaf-list1"; + } + leaf leaf2 { + config true; + type string; + description + "leaf2"; + } + } + } +} \ No newline at end of file diff --git a/test/yang/yang.go b/test/yang/yang.go new file mode 100644 index 0000000000000000000000000000000000000000..7801d549b1d569245936cbdddabf74d7bf215f4c --- /dev/null +++ b/test/yang/yang.go @@ -0,0 +1,332 @@ +/* +Package yang is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was false +in this case). + +This package was generated by /Users/mk/go/pkg/mod/github.com/openconfig/ygot@v0.10.0/genutil/names.go +using the following YANG input files: + - test.yang +Imported modules were sourced from: +*/ +package yang + +import ( + "encoding/json" + "fmt" + "reflect" + + "github.com/openconfig/goyang/pkg/yang" + "github.com/openconfig/ygot/ygot" + "github.com/openconfig/ygot/ytypes" +) + +// Binary is a type that is used for fields that have a YANG type of +// binary. It is used such that binary fields can be distinguished from +// leaf-lists of uint8s (which are mapped to []uint8, equivalent to +// []byte in reflection). +type Binary []byte + +// YANGEmpty is a type that is used for fields that have a YANG type of +// empty. It is used such that empty fields can be distinguished from boolean fields +// in the generated code. +type YANGEmpty bool + +var ( + SchemaTree map[string]*yang.Entry +) + +func init() { + var err error + if SchemaTree, err = UnzipSchema(); err != nil { + panic("schema error: " + err.Error()) + } +} + +// Schema returns the details of the generated schema. +func Schema() (*ytypes.Schema, error) { + uzp, err := UnzipSchema() + if err != nil { + return nil, fmt.Errorf("cannot unzip schema, %v", err) + } + + return &ytypes.Schema{ + Root: &Device{}, + SchemaTree: uzp, + Unmarshal: Unmarshal, + }, nil +} + +// UnzipSchema unzips the zipped schema and returns a map of yang.Entry nodes, +// keyed by the name of the struct that the yang.Entry describes the schema for. +func UnzipSchema() (map[string]*yang.Entry, error) { + var schemaTree map[string]*yang.Entry + var err error + if schemaTree, err = ygot.GzipToSchema(ySchema); err != nil { + return nil, fmt.Errorf("could not unzip the schema; %v", err) + } + return schemaTree, nil +} + +// Unmarshal unmarshals data, which must be RFC7951 JSON format, into +// destStruct, which must be non-nil and the correct GoStruct type. It returns +// an error if the destStruct is not found in the schema or the data cannot be +// unmarshaled. The supplied options (opts) are used to control the behaviour +// of the unmarshal function - for example, determining whether errors are +// thrown for unknown fields in the input JSON. +func Unmarshal(data []byte, destStruct ygot.GoStruct, opts ...ytypes.UnmarshalOpt) error { + tn := reflect.TypeOf(destStruct).Elem().Name() + schema, ok := SchemaTree[tn] + if !ok { + return fmt.Errorf("could not find schema for type %s", tn) + } + var jsonTree interface{} + if err := json.Unmarshal([]byte(data), &jsonTree); err != nil { + return err + } + return ytypes.Unmarshal(schema, destStruct, jsonTree, opts...) +} + +// Device represents the /device YANG schema element. +type Device struct { + Container1 *Test_Container1 `path:"container1" module:"test"` + Container2 *Test_Container2 `path:"container2" module:"test"` +} + +// IsYANGGoStruct ensures that Device implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Device) IsYANGGoStruct() {} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Device) Validate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Device"], t, opts...); err != nil { + return err + } + return nil +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Device) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// Test_Container1 represents the /test/container1 YANG schema element. +type Test_Container1 struct { + List1 map[string]*Test_Container1_List1 `path:"list1" module:"test"` +} + +// IsYANGGoStruct ensures that Test_Container1 implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Test_Container1) IsYANGGoStruct() {} + +// NewList1 creates a new entry in the List1 list of the +// Test_Container1 struct. The keys of the list are populated from the input +// arguments. +func (t *Test_Container1) NewList1(Leaf1 string) (*Test_Container1_List1, error) { + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.List1 == nil { + t.List1 = make(map[string]*Test_Container1_List1) + } + + key := Leaf1 + + // Ensure that this key has not already been used in the + // list. Keyed YANG lists do not allow duplicate keys to + // be created. + if _, ok := t.List1[key]; ok { + return nil, fmt.Errorf("duplicate key %v for list List1", key) + } + + t.List1[key] = &Test_Container1_List1{ + Leaf1: &Leaf1, + } + + return t.List1[key], nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Test_Container1) Validate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Test_Container1"], t, opts...); err != nil { + return err + } + return nil +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Test_Container1) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// Test_Container1_List1 represents the /test/container1/list1 YANG schema element. +type Test_Container1_List1 struct { + LeafList1 []string `path:"leaf-list1" module:"test"` + Leaf1 *string `path:"leaf1" module:"test"` + Leaf2 *string `path:"leaf2" module:"test"` +} + +// IsYANGGoStruct ensures that Test_Container1_List1 implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Test_Container1_List1) IsYANGGoStruct() {} + +// ΛListKeyMap returns the keys of the Test_Container1_List1 struct, which is a YANG list entry. +func (t *Test_Container1_List1) ΛListKeyMap() (map[string]interface{}, error) { + if t.Leaf1 == nil { + return nil, fmt.Errorf("nil value for key Leaf1") + } + + return map[string]interface{}{ + "leaf1": *t.Leaf1, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Test_Container1_List1) Validate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Test_Container1_List1"], t, opts...); err != nil { + return err + } + return nil +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Test_Container1_List1) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// Test_Container2 represents the /test/container2 YANG schema element. +type Test_Container2 struct { + List1 map[string]*Test_Container2_List1 `path:"list1" module:"test"` +} + +// IsYANGGoStruct ensures that Test_Container2 implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Test_Container2) IsYANGGoStruct() {} + +// NewList1 creates a new entry in the List1 list of the +// Test_Container2 struct. The keys of the list are populated from the input +// arguments. +func (t *Test_Container2) NewList1(Leaf1 string) (*Test_Container2_List1, error) { + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.List1 == nil { + t.List1 = make(map[string]*Test_Container2_List1) + } + + key := Leaf1 + + // Ensure that this key has not already been used in the + // list. Keyed YANG lists do not allow duplicate keys to + // be created. + if _, ok := t.List1[key]; ok { + return nil, fmt.Errorf("duplicate key %v for list List1", key) + } + + t.List1[key] = &Test_Container2_List1{ + Leaf1: &Leaf1, + } + + return t.List1[key], nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Test_Container2) Validate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Test_Container2"], t, opts...); err != nil { + return err + } + return nil +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Test_Container2) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// Test_Container2_List1 represents the /test/container2/list1 YANG schema element. +type Test_Container2_List1 struct { + LeafList1 []string `path:"leaf-list1" module:"test"` + Leaf1 *string `path:"leaf1" module:"test"` + Leaf2 *string `path:"leaf2" module:"test"` +} + +// IsYANGGoStruct ensures that Test_Container2_List1 implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Test_Container2_List1) IsYANGGoStruct() {} + +// ΛListKeyMap returns the keys of the Test_Container2_List1 struct, which is a YANG list entry. +func (t *Test_Container2_List1) ΛListKeyMap() (map[string]interface{}, error) { + if t.Leaf1 == nil { + return nil, fmt.Errorf("nil value for key Leaf1") + } + + return map[string]interface{}{ + "leaf1": *t.Leaf1, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Test_Container2_List1) Validate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Test_Container2_List1"], t, opts...); err != nil { + return err + } + return nil +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Test_Container2_List1) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +var ( + // ySchema is a byte slice contain a gzip compressed representation of the + // YANG schema from which the Go code was generated. When uncompressed the + // contents of the byte slice is a JSON document containing an object, keyed + // on the name of the generated struct, and containing the JSON marshalled + // contents of a goyang yang.Entry struct, which defines the schema for the + // fields within the struct. + ySchema = []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xdf, 0x6f, 0xda, 0x30, + 0x10, 0x7e, 0xcf, 0x5f, 0x61, 0xf9, 0x99, 0x09, 0xe2, 0x41, 0xe9, 0xf2, 0xc6, 0xda, 0x4d, 0x93, + 0xda, 0x6e, 0xd3, 0xd6, 0xf7, 0xca, 0x4a, 0x0e, 0x6a, 0x0d, 0x6c, 0x64, 0x3b, 0x5b, 0xa3, 0x89, + 0xff, 0x7d, 0x22, 0xa1, 0xf9, 0x45, 0x12, 0xdb, 0x30, 0x69, 0x4c, 0xf2, 0x23, 0xf6, 0x5d, 0xee, + 0xbb, 0xfb, 0xee, 0x72, 0xf9, 0xc4, 0xef, 0x00, 0x21, 0x84, 0xf0, 0x67, 0xba, 0x01, 0x1c, 0x21, + 0x9c, 0xc0, 0x4f, 0x16, 0x03, 0x1e, 0x15, 0xa7, 0x77, 0x8c, 0x27, 0x38, 0x42, 0xe1, 0xe1, 0xe7, + 0x8d, 0xe0, 0x4b, 0xb6, 0xc2, 0x11, 0x9a, 0x1c, 0x0e, 0x6e, 0x99, 0xc4, 0x11, 0x2a, 0x1e, 0x91, + 0x1f, 0xc4, 0x82, 0x6b, 0xca, 0x38, 0xc8, 0xb0, 0x71, 0xde, 0x08, 0x51, 0xb3, 0x19, 0x35, 0x2d, + 0x9a, 0xe1, 0xca, 0xe3, 0x76, 0xd8, 0xf2, 0xe2, 0xab, 0x84, 0x25, 0x7b, 0x39, 0x8a, 0xd4, 0x8a, + 0x16, 0xb7, 0xc2, 0xe4, 0xd7, 0xdf, 0x45, 0x2a, 0x63, 0xe8, 0x74, 0x2d, 0xa0, 0x40, 0xf6, 0x4b, + 0xc8, 0x3d, 0x1a, 0xbc, 0x2d, 0xa2, 0x8c, 0xba, 0x0d, 0x3f, 0x51, 0xb5, 0x90, 0xab, 0x74, 0x03, + 0x5c, 0xe3, 0x08, 0x69, 0x99, 0x42, 0x8f, 0x61, 0xcd, 0x2a, 0x07, 0x75, 0x64, 0xb5, 0x6b, 0x9c, + 0xec, 0x5a, 0xb9, 0xb6, 0x4b, 0x5d, 0x5e, 0xac, 0x99, 0xd2, 0x61, 0x7f, 0x22, 0xaf, 0x75, 0x28, + 0xcc, 0x7a, 0xb0, 0x75, 0x17, 0xde, 0x48, 0x80, 0x0d, 0x11, 0x96, 0x84, 0xd8, 0x12, 0xe3, 0x4c, + 0x90, 0x33, 0x51, 0xf6, 0x84, 0x75, 0x13, 0xd7, 0x43, 0xa0, 0x91, 0xc8, 0x8a, 0x50, 0xa0, 0xcb, + 0x37, 0xc3, 0xac, 0x1e, 0xb3, 0x5b, 0xf9, 0x18, 0xb2, 0x3a, 0x50, 0x3d, 0x31, 0x98, 0x95, 0x94, + 0x87, 0x06, 0x43, 0x0b, 0xea, 0x1d, 0x5b, 0xc0, 0xb5, 0x15, 0x4e, 0x6e, 0x89, 0x93, 0x5b, 0xc3, + 0xbd, 0x45, 0x86, 0x5b, 0xc5, 0xd0, 0x32, 0x65, 0xb8, 0xc7, 0x6c, 0x0b, 0x6e, 0x95, 0x56, 0x5a, + 0x32, 0xbe, 0xb2, 0x29, 0xf6, 0xeb, 0x2b, 0xe0, 0xfa, 0x2c, 0x84, 0xf7, 0x4c, 0xe9, 0x85, 0xd6, + 0xd2, 0x0e, 0xe5, 0x03, 0xe3, 0x1f, 0xd6, 0xb0, 0x2f, 0xa0, 0x32, 0xb7, 0x64, 0xe1, 0x41, 0x5f, + 0x6a, 0x1e, 0xe1, 0xf5, 0x74, 0x7a, 0x35, 0x9f, 0x4e, 0x27, 0xf3, 0xb7, 0xf3, 0xc9, 0xbb, 0xd9, + 0x2c, 0xbc, 0x0a, 0x67, 0x16, 0x0f, 0xf9, 0x22, 0x13, 0x90, 0x90, 0xbc, 0xcf, 0x70, 0x84, 0x78, + 0xba, 0x5e, 0x07, 0xa7, 0x31, 0x36, 0x50, 0x8b, 0x7c, 0x1e, 0x1d, 0xc7, 0xf7, 0xaf, 0x4f, 0x2e, + 0xf1, 0x93, 0x7b, 0x31, 0x93, 0xfb, 0x40, 0x79, 0x42, 0xb5, 0x90, 0x99, 0xc5, 0x1b, 0xf5, 0x02, + 0xa6, 0xfc, 0xe4, 0x9e, 0x27, 0x6e, 0x3d, 0x4f, 0xfc, 0xb6, 0xf2, 0xdb, 0xea, 0x9f, 0xf4, 0xb1, + 0xd3, 0x27, 0xdb, 0x1d, 0x64, 0xa6, 0xb7, 0xb4, 0xdd, 0xe6, 0xb3, 0xdf, 0x78, 0x67, 0x6d, 0x3a, + 0xbb, 0x0d, 0xd7, 0x97, 0xed, 0x82, 0x73, 0xa1, 0xa9, 0x66, 0x82, 0x0f, 0xe7, 0xa2, 0xe2, 0x67, + 0xd8, 0xd0, 0x2d, 0xd5, 0xcf, 0xfb, 0xe2, 0x8c, 0x35, 0x28, 0x3d, 0xae, 0xb4, 0xdd, 0xd8, 0xf4, + 0x35, 0xba, 0x67, 0x3b, 0x8d, 0x35, 0x3f, 0x70, 0xff, 0x08, 0x4a, 0x3f, 0xdd, 0x94, 0xee, 0x4f, + 0xf7, 0xb9, 0x7b, 0x60, 0x47, 0xde, 0xb0, 0x74, 0x32, 0x24, 0x64, 0x48, 0xa4, 0x4b, 0x3d, 0x0e, + 0x42, 0x6f, 0x82, 0xae, 0xa0, 0xd5, 0x60, 0x55, 0x1a, 0x98, 0x58, 0xe8, 0x64, 0xe2, 0x75, 0xb2, + 0xd7, 0xc9, 0x5e, 0x27, 0x7b, 0x9d, 0xec, 0xbf, 0x3c, 0xbc, 0x4e, 0xf6, 0x3a, 0xd9, 0xeb, 0x64, + 0xaf, 0x93, 0xbd, 0x4e, 0xf6, 0xdb, 0xca, 0x6f, 0x2b, 0xaf, 0x93, 0xff, 0x7b, 0x9d, 0x4c, 0xce, + 0xd3, 0xc9, 0xe4, 0x62, 0x74, 0x32, 0x71, 0xd5, 0xc9, 0xa4, 0x57, 0x27, 0x07, 0x35, 0x70, 0x7d, + 0xa0, 0x30, 0x53, 0x1f, 0xe9, 0x0f, 0xf8, 0x26, 0xc4, 0xf1, 0x70, 0xb7, 0x81, 0xe2, 0xfa, 0x55, + 0x03, 0xd1, 0x6d, 0xf1, 0x6f, 0x77, 0x11, 0x30, 0xd8, 0xfd, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x0c, 0xf4, 0xf2, 0x38, 0x0c, 0x1f, 0x00, 0x00, + } +) + +// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that +// correspond with the leaf. The type is represented as a reflect.Type. The naming +// of the map ensures that there are no clashes with valid YANG identifiers. +var ΛEnumTypes = map[string][]reflect.Type{}