From 7f06a3aa27329fa1dfec7c0f33abcd73a471e11f Mon Sep 17 00:00:00 2001 From: Kalya Subramanian Date: Tue, 21 Jul 2020 13:41:14 -0700 Subject: [PATCH] ListDiskIDs API for disk v1beta1 --- .gitignore | 1 + client/api/disk/v1beta1/api.pb.go | 964 ++++++++++++++++++ client/api/disk/v1beta1/api.proto | 68 ++ client/go.mod | 3 +- client/go.sum | 23 + .../groups/disk/v1beta1/client_generated.go | 68 ++ go.mod | 3 +- go.sum | 29 +- integrationtests/disk_test.go | 54 + integrationtests/smb_test.go | 3 +- integrationtests/volume_test.go | 8 +- internal/os/disk/api.go | 82 +- internal/server/disk/api_group_generated.go | 7 + internal/server/disk/internal/types.go | 13 + .../server/disk/internal/types_generated.go | 1 + .../disk/internal/v1beta1/conversion.go | 42 + .../internal/v1beta1/conversion_generated.go | 244 +++++ .../disk/internal/v1beta1/server_generated.go | 104 ++ internal/server/disk/server.go | 30 + internal/shared/disk/types.go | 6 + 20 files changed, 1739 insertions(+), 14 deletions(-) create mode 100644 client/api/disk/v1beta1/api.pb.go create mode 100644 client/api/disk/v1beta1/api.proto create mode 100644 client/groups/disk/v1beta1/client_generated.go create mode 100644 integrationtests/disk_test.go create mode 100644 internal/server/disk/internal/v1beta1/conversion.go create mode 100644 internal/server/disk/internal/v1beta1/conversion_generated.go create mode 100644 internal/server/disk/internal/v1beta1/server_generated.go diff --git a/.gitignore b/.gitignore index fa6b0cf8..3dafce90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /bin/ settings.json +integrationtests/integrationtests.test.exe diff --git a/client/api/disk/v1beta1/api.pb.go b/client/api/disk/v1beta1/api.pb.go new file mode 100644 index 00000000..6d3a3352 --- /dev/null +++ b/client/api/disk/v1beta1/api.pb.go @@ -0,0 +1,964 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.11.2 +// source: github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1/api.proto + +package v1beta1 + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + 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) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type ListDiskLocationsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListDiskLocationsRequest) Reset() { + *x = ListDiskLocationsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDiskLocationsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDiskLocationsRequest) ProtoMessage() {} + +func (x *ListDiskLocationsRequest) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 ListDiskLocationsRequest.ProtoReflect.Descriptor instead. +func (*ListDiskLocationsRequest) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{0} +} + +type DiskLocation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Adapter string `protobuf:"bytes,1,opt,name=Adapter,proto3" json:"Adapter,omitempty"` + Bus string `protobuf:"bytes,2,opt,name=Bus,proto3" json:"Bus,omitempty"` + Target string `protobuf:"bytes,3,opt,name=Target,proto3" json:"Target,omitempty"` + LUNID string `protobuf:"bytes,4,opt,name=LUNID,proto3" json:"LUNID,omitempty"` +} + +func (x *DiskLocation) Reset() { + *x = DiskLocation{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DiskLocation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DiskLocation) ProtoMessage() {} + +func (x *DiskLocation) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 DiskLocation.ProtoReflect.Descriptor instead. +func (*DiskLocation) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{1} +} + +func (x *DiskLocation) GetAdapter() string { + if x != nil { + return x.Adapter + } + return "" +} + +func (x *DiskLocation) GetBus() string { + if x != nil { + return x.Bus + } + return "" +} + +func (x *DiskLocation) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +func (x *DiskLocation) GetLUNID() string { + if x != nil { + return x.LUNID + } + return "" +} + +type ListDiskLocationsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map of disk device IDs and associated with each disk device + DiskLocations map[string]*DiskLocation `protobuf:"bytes,1,rep,name=disk_locations,json=diskLocations,proto3" json:"disk_locations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ListDiskLocationsResponse) Reset() { + *x = ListDiskLocationsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDiskLocationsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDiskLocationsResponse) ProtoMessage() {} + +func (x *ListDiskLocationsResponse) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 ListDiskLocationsResponse.ProtoReflect.Descriptor instead. +func (*ListDiskLocationsResponse) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{2} +} + +func (x *ListDiskLocationsResponse) GetDiskLocations() map[string]*DiskLocation { + if x != nil { + return x.DiskLocations + } + return nil +} + +type PartitionDiskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Disk device ID of the disk to partition + DiskID string `protobuf:"bytes,1,opt,name=diskID,proto3" json:"diskID,omitempty"` +} + +func (x *PartitionDiskRequest) Reset() { + *x = PartitionDiskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PartitionDiskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartitionDiskRequest) ProtoMessage() {} + +func (x *PartitionDiskRequest) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 PartitionDiskRequest.ProtoReflect.Descriptor instead. +func (*PartitionDiskRequest) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{3} +} + +func (x *PartitionDiskRequest) GetDiskID() string { + if x != nil { + return x.DiskID + } + return "" +} + +type PartitionDiskResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PartitionDiskResponse) Reset() { + *x = PartitionDiskResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PartitionDiskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartitionDiskResponse) ProtoMessage() {} + +func (x *PartitionDiskResponse) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 PartitionDiskResponse.ProtoReflect.Descriptor instead. +func (*PartitionDiskResponse) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{4} +} + +type RescanRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RescanRequest) Reset() { + *x = RescanRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RescanRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RescanRequest) ProtoMessage() {} + +func (x *RescanRequest) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 RescanRequest.ProtoReflect.Descriptor instead. +func (*RescanRequest) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{5} +} + +type RescanResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RescanResponse) Reset() { + *x = RescanResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RescanResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RescanResponse) ProtoMessage() {} + +func (x *RescanResponse) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 RescanResponse.ProtoReflect.Descriptor instead. +func (*RescanResponse) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{6} +} + +type ListDiskIDsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListDiskIDsRequest) Reset() { + *x = ListDiskIDsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDiskIDsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDiskIDsRequest) ProtoMessage() {} + +func (x *ListDiskIDsRequest) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 ListDiskIDsRequest.ProtoReflect.Descriptor instead. +func (*ListDiskIDsRequest) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{7} +} + +type DiskIDs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map of Disk ID types and Disk ID values + Identifiers map[string]string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *DiskIDs) Reset() { + *x = DiskIDs{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DiskIDs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DiskIDs) ProtoMessage() {} + +func (x *DiskIDs) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 DiskIDs.ProtoReflect.Descriptor instead. +func (*DiskIDs) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{8} +} + +func (x *DiskIDs) GetIdentifiers() map[string]string { + if x != nil { + return x.Identifiers + } + return nil +} + +type ListDiskIDsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Map of disk device numbers and IDs associated with each disk device + DiskIDs map[string]*DiskIDs `protobuf:"bytes,1,rep,name=diskIDs,proto3" json:"diskIDs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ListDiskIDsResponse) Reset() { + *x = ListDiskIDsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDiskIDsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDiskIDsResponse) ProtoMessage() {} + +func (x *ListDiskIDsResponse) ProtoReflect() protoreflect.Message { + mi := &file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 ListDiskIDsResponse.ProtoReflect.Descriptor instead. +func (*ListDiskIDsResponse) Descriptor() ([]byte, []int) { + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP(), []int{9} +} + +func (x *ListDiskIDsResponse) GetDiskIDs() map[string]*DiskIDs { + if x != nil { + return x.DiskIDs + } + return nil +} + +var File_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto protoreflect.FileDescriptor + +var file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDesc = []byte{ + 0x0a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, 0x63, 0x73, 0x69, 0x2d, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x64, 0x69, 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x70, + 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x22, 0x1a, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x68, 0x0a, 0x0c, + 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, + 0x41, 0x64, 0x61, 0x70, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x41, + 0x64, 0x61, 0x70, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x42, 0x75, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x42, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x55, 0x4e, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x4c, 0x55, 0x4e, 0x49, 0x44, 0x22, 0xd2, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x44, + 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x0e, 0x64, 0x69, 0x73, 0x6b, 0x5f, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x4c, + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x1a, 0x57, 0x0a, 0x12, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2b, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x2e, 0x0a, 0x14, 0x50, + 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x22, 0x17, 0x0a, 0x15, 0x50, + 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x63, 0x61, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x63, 0x61, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x44, + 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x8e, 0x01, + 0x0a, 0x07, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x12, 0x43, 0x0a, 0x0b, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, + 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x0b, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x1a, 0x3e, + 0x0a, 0x10, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa8, + 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x07, 0x64, 0x69, 0x73, 0x6b, 0x49, 0x44, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x07, 0x64, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x1a, 0x4c, 0x0a, 0x0c, 0x44, + 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xbf, 0x02, 0x0a, 0x04, 0x44, 0x69, + 0x73, 0x6b, 0x12, 0x5c, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x4c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x50, 0x0a, 0x0d, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x69, 0x73, + 0x6b, 0x12, 0x1d, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x74, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x63, 0x61, 0x6e, 0x12, 0x16, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, + 0x65, 0x73, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4a, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, 0x73, 0x12, 0x1b, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, + 0x6b, 0x49, 0x44, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x49, 0x44, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3d, 0x5a, 0x3b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, 0x63, 0x73, 0x69, 0x2d, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x69, + 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescOnce sync.Once + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescData = file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDesc +) + +func file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescGZIP() []byte { + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescOnce.Do(func() { + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescData) + }) + return file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDescData +} + +var file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_goTypes = []interface{}{ + (*ListDiskLocationsRequest)(nil), // 0: v1beta1.ListDiskLocationsRequest + (*DiskLocation)(nil), // 1: v1beta1.DiskLocation + (*ListDiskLocationsResponse)(nil), // 2: v1beta1.ListDiskLocationsResponse + (*PartitionDiskRequest)(nil), // 3: v1beta1.PartitionDiskRequest + (*PartitionDiskResponse)(nil), // 4: v1beta1.PartitionDiskResponse + (*RescanRequest)(nil), // 5: v1beta1.RescanRequest + (*RescanResponse)(nil), // 6: v1beta1.RescanResponse + (*ListDiskIDsRequest)(nil), // 7: v1beta1.ListDiskIDsRequest + (*DiskIDs)(nil), // 8: v1beta1.DiskIDs + (*ListDiskIDsResponse)(nil), // 9: v1beta1.ListDiskIDsResponse + nil, // 10: v1beta1.ListDiskLocationsResponse.DiskLocationsEntry + nil, // 11: v1beta1.DiskIDs.IdentifiersEntry + nil, // 12: v1beta1.ListDiskIDsResponse.DiskIDsEntry +} +var file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_depIdxs = []int32{ + 10, // 0: v1beta1.ListDiskLocationsResponse.disk_locations:type_name -> v1beta1.ListDiskLocationsResponse.DiskLocationsEntry + 11, // 1: v1beta1.DiskIDs.identifiers:type_name -> v1beta1.DiskIDs.IdentifiersEntry + 12, // 2: v1beta1.ListDiskIDsResponse.diskIDs:type_name -> v1beta1.ListDiskIDsResponse.DiskIDsEntry + 1, // 3: v1beta1.ListDiskLocationsResponse.DiskLocationsEntry.value:type_name -> v1beta1.DiskLocation + 8, // 4: v1beta1.ListDiskIDsResponse.DiskIDsEntry.value:type_name -> v1beta1.DiskIDs + 0, // 5: v1beta1.Disk.ListDiskLocations:input_type -> v1beta1.ListDiskLocationsRequest + 3, // 6: v1beta1.Disk.PartitionDisk:input_type -> v1beta1.PartitionDiskRequest + 5, // 7: v1beta1.Disk.Rescan:input_type -> v1beta1.RescanRequest + 7, // 8: v1beta1.Disk.ListDiskIDs:input_type -> v1beta1.ListDiskIDsRequest + 2, // 9: v1beta1.Disk.ListDiskLocations:output_type -> v1beta1.ListDiskLocationsResponse + 4, // 10: v1beta1.Disk.PartitionDisk:output_type -> v1beta1.PartitionDiskResponse + 6, // 11: v1beta1.Disk.Rescan:output_type -> v1beta1.RescanResponse + 9, // 12: v1beta1.Disk.ListDiskIDs:output_type -> v1beta1.ListDiskIDsResponse + 9, // [9:13] is the sub-list for method output_type + 5, // [5:9] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_init() } +func file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_init() { + if File_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDiskLocationsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DiskLocation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDiskLocationsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PartitionDiskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PartitionDiskResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RescanRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RescanResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDiskIDsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DiskIDs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDiskIDsResponse); 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_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 13, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_goTypes, + DependencyIndexes: file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_depIdxs, + MessageInfos: file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_msgTypes, + }.Build() + File_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto = out.File + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_rawDesc = nil + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_proto_goTypes = nil + file_github_com_kubernetes_csi_csi_proxy_client_api_disk_v1beta1_api_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 + +// DiskClient is the client API for Disk service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DiskClient interface { + // ListDiskLocations returns locations of all + // disk devices enumerated by the host + ListDiskLocations(ctx context.Context, in *ListDiskLocationsRequest, opts ...grpc.CallOption) (*ListDiskLocationsResponse, error) + // PartitionDisk initializes and partitions a disk device (if the disk has not + // been partitioned already) and returns the resulting volume device ID + PartitionDisk(ctx context.Context, in *PartitionDiskRequest, opts ...grpc.CallOption) (*PartitionDiskResponse, error) + // Rescan refreshes the host's storage cache + Rescan(ctx context.Context, in *RescanRequest, opts ...grpc.CallOption) (*RescanResponse, error) + // ListDiskIDs returns a map of DiskID objects where the key is the disk number + ListDiskIDs(ctx context.Context, in *ListDiskIDsRequest, opts ...grpc.CallOption) (*ListDiskIDsResponse, error) +} + +type diskClient struct { + cc grpc.ClientConnInterface +} + +func NewDiskClient(cc grpc.ClientConnInterface) DiskClient { + return &diskClient{cc} +} + +func (c *diskClient) ListDiskLocations(ctx context.Context, in *ListDiskLocationsRequest, opts ...grpc.CallOption) (*ListDiskLocationsResponse, error) { + out := new(ListDiskLocationsResponse) + err := c.cc.Invoke(ctx, "/v1beta1.Disk/ListDiskLocations", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *diskClient) PartitionDisk(ctx context.Context, in *PartitionDiskRequest, opts ...grpc.CallOption) (*PartitionDiskResponse, error) { + out := new(PartitionDiskResponse) + err := c.cc.Invoke(ctx, "/v1beta1.Disk/PartitionDisk", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *diskClient) Rescan(ctx context.Context, in *RescanRequest, opts ...grpc.CallOption) (*RescanResponse, error) { + out := new(RescanResponse) + err := c.cc.Invoke(ctx, "/v1beta1.Disk/Rescan", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *diskClient) ListDiskIDs(ctx context.Context, in *ListDiskIDsRequest, opts ...grpc.CallOption) (*ListDiskIDsResponse, error) { + out := new(ListDiskIDsResponse) + err := c.cc.Invoke(ctx, "/v1beta1.Disk/ListDiskIDs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DiskServer is the server API for Disk service. +type DiskServer interface { + // ListDiskLocations returns locations of all + // disk devices enumerated by the host + ListDiskLocations(context.Context, *ListDiskLocationsRequest) (*ListDiskLocationsResponse, error) + // PartitionDisk initializes and partitions a disk device (if the disk has not + // been partitioned already) and returns the resulting volume device ID + PartitionDisk(context.Context, *PartitionDiskRequest) (*PartitionDiskResponse, error) + // Rescan refreshes the host's storage cache + Rescan(context.Context, *RescanRequest) (*RescanResponse, error) + // ListDiskIDs returns a map of DiskID objects where the key is the disk number + ListDiskIDs(context.Context, *ListDiskIDsRequest) (*ListDiskIDsResponse, error) +} + +// UnimplementedDiskServer can be embedded to have forward compatible implementations. +type UnimplementedDiskServer struct { +} + +func (*UnimplementedDiskServer) ListDiskLocations(context.Context, *ListDiskLocationsRequest) (*ListDiskLocationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDiskLocations not implemented") +} +func (*UnimplementedDiskServer) PartitionDisk(context.Context, *PartitionDiskRequest) (*PartitionDiskResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PartitionDisk not implemented") +} +func (*UnimplementedDiskServer) Rescan(context.Context, *RescanRequest) (*RescanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rescan not implemented") +} +func (*UnimplementedDiskServer) ListDiskIDs(context.Context, *ListDiskIDsRequest) (*ListDiskIDsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDiskIDs not implemented") +} + +func RegisterDiskServer(s *grpc.Server, srv DiskServer) { + s.RegisterService(&_Disk_serviceDesc, srv) +} + +func _Disk_ListDiskLocations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDiskLocationsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiskServer).ListDiskLocations(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1beta1.Disk/ListDiskLocations", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiskServer).ListDiskLocations(ctx, req.(*ListDiskLocationsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Disk_PartitionDisk_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PartitionDiskRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiskServer).PartitionDisk(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1beta1.Disk/PartitionDisk", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiskServer).PartitionDisk(ctx, req.(*PartitionDiskRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Disk_Rescan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RescanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiskServer).Rescan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1beta1.Disk/Rescan", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiskServer).Rescan(ctx, req.(*RescanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Disk_ListDiskIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDiskIDsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiskServer).ListDiskIDs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1beta1.Disk/ListDiskIDs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiskServer).ListDiskIDs(ctx, req.(*ListDiskIDsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Disk_serviceDesc = grpc.ServiceDesc{ + ServiceName: "v1beta1.Disk", + HandlerType: (*DiskServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListDiskLocations", + Handler: _Disk_ListDiskLocations_Handler, + }, + { + MethodName: "PartitionDisk", + Handler: _Disk_PartitionDisk_Handler, + }, + { + MethodName: "Rescan", + Handler: _Disk_Rescan_Handler, + }, + { + MethodName: "ListDiskIDs", + Handler: _Disk_ListDiskIDs_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1/api.proto", +} diff --git a/client/api/disk/v1beta1/api.proto b/client/api/disk/v1beta1/api.proto new file mode 100644 index 00000000..1282ed6e --- /dev/null +++ b/client/api/disk/v1beta1/api.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; + +package v1beta1; + +option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1"; + +service Disk { + // ListDiskLocations returns locations of all + // disk devices enumerated by the host + rpc ListDiskLocations(ListDiskLocationsRequest) returns (ListDiskLocationsResponse) {} + + // PartitionDisk initializes and partitions a disk device (if the disk has not + // been partitioned already) and returns the resulting volume device ID + rpc PartitionDisk(PartitionDiskRequest) returns (PartitionDiskResponse) {} + + // Rescan refreshes the host's storage cache + rpc Rescan(RescanRequest) returns (RescanResponse) {} + + // ListDiskIDs returns a map of DiskID objects where the key is the disk number + rpc ListDiskIDs(ListDiskIDsRequest) returns (ListDiskIDsResponse) {} +} + +message ListDiskLocationsRequest { + // Intentionally empty +} + +message DiskLocation { + string Adapter = 1; + string Bus = 2; + string Target = 3; + string LUNID = 4; +} + +message ListDiskLocationsResponse { + // Map of disk device IDs and associated with each disk device + map disk_locations = 1; +} + +message PartitionDiskRequest { + // Disk device ID of the disk to partition + string diskID = 1; +} + +message PartitionDiskResponse { + // Intentionally empty +} + +message RescanRequest { + // Intentionally empty +} + +message RescanResponse { + // Intentionally empty +} + +message ListDiskIDsRequest { + // Intentionally empty +} + +message DiskIDs { + // Map of Disk ID types and Disk ID values + map identifiers = 1; +} + +message ListDiskIDsResponse { + // Map of disk device numbers and IDs associated with each disk device + map diskIDs = 1; +} diff --git a/client/go.mod b/client/go.mod index dc911651..85501884 100644 --- a/client/go.mod +++ b/client/go.mod @@ -4,8 +4,9 @@ go 1.12 require ( github.com/Microsoft/go-winio v0.4.14 - github.com/golang/protobuf v1.3.2 + github.com/golang/protobuf v1.4.1 github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.2.2 google.golang.org/grpc v1.27.0 + google.golang.org/protobuf v1.25.0 ) diff --git a/client/go.sum b/client/go.sum index f3f77038..7b2beee3 100644 --- a/client/go.sum +++ b/client/go.sum @@ -14,8 +14,19 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -51,15 +62,27 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/client/groups/disk/v1beta1/client_generated.go b/client/groups/disk/v1beta1/client_generated.go new file mode 100644 index 00000000..f6d3a678 --- /dev/null +++ b/client/groups/disk/v1beta1/client_generated.go @@ -0,0 +1,68 @@ +// Code generated by csi-proxy-api-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "net" + + "github.com/Microsoft/go-winio" + "github.com/kubernetes-csi/csi-proxy/client" + "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1" + "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "google.golang.org/grpc" +) + +const groupName = "disk" + +var version = apiversion.NewVersionOrPanic("v1beta1") + +type Client struct { + client v1beta1.DiskClient + connection *grpc.ClientConn +} + +// NewClient returns a client to make calls to the disk API group version v1beta1. +// It's the caller's responsibility to Close the client when done. +func NewClient() (*Client, error) { + pipePath := client.PipePath(groupName, version) + + connection, err := grpc.Dial(pipePath, + grpc.WithContextDialer(func(context context.Context, s string) (net.Conn, error) { + return winio.DialPipeContext(context, s) + }), + grpc.WithInsecure()) + if err != nil { + return nil, err + } + + client := v1beta1.NewDiskClient(connection) + return &Client{ + client: client, + connection: connection, + }, nil +} + +// Close closes the client. It must be called before the client gets GC-ed. +func (w *Client) Close() error { + return w.connection.Close() +} + +// ensures we implement all the required methods +var _ v1beta1.DiskClient = &Client{} + +func (w *Client) ListDiskIDs(context context.Context, request *v1beta1.ListDiskIDsRequest, opts ...grpc.CallOption) (*v1beta1.ListDiskIDsResponse, error) { + return w.client.ListDiskIDs(context, request, opts...) +} + +func (w *Client) ListDiskLocations(context context.Context, request *v1beta1.ListDiskLocationsRequest, opts ...grpc.CallOption) (*v1beta1.ListDiskLocationsResponse, error) { + return w.client.ListDiskLocations(context, request, opts...) +} + +func (w *Client) PartitionDisk(context context.Context, request *v1beta1.PartitionDiskRequest, opts ...grpc.CallOption) (*v1beta1.PartitionDiskResponse, error) { + return w.client.PartitionDisk(context, request, opts...) +} + +func (w *Client) Rescan(context context.Context, request *v1beta1.RescanRequest, opts ...grpc.CallOption) (*v1beta1.RescanResponse, error) { + return w.client.Rescan(context, request, opts...) +} diff --git a/go.mod b/go.mod index b3a6cf55..b8f86d39 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ replace ( require ( github.com/Microsoft/go-winio v0.4.14 - github.com/golang/protobuf v1.3.3 + github.com/golang/protobuf v1.4.1 github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 github.com/kubernetes-csi/csi-proxy/client v0.0.0-00010101000000-000000000000 github.com/pkg/errors v0.8.1 @@ -24,7 +24,6 @@ require ( golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect golang.org/x/text v0.3.2 // indirect - google.golang.org/genproto v0.0.0-20200205142000-a86caf926a67 // indirect google.golang.org/grpc v1.27.1 k8s.io/gengo v0.0.0-00010101000000-000000000000 k8s.io/klog v1.0.0 diff --git a/go.sum b/go.sum index 8523fd4a..9280605f 100644 --- a/go.sum +++ b/go.sum @@ -15,10 +15,20 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww= github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -70,17 +80,28 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200205142000-a86caf926a67 h1:MBO9fkVSrTpJ8vgHLPi5gb+ZWXEy7/auJN8yqyu9EiE= -google.golang.org/genproto v0.0.0-20200205142000-a86caf926a67/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/integrationtests/disk_test.go b/integrationtests/disk_test.go new file mode 100644 index 00000000..28c8feeb --- /dev/null +++ b/integrationtests/disk_test.go @@ -0,0 +1,54 @@ +package integrationtests + +import ( + "context" + "strconv" + "strings" + "testing" + + "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1" + v1beta1client "github.com/kubernetes-csi/csi-proxy/client/groups/disk/v1beta1" + "github.com/stretchr/testify/require" +) + +// This test is meant to run on GCE where the page83 ID of the first disk contains +// the host name +func TestDiskAPIGroupV1Beta1(t *testing.T) { + t.Run("ListDiskIDs", func(t *testing.T) { + client, err := v1beta1client.NewClient() + require.Nil(t, err) + defer client.Close() + + diskNumber := 0 + id := "page83" + listRequest := &v1beta1.ListDiskIDsRequest{} + diskIDsResponse, err := client.ListDiskIDs(context.TODO(), listRequest) + require.Nil(t, err) + + cmd := "hostname" + hostname, err := runPowershellCmd(cmd) + if err != nil { + t.Errorf("Error: %v. Command: %s. Out: %s", err, cmd, hostname) + } + + hostname = strings.TrimSpace(hostname) + + diskIDsMap := diskIDsResponse.GetDiskIDs() + if diskIDsMap != nil { + diskIDs, found := diskIDsMap[strconv.Itoa(diskNumber)] + if !found { + t.Errorf("Cannot find Disk %d", diskNumber) + } + + idValue, found := diskIDs.Identifiers[id] + if !found { + t.Errorf("Cannot find %s ID of Disk %d", id, diskNumber) + } + + // In GCE, the page83 ID of Disk 0 contains the hostname + if !strings.Contains(idValue, hostname) { + t.Errorf("%s ID of Disk %d is incorrect. Expected to contain: %s. Received: %s", id, diskNumber, hostname, idValue) + } + } + }) +} diff --git a/integrationtests/smb_test.go b/integrationtests/smb_test.go index 330c2087..f810221a 100644 --- a/integrationtests/smb_test.go +++ b/integrationtests/smb_test.go @@ -48,7 +48,7 @@ func setupUser(username, password string) error { return nil } -func removeUser(t *testing.T, username string) error { +func removeUser(t *testing.T, username string) { cmdLine := fmt.Sprintf(`Remove-Localuser -name $Env:username`) cmd := exec.Command("powershell", "/c", cmdLine) cmd.Env = append(os.Environ(), @@ -56,7 +56,6 @@ func removeUser(t *testing.T, username string) error { if output, err := cmd.CombinedOutput(); err != nil { t.Fatalf("setupUser failed: %v, output: %q", err, string(output)) } - return } func setupSmbShare(shareName, localPath, username string) error { diff --git a/integrationtests/volume_test.go b/integrationtests/volume_test.go index 50f46a53..e0102004 100644 --- a/integrationtests/volume_test.go +++ b/integrationtests/volume_test.go @@ -40,9 +40,11 @@ func diskCleanup(t *testing.T, vhdxPath, mountPath, testPluginPath string) { if out, err = runPowershellCmd(cmd); err != nil { t.Errorf("Error: %v. Command: %s. Out: %s", err, cmd, out) } - cmd = fmt.Sprintf("rmdir %s", testPluginPath) - if out, err = runPowershellCmd(cmd); err != nil { - t.Errorf("Error: %v. Command: %s. Out: %s", err, cmd, out) + if testPluginPath != "" { + cmd = fmt.Sprintf("rmdir %s", testPluginPath) + if out, err = runPowershellCmd(cmd); err != nil { + t.Errorf("Error: %v. Command: %s. Out: %s", err, cmd, out) + } } } diff --git a/internal/os/disk/api.go b/internal/os/disk/api.go index 3bba8348..2d681df9 100644 --- a/internal/os/disk/api.go +++ b/internal/os/disk/api.go @@ -142,7 +142,7 @@ func (imp APIImplementor) GetDiskNumberByName(diskName string) (string, error) { return strconv.FormatUint(uint64(diskNumber), 10), err } -func (APIImplementor) DiskNumber(disk syscall.Handle) (uint32, error) { +func (APIImplementor) GetDiskNumber(disk syscall.Handle) (uint32, error) { var bytes uint32 devNum := StorageDeviceNumber{} buflen := uint32(unsafe.Sizeof(devNum.DeviceType)) + uint32(unsafe.Sizeof(devNum.DeviceNumber)) + uint32(unsafe.Sizeof(devNum.PartitionNumber)) @@ -193,6 +193,44 @@ func (APIImplementor) DiskHasPage83ID(disk syscall.Handle, matchID string) (bool return false, nil } +func (APIImplementor) GetDiskPage83ID(disk syscall.Handle) (string, error) { + query := StoragePropertyQuery{} + + bufferSize := uint32(4 * 1024) + buffer := make([]byte, 4*1024) + var size uint32 + var n uint32 + var m uint16 + + query.QueryType = PropertyStandardQuery + query.PropertyID = StorageDeviceIDProperty + + querySize := uint32(unsafe.Sizeof(query.PropertyID)) + uint32(unsafe.Sizeof(query.QueryType)) + uint32(unsafe.Sizeof(query.Byte)) + querySize = uint32(unsafe.Sizeof(query)) + err := syscall.DeviceIoControl(disk, IOCTL_STORAGE_QUERY_PROPERTY, (*byte)(unsafe.Pointer(&query)), querySize, (*byte)(unsafe.Pointer(&buffer[0])), bufferSize, &size, nil) + if err != nil { + return "", fmt.Errorf("IOCTL_STORAGE_QUERY_PROPERTY failed: %v", err) + } + + devIDDesc := (*StorageDeviceIDDescriptor)(unsafe.Pointer(&buffer[0])) + + pID := (*StorageIdentifier)(unsafe.Pointer(&devIDDesc.Identifiers[0])) + + page83ID := []byte{} + byteSize := unsafe.Sizeof(byte(0)) + for n = 0; n < devIDDesc.NumberOfIdentifiers; n++ { + if pID.CodeSet == StorageIDCodeSetASCII && pID.Association == StorageIDAssocDevice { + for m = 0; m < pID.IdentifierSize; m++ { + page83ID = append(page83ID, *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pID.Identifier[0])) + byteSize*uintptr(m)))) + } + + return string(page83ID), nil + } + pID = (*StorageIdentifier)(unsafe.Pointer(uintptr(unsafe.Pointer(pID)) + byteSize*uintptr(pID.NextOffset))) + } + return "", nil +} + func (imp APIImplementor) GetDiskNumberWithID(page83ID string) (uint32, error) { out, err := exec.Command("powershell.exe", "(get-disk | select Path) | ConvertTo-Json").CombinedOutput() if err != nil { @@ -211,9 +249,49 @@ func (imp APIImplementor) GetDiskNumberWithID(page83ID string) (uint32, error) { found, err := imp.DiskHasPage83ID(h, page83ID) if found { - return imp.DiskNumber(h) + return imp.GetDiskNumber(h) } } return 0, fmt.Errorf("Could not find disk with Page83 ID %s", page83ID) } + +// ListDiskIDs - constructs a map with the disk number as the key and the DiskID structure +// as the value. The DiskID struct has a field for the page83 ID. +func (imp APIImplementor) ListDiskIDs() (map[string]shared.DiskIDs, error) { + out, err := exec.Command("powershell.exe", "(get-disk | select Path) | ConvertTo-Json").CombinedOutput() + if err != nil { + return nil, fmt.Errorf("Could not query disk paths") + } + + outString := string(out) + diskPaths := []DiskPath{} + json.Unmarshal([]byte(outString), &diskPaths) + + m := make(map[string]shared.DiskIDs) + + for i := range diskPaths { + h, err := syscall.Open(diskPaths[i].Path, syscall.O_RDONLY, 0) + if err != nil { + return nil, err + } + + page83, err := imp.GetDiskPage83ID(h) + if err != nil { + return m, fmt.Errorf("Could not get page83 ID: %v", err) + } + + diskNumber, err := imp.GetDiskNumber(h) + if err != nil { + return m, fmt.Errorf("Could not get disk number: %v", err) + } + + diskNumString := strconv.FormatUint(uint64(diskNumber), 10) + + diskIDs := make(map[string]string) + diskIDs["page83"] = page83 + m[diskNumString] = shared.DiskIDs{Identifiers: diskIDs} + } + + return m, nil +} diff --git a/internal/server/disk/api_group_generated.go b/internal/server/disk/api_group_generated.go index 658394cb..05dc219f 100644 --- a/internal/server/disk/api_group_generated.go +++ b/internal/server/disk/api_group_generated.go @@ -6,6 +6,7 @@ import ( "github.com/kubernetes-csi/csi-proxy/client/apiversion" "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal" "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal/v1alpha1" + "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal/v1beta1" srvtypes "github.com/kubernetes-csi/csi-proxy/internal/server/types" ) @@ -16,6 +17,7 @@ var _ internal.ServerInterface = &Server{} func (s *Server) VersionedAPIs() []*srvtypes.VersionedAPI { v1alpha1Server := v1alpha1.NewVersionedServer(s) + v1beta1Server := v1beta1.NewVersionedServer(s) return []*srvtypes.VersionedAPI{ { @@ -23,5 +25,10 @@ func (s *Server) VersionedAPIs() []*srvtypes.VersionedAPI { Version: apiversion.NewVersionOrPanic("v1alpha1"), Registrant: v1alpha1Server.Register, }, + { + Group: name, + Version: apiversion.NewVersionOrPanic("v1beta1"), + Registrant: v1beta1Server.Register, + }, } } diff --git a/internal/server/disk/internal/types.go b/internal/server/disk/internal/types.go index d144686d..584c63ce 100644 --- a/internal/server/disk/internal/types.go +++ b/internal/server/disk/internal/types.go @@ -37,3 +37,16 @@ type GetDiskNumberByNameRequest struct { type GetDiskNumberByNameResponse struct { DiskNumber string } + +type DiskIDs struct { + // Map of Disk ID types and Disk ID values + Identifiers map[string]string +} + +type ListDiskIDsRequest struct { +} + +type ListDiskIDsResponse struct { + // Map of disk device numbers and IDs associated with each disk device + DiskIDs map[string]*DiskIDs +} diff --git a/internal/server/disk/internal/types_generated.go b/internal/server/disk/internal/types_generated.go index 5ba8df6a..1304119c 100644 --- a/internal/server/disk/internal/types_generated.go +++ b/internal/server/disk/internal/types_generated.go @@ -16,6 +16,7 @@ type VersionedAPI interface { // All the functions this group's server needs to define. type ServerInterface interface { GetDiskNumberByName(context.Context, *GetDiskNumberByNameRequest, apiversion.Version) (*GetDiskNumberByNameResponse, error) + ListDiskIDs(context.Context, *ListDiskIDsRequest, apiversion.Version) (*ListDiskIDsResponse, error) ListDiskLocations(context.Context, *ListDiskLocationsRequest, apiversion.Version) (*ListDiskLocationsResponse, error) PartitionDisk(context.Context, *PartitionDiskRequest, apiversion.Version) (*PartitionDiskResponse, error) Rescan(context.Context, *RescanRequest, apiversion.Version) (*RescanResponse, error) diff --git a/internal/server/disk/internal/v1beta1/conversion.go b/internal/server/disk/internal/v1beta1/conversion.go new file mode 100644 index 00000000..dce326d7 --- /dev/null +++ b/internal/server/disk/internal/v1beta1/conversion.go @@ -0,0 +1,42 @@ +package v1beta1 + +// Add manual conversion functions here to override automatic conversion functions + +import ( + v1beta1 "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1" + internal "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal" +) + +func Convert_internal_ListDiskLocationsResponse_To_v1beta1_ListDiskLocationsResponse(in *internal.ListDiskLocationsResponse, out *v1beta1.ListDiskLocationsResponse) error { + if in.DiskLocations != nil { + in, out := &in.DiskLocations, &out.DiskLocations + *out = make(map[string]*v1beta1.DiskLocation, len(*in)) + for key, val := range *in { + newVal := new(v1beta1.DiskLocation) + if err := Convert_internal_DiskLocation_To_v1beta1_DiskLocation(val, newVal); err != nil { + return err + } + (*out)[key] = newVal + } + } else { + out.DiskLocations = nil + } + return nil +} + +func Convert_internal_ListDiskIDsResponse_To_v1beta1_ListDiskIDsResponse(in *internal.ListDiskIDsResponse, out *v1beta1.ListDiskIDsResponse) error { + if in.DiskIDs != nil { + in, out := &in.DiskIDs, &out.DiskIDs + *out = make(map[string]*v1beta1.DiskIDs, len(*in)) + for key, val := range *in { + newVal := new(v1beta1.DiskIDs) + if err := Convert_internal_DiskIDs_To_v1beta1_DiskIDs(val, newVal); err != nil { + return err + } + (*out)[key] = newVal + } + } else { + out.DiskIDs = nil + } + return nil +} diff --git a/internal/server/disk/internal/v1beta1/conversion_generated.go b/internal/server/disk/internal/v1beta1/conversion_generated.go new file mode 100644 index 00000000..694f8247 --- /dev/null +++ b/internal/server/disk/internal/v1beta1/conversion_generated.go @@ -0,0 +1,244 @@ +// Code generated by csi-proxy-api-gen. DO NOT EDIT. + +package v1beta1 + +import ( + unsafe "unsafe" + + v1beta1 "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1" + internal "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal" +) + +func autoConvert_v1beta1_DiskIDs_To_internal_DiskIDs(in *v1beta1.DiskIDs, out *internal.DiskIDs) error { + out.Identifiers = *(*map[string]string)(unsafe.Pointer(&in.Identifiers)) + return nil +} + +// Convert_v1beta1_DiskIDs_To_internal_DiskIDs is an autogenerated conversion function. +func Convert_v1beta1_DiskIDs_To_internal_DiskIDs(in *v1beta1.DiskIDs, out *internal.DiskIDs) error { + return autoConvert_v1beta1_DiskIDs_To_internal_DiskIDs(in, out) +} + +func autoConvert_internal_DiskIDs_To_v1beta1_DiskIDs(in *internal.DiskIDs, out *v1beta1.DiskIDs) error { + out.Identifiers = *(*map[string]string)(unsafe.Pointer(&in.Identifiers)) + return nil +} + +// Convert_internal_DiskIDs_To_v1beta1_DiskIDs is an autogenerated conversion function. +func Convert_internal_DiskIDs_To_v1beta1_DiskIDs(in *internal.DiskIDs, out *v1beta1.DiskIDs) error { + return autoConvert_internal_DiskIDs_To_v1beta1_DiskIDs(in, out) +} + +func autoConvert_v1beta1_DiskLocation_To_internal_DiskLocation(in *v1beta1.DiskLocation, out *internal.DiskLocation) error { + out.Adapter = in.Adapter + out.Bus = in.Bus + out.Target = in.Target + out.LUNID = in.LUNID + return nil +} + +// Convert_v1beta1_DiskLocation_To_internal_DiskLocation is an autogenerated conversion function. +func Convert_v1beta1_DiskLocation_To_internal_DiskLocation(in *v1beta1.DiskLocation, out *internal.DiskLocation) error { + return autoConvert_v1beta1_DiskLocation_To_internal_DiskLocation(in, out) +} + +func autoConvert_internal_DiskLocation_To_v1beta1_DiskLocation(in *internal.DiskLocation, out *v1beta1.DiskLocation) error { + out.Adapter = in.Adapter + out.Bus = in.Bus + out.Target = in.Target + out.LUNID = in.LUNID + return nil +} + +// Convert_internal_DiskLocation_To_v1beta1_DiskLocation is an autogenerated conversion function. +func Convert_internal_DiskLocation_To_v1beta1_DiskLocation(in *internal.DiskLocation, out *v1beta1.DiskLocation) error { + return autoConvert_internal_DiskLocation_To_v1beta1_DiskLocation(in, out) +} + +func autoConvert_v1beta1_ListDiskIDsRequest_To_internal_ListDiskIDsRequest(in *v1beta1.ListDiskIDsRequest, out *internal.ListDiskIDsRequest) error { + return nil +} + +// Convert_v1beta1_ListDiskIDsRequest_To_internal_ListDiskIDsRequest is an autogenerated conversion function. +func Convert_v1beta1_ListDiskIDsRequest_To_internal_ListDiskIDsRequest(in *v1beta1.ListDiskIDsRequest, out *internal.ListDiskIDsRequest) error { + return autoConvert_v1beta1_ListDiskIDsRequest_To_internal_ListDiskIDsRequest(in, out) +} + +func autoConvert_internal_ListDiskIDsRequest_To_v1beta1_ListDiskIDsRequest(in *internal.ListDiskIDsRequest, out *v1beta1.ListDiskIDsRequest) error { + return nil +} + +// Convert_internal_ListDiskIDsRequest_To_v1beta1_ListDiskIDsRequest is an autogenerated conversion function. +func Convert_internal_ListDiskIDsRequest_To_v1beta1_ListDiskIDsRequest(in *internal.ListDiskIDsRequest, out *v1beta1.ListDiskIDsRequest) error { + return autoConvert_internal_ListDiskIDsRequest_To_v1beta1_ListDiskIDsRequest(in, out) +} + +func autoConvert_v1beta1_ListDiskIDsResponse_To_internal_ListDiskIDsResponse(in *v1beta1.ListDiskIDsResponse, out *internal.ListDiskIDsResponse) error { + if in.DiskIDs != nil { + in, out := &in.DiskIDs, &out.DiskIDs + *out = make(map[string]*internal.DiskIDs, len(*in)) + for key, val := range *in { + newVal := new(*internal.DiskIDs) + if err := Convert_v1beta1_DiskIDs_To_internal_DiskIDs(*&val, *newVal); err != nil { + return err + } + (*out)[key] = *newVal + } + } else { + out.DiskIDs = nil + } + return nil +} + +// Convert_v1beta1_ListDiskIDsResponse_To_internal_ListDiskIDsResponse is an autogenerated conversion function. +func Convert_v1beta1_ListDiskIDsResponse_To_internal_ListDiskIDsResponse(in *v1beta1.ListDiskIDsResponse, out *internal.ListDiskIDsResponse) error { + return autoConvert_v1beta1_ListDiskIDsResponse_To_internal_ListDiskIDsResponse(in, out) +} + +func autoConvert_internal_ListDiskIDsResponse_To_v1beta1_ListDiskIDsResponse(in *internal.ListDiskIDsResponse, out *v1beta1.ListDiskIDsResponse) error { + if in.DiskIDs != nil { + in, out := &in.DiskIDs, &out.DiskIDs + *out = make(map[string]*v1beta1.DiskIDs, len(*in)) + for key, val := range *in { + newVal := new(*v1beta1.DiskIDs) + if err := Convert_internal_DiskIDs_To_v1beta1_DiskIDs(*&val, *newVal); err != nil { + return err + } + (*out)[key] = *newVal + } + } else { + out.DiskIDs = nil + } + return nil +} + +func autoConvert_v1beta1_ListDiskLocationsRequest_To_internal_ListDiskLocationsRequest(in *v1beta1.ListDiskLocationsRequest, out *internal.ListDiskLocationsRequest) error { + return nil +} + +// Convert_v1beta1_ListDiskLocationsRequest_To_internal_ListDiskLocationsRequest is an autogenerated conversion function. +func Convert_v1beta1_ListDiskLocationsRequest_To_internal_ListDiskLocationsRequest(in *v1beta1.ListDiskLocationsRequest, out *internal.ListDiskLocationsRequest) error { + return autoConvert_v1beta1_ListDiskLocationsRequest_To_internal_ListDiskLocationsRequest(in, out) +} + +func autoConvert_internal_ListDiskLocationsRequest_To_v1beta1_ListDiskLocationsRequest(in *internal.ListDiskLocationsRequest, out *v1beta1.ListDiskLocationsRequest) error { + return nil +} + +// Convert_internal_ListDiskLocationsRequest_To_v1beta1_ListDiskLocationsRequest is an autogenerated conversion function. +func Convert_internal_ListDiskLocationsRequest_To_v1beta1_ListDiskLocationsRequest(in *internal.ListDiskLocationsRequest, out *v1beta1.ListDiskLocationsRequest) error { + return autoConvert_internal_ListDiskLocationsRequest_To_v1beta1_ListDiskLocationsRequest(in, out) +} + +func autoConvert_v1beta1_ListDiskLocationsResponse_To_internal_ListDiskLocationsResponse(in *v1beta1.ListDiskLocationsResponse, out *internal.ListDiskLocationsResponse) error { + if in.DiskLocations != nil { + in, out := &in.DiskLocations, &out.DiskLocations + *out = make(map[string]*internal.DiskLocation, len(*in)) + for key, val := range *in { + newVal := new(*internal.DiskLocation) + if err := Convert_v1beta1_DiskLocation_To_internal_DiskLocation(*&val, *newVal); err != nil { + return err + } + (*out)[key] = *newVal + } + } else { + out.DiskLocations = nil + } + return nil +} + +// Convert_v1beta1_ListDiskLocationsResponse_To_internal_ListDiskLocationsResponse is an autogenerated conversion function. +func Convert_v1beta1_ListDiskLocationsResponse_To_internal_ListDiskLocationsResponse(in *v1beta1.ListDiskLocationsResponse, out *internal.ListDiskLocationsResponse) error { + return autoConvert_v1beta1_ListDiskLocationsResponse_To_internal_ListDiskLocationsResponse(in, out) +} + +func autoConvert_internal_ListDiskLocationsResponse_To_v1beta1_ListDiskLocationsResponse(in *internal.ListDiskLocationsResponse, out *v1beta1.ListDiskLocationsResponse) error { + if in.DiskLocations != nil { + in, out := &in.DiskLocations, &out.DiskLocations + *out = make(map[string]*v1beta1.DiskLocation, len(*in)) + for key, val := range *in { + newVal := new(*v1beta1.DiskLocation) + if err := Convert_internal_DiskLocation_To_v1beta1_DiskLocation(*&val, *newVal); err != nil { + return err + } + (*out)[key] = *newVal + } + } else { + out.DiskLocations = nil + } + return nil +} + +func autoConvert_v1beta1_PartitionDiskRequest_To_internal_PartitionDiskRequest(in *v1beta1.PartitionDiskRequest, out *internal.PartitionDiskRequest) error { + out.DiskID = in.DiskID + return nil +} + +// Convert_v1beta1_PartitionDiskRequest_To_internal_PartitionDiskRequest is an autogenerated conversion function. +func Convert_v1beta1_PartitionDiskRequest_To_internal_PartitionDiskRequest(in *v1beta1.PartitionDiskRequest, out *internal.PartitionDiskRequest) error { + return autoConvert_v1beta1_PartitionDiskRequest_To_internal_PartitionDiskRequest(in, out) +} + +func autoConvert_internal_PartitionDiskRequest_To_v1beta1_PartitionDiskRequest(in *internal.PartitionDiskRequest, out *v1beta1.PartitionDiskRequest) error { + out.DiskID = in.DiskID + return nil +} + +// Convert_internal_PartitionDiskRequest_To_v1beta1_PartitionDiskRequest is an autogenerated conversion function. +func Convert_internal_PartitionDiskRequest_To_v1beta1_PartitionDiskRequest(in *internal.PartitionDiskRequest, out *v1beta1.PartitionDiskRequest) error { + return autoConvert_internal_PartitionDiskRequest_To_v1beta1_PartitionDiskRequest(in, out) +} + +func autoConvert_v1beta1_PartitionDiskResponse_To_internal_PartitionDiskResponse(in *v1beta1.PartitionDiskResponse, out *internal.PartitionDiskResponse) error { + return nil +} + +// Convert_v1beta1_PartitionDiskResponse_To_internal_PartitionDiskResponse is an autogenerated conversion function. +func Convert_v1beta1_PartitionDiskResponse_To_internal_PartitionDiskResponse(in *v1beta1.PartitionDiskResponse, out *internal.PartitionDiskResponse) error { + return autoConvert_v1beta1_PartitionDiskResponse_To_internal_PartitionDiskResponse(in, out) +} + +func autoConvert_internal_PartitionDiskResponse_To_v1beta1_PartitionDiskResponse(in *internal.PartitionDiskResponse, out *v1beta1.PartitionDiskResponse) error { + return nil +} + +// Convert_internal_PartitionDiskResponse_To_v1beta1_PartitionDiskResponse is an autogenerated conversion function. +func Convert_internal_PartitionDiskResponse_To_v1beta1_PartitionDiskResponse(in *internal.PartitionDiskResponse, out *v1beta1.PartitionDiskResponse) error { + return autoConvert_internal_PartitionDiskResponse_To_v1beta1_PartitionDiskResponse(in, out) +} + +func autoConvert_v1beta1_RescanRequest_To_internal_RescanRequest(in *v1beta1.RescanRequest, out *internal.RescanRequest) error { + return nil +} + +// Convert_v1beta1_RescanRequest_To_internal_RescanRequest is an autogenerated conversion function. +func Convert_v1beta1_RescanRequest_To_internal_RescanRequest(in *v1beta1.RescanRequest, out *internal.RescanRequest) error { + return autoConvert_v1beta1_RescanRequest_To_internal_RescanRequest(in, out) +} + +func autoConvert_internal_RescanRequest_To_v1beta1_RescanRequest(in *internal.RescanRequest, out *v1beta1.RescanRequest) error { + return nil +} + +// Convert_internal_RescanRequest_To_v1beta1_RescanRequest is an autogenerated conversion function. +func Convert_internal_RescanRequest_To_v1beta1_RescanRequest(in *internal.RescanRequest, out *v1beta1.RescanRequest) error { + return autoConvert_internal_RescanRequest_To_v1beta1_RescanRequest(in, out) +} + +func autoConvert_v1beta1_RescanResponse_To_internal_RescanResponse(in *v1beta1.RescanResponse, out *internal.RescanResponse) error { + return nil +} + +// Convert_v1beta1_RescanResponse_To_internal_RescanResponse is an autogenerated conversion function. +func Convert_v1beta1_RescanResponse_To_internal_RescanResponse(in *v1beta1.RescanResponse, out *internal.RescanResponse) error { + return autoConvert_v1beta1_RescanResponse_To_internal_RescanResponse(in, out) +} + +func autoConvert_internal_RescanResponse_To_v1beta1_RescanResponse(in *internal.RescanResponse, out *v1beta1.RescanResponse) error { + return nil +} + +// Convert_internal_RescanResponse_To_v1beta1_RescanResponse is an autogenerated conversion function. +func Convert_internal_RescanResponse_To_v1beta1_RescanResponse(in *internal.RescanResponse, out *v1beta1.RescanResponse) error { + return autoConvert_internal_RescanResponse_To_v1beta1_RescanResponse(in, out) +} diff --git a/internal/server/disk/internal/v1beta1/server_generated.go b/internal/server/disk/internal/v1beta1/server_generated.go new file mode 100644 index 00000000..355e9bdc --- /dev/null +++ b/internal/server/disk/internal/v1beta1/server_generated.go @@ -0,0 +1,104 @@ +// Code generated by csi-proxy-api-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + + "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1" + "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal" + "google.golang.org/grpc" +) + +var version = apiversion.NewVersionOrPanic("v1beta1") + +type versionedAPI struct { + apiGroupServer internal.ServerInterface +} + +func NewVersionedServer(apiGroupServer internal.ServerInterface) internal.VersionedAPI { + return &versionedAPI{ + apiGroupServer: apiGroupServer, + } +} + +func (s *versionedAPI) Register(grpcServer *grpc.Server) { + v1beta1.RegisterDiskServer(grpcServer, s) +} + +func (s *versionedAPI) ListDiskIDs(context context.Context, versionedRequest *v1beta1.ListDiskIDsRequest) (*v1beta1.ListDiskIDsResponse, error) { + request := &internal.ListDiskIDsRequest{} + if err := Convert_v1beta1_ListDiskIDsRequest_To_internal_ListDiskIDsRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.ListDiskIDs(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1beta1.ListDiskIDsResponse{} + if err := Convert_internal_ListDiskIDsResponse_To_v1beta1_ListDiskIDsResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} + +func (s *versionedAPI) ListDiskLocations(context context.Context, versionedRequest *v1beta1.ListDiskLocationsRequest) (*v1beta1.ListDiskLocationsResponse, error) { + request := &internal.ListDiskLocationsRequest{} + if err := Convert_v1beta1_ListDiskLocationsRequest_To_internal_ListDiskLocationsRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.ListDiskLocations(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1beta1.ListDiskLocationsResponse{} + if err := Convert_internal_ListDiskLocationsResponse_To_v1beta1_ListDiskLocationsResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} + +func (s *versionedAPI) PartitionDisk(context context.Context, versionedRequest *v1beta1.PartitionDiskRequest) (*v1beta1.PartitionDiskResponse, error) { + request := &internal.PartitionDiskRequest{} + if err := Convert_v1beta1_PartitionDiskRequest_To_internal_PartitionDiskRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.PartitionDisk(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1beta1.PartitionDiskResponse{} + if err := Convert_internal_PartitionDiskResponse_To_v1beta1_PartitionDiskResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} + +func (s *versionedAPI) Rescan(context context.Context, versionedRequest *v1beta1.RescanRequest) (*v1beta1.RescanResponse, error) { + request := &internal.RescanRequest{} + if err := Convert_v1beta1_RescanRequest_To_internal_RescanRequest(versionedRequest, request); err != nil { + return nil, err + } + + response, err := s.apiGroupServer.Rescan(context, request, version) + if err != nil { + return nil, err + } + + versionedResponse := &v1beta1.RescanResponse{} + if err := Convert_internal_RescanResponse_To_v1beta1_RescanResponse(response, versionedResponse); err != nil { + return nil, err + } + + return versionedResponse, err +} diff --git a/internal/server/disk/server.go b/internal/server/disk/server.go index 4270ec39..5bc015a4 100644 --- a/internal/server/disk/server.go +++ b/internal/server/disk/server.go @@ -2,6 +2,7 @@ package disk import ( "context" + "fmt" "github.com/kubernetes-csi/csi-proxy/client/apiversion" "github.com/kubernetes-csi/csi-proxy/internal/server/disk/internal" @@ -21,6 +22,7 @@ type API interface { CreatePartition(diskID string) error Rescan() error GetDiskNumberByName(diskName string) (string, error) + ListDiskIDs() (map[string]shared.DiskIDs, error) } func NewServer(hostAPI API) (*Server, error) { @@ -113,3 +115,31 @@ func (s *Server) GetDiskNumberByName(context context.Context, request *internal. response.DiskNumber = number return response, nil } + +func (s *Server) ListDiskIDs(context context.Context, request *internal.ListDiskIDsRequest, version apiversion.Version) (*internal.ListDiskIDsResponse, error) { + klog.V(4).Infof("calling ListDiskIDs") + minimumVersion := apiversion.NewVersionOrPanic("v1beta1") + if version.Compare(minimumVersion) < 0 { + return nil, fmt.Errorf("ListDiskIDs requires CSI-Proxy API version v1beta1 or greater") + } + + response := &internal.ListDiskIDsResponse{} + diskIDs, err := s.hostAPI.ListDiskIDs() + + if err != nil { + klog.Errorf("failed ListDiskIDs %v", err) + return nil, err + } + responseDiskIDs := make(map[string]*internal.DiskIDs) + + // Convert from shared to internal type + for k, v := range diskIDs { + diskIDs := internal.DiskIDs{Identifiers: make(map[string]string)} + for k1, v1 := range v.Identifiers { + diskIDs.Identifiers[k1] = v1 + } + responseDiskIDs[k] = &diskIDs + } + response.DiskIDs = responseDiskIDs + return response, nil +} diff --git a/internal/shared/disk/types.go b/internal/shared/disk/types.go index 4503e566..dc62e471 100644 --- a/internal/shared/disk/types.go +++ b/internal/shared/disk/types.go @@ -10,3 +10,9 @@ type DiskLocation struct { Target string LUNID string } + +// DiskID definition +type DiskIDs struct { + // Map of Disk ID types and Disk ID values + Identifiers map[string]string +}