diff --git a/README.md b/README.md index fa6e6bce..580ed4a4 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ docker run --network=host --rm -it namely/grpc-cli ls --json_input --json_outp docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeSubsystem "{nvme_subsystem : {spec : {nqn: 'nqn.2022-09.io.spdk:opitest2', serial_number: 'myserial2', model_number: 'mymodel2', max_namespaces: 11} }, nvme_subsystem_id : 'subsystem2' }" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmeSubsystems "{}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 GetNvmeSubsystem "{name : '//storage.opiproject.org/subsystems/subsystem2'}" -docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeController "{parent: '//storage.opiproject.org/subsystems/subsystem2', nvme_controller : {spec : {nvme_controller_id: 2, pcie_id : {physical_function : 0, virtual_function : 0, port_id: 0}, max_nsq:5, max_ncq:5, 'trtype': 'NVME_TRANSPORT_PCIE' } }, nvme_controller_id : 'controller1'}" +docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeController "{parent: '//storage.opiproject.org/subsystems/subsystem2', nvme_controller : {spec : {nvme_controller_id: 2, pcie_id : {physical_function : 0, virtual_function : 0, port_id: 0}, max_nsq:5, max_ncq:5, 'trtype': 'NVME_TRANSPORT_TYPE_PCIE' } }, nvme_controller_id : 'controller1'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmeControllers "{parent : '//storage.opiproject.org/subsystems/subsystem2'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 GetNvmeController "{name : '//storage.opiproject.org/subsystems/subsystem2/controllers/controller1'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeNamespace "{parent: '//storage.opiproject.org/subsystems/subsystem2', nvme_namespace : {spec : {volume_name_ref : 'Malloc0', 'host_nsid' : '10', uuid:{value : '1b4e28ba-2fa1-11d2-883f-b9a761bde3fb'}, nguid: '1b4e28ba-2fa1-11d2-883f-b9a761bde3fb', eui64: 1967554867335598546 } }, nvme_namespace_id: 'namespace1'}" @@ -120,9 +120,9 @@ docker run --network=host --rm -it namely/grpc-cli call --json_input --json_outp docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeRemoteController "{nvme_remote_controller : {multipath: 'NVME_MULTIPATH_MULTIPATH'}, nvme_remote_controller_id: 'nvmetcp12'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmeRemoteControllers "{parent : 'todo'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 GetNvmeRemoteController "{name: '//storage.opiproject.org/volumes/nvmetcp12'}" -docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmePath "{nvme_path : {controller_name_ref: '//storage.opiproject.org/volumes/nvmetcp12', traddr:'11.11.11.2', trtype:'NVME_TRANSPORT_TCP', fabrics: {adrfam:'NVME_ADRFAM_IPV4', subnqn:'nqn.2016-06.com.opi.spdk.target0', trsvcid:'4444', hostnqn:'nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c'}}, nvme_path_id: 'nvmetcp12path0'}" +docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmePath "{nvme_path : {controller_name_ref: '//storage.opiproject.org/volumes/nvmetcp12', traddr:'11.11.11.2', trtype:'NVME_TRANSPORT_TYPE_TCP', fabrics: {adrfam:'NVME_ADDRESS_FAMILY_IPV4', subnqn:'nqn.2016-06.com.opi.spdk.target0', trsvcid:'4444', hostnqn:'nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c'}}, nvme_path_id: 'nvmetcp12path0'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeRemoteController "{nvme_remote_controller : {multipath: 'NVME_MULTIPATH_DISABLE'}, nvme_remote_controller_id: 'nvmepcie13'}" -docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmePath "{nvme_path : {controller_name_ref: '//storage.opiproject.org/volumes/nvmepcie13', traddr:'0000:01:00.0', trtype:'NVME_TRANSPORT_PCIE'}, nvme_path_id: 'nvmepcie13path0'}" +docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmePath "{nvme_path : {controller_name_ref: '//storage.opiproject.org/volumes/nvmepcie13', traddr:'0000:01:00.0', trtype:'NVME_TRANSPORT_TYPE_PCIE'}, nvme_path_id: 'nvmepcie13path0'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmePaths "{parent : 'todo'}" docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 DeleteNvmePath "{name: '//storage.opiproject.org/volumes/nvmepcie13path0'}" diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go index 48e29228..8563aedc 100644 --- a/pkg/frontend/frontend.go +++ b/pkg/frontend/frontend.go @@ -18,6 +18,7 @@ import ( // Server contains frontend related OPI services type Server struct { pb.UnimplementedFrontendNvmeServiceServer + pb.UnimplementedFrontendVirtioBlkServiceServer VirtioCtrls map[string]*pb.VirtioBlk NQNs map[string]bool Pagination map[string]int diff --git a/pkg/frontend/frontend_test.go b/pkg/frontend/frontend_test.go index 5b79ac51..9f238b23 100644 --- a/pkg/frontend/frontend_test.go +++ b/pkg/frontend/frontend_test.go @@ -119,7 +119,7 @@ var ( PortId: wrapperspb.Int32(0), }, }, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(17), }, } diff --git a/pkg/frontend/nvme_controller_test.go b/pkg/frontend/nvme_controller_test.go index 21f2859c..b835a313 100644 --- a/pkg/frontend/nvme_controller_test.go +++ b/pkg/frontend/nvme_controller_test.go @@ -24,12 +24,12 @@ import ( func TestFrontEnd_CreateNvmeController(t *testing.T) { spec := &pb.NvmeControllerSpec{ Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(1), } controllerSpec := &pb.NvmeControllerSpec{ Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(17), } t.Cleanup(checkGlobalTestProtoObjectsNotChanged(t, t.Name())) @@ -50,7 +50,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { in: &pb.NvmeController{ Spec: &pb.NvmeControllerSpec{ Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(1), }, }, @@ -118,7 +118,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { Name: testControllerName, Spec: &pb.NvmeControllerSpec{ Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(17), }, Status: &pb.NvmeControllerStatus{ @@ -148,7 +148,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { in: &pb.NvmeController{ Spec: &pb.NvmeControllerSpec{ Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(1), }, }, @@ -175,7 +175,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { Spec: &pb.NvmeControllerSpec{ NvmeControllerId: proto.Int32(1), Endpoint: testController.Spec.Endpoint, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, }, }, out: nil, @@ -193,17 +193,17 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { FabricsId: &pb.FabricsEndpoint{ Traddr: "127.0.0.1", Trsvcid: "4420", - Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, + Adrfam: pb.NvmeAddressFamily_NVME_ADDRESS_FAMILY_IPV4, }, }, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_TCP, NvmeControllerId: proto.Int32(1), }, }, out: nil, spdk: []string{}, errCode: codes.Unknown, - errMsg: fmt.Sprintf("not supported transport type: %v", pb.NvmeTransportType_NVME_TRANSPORT_TCP), + errMsg: fmt.Sprintf("not supported transport type: %v", pb.NvmeTransportType_NVME_TRANSPORT_TYPE_TCP), exist: false, subsys: testSubsystemName, }, @@ -215,10 +215,10 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { FabricsId: &pb.FabricsEndpoint{ Traddr: "127.0.0.1", Trsvcid: "4420", - Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, + Adrfam: pb.NvmeAddressFamily_NVME_ADDRESS_FAMILY_IPV4, }, }, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE, NvmeControllerId: proto.Int32(1), }, }, diff --git a/pkg/frontend/nvme_controller_validate.go b/pkg/frontend/nvme_controller_validate.go index ac40b48b..234bcc8f 100644 --- a/pkg/frontend/nvme_controller_validate.go +++ b/pkg/frontend/nvme_controller_validate.go @@ -27,7 +27,7 @@ func (s *Server) validateCreateNvmeControllerRequest(in *pb.CreateNvmeController } } - if in.NvmeController.Spec.Trtype != pb.NvmeTransportType_NVME_TRANSPORT_PCIE { + if in.NvmeController.Spec.Trtype != pb.NvmeTransportType_NVME_TRANSPORT_TYPE_PCIE { return fmt.Errorf("not supported transport type: %v", in.NvmeController.Spec.Trtype) } diff --git a/pkg/frontend/nvme_namespace.go b/pkg/frontend/nvme_namespace.go index 90129b93..d8499bce 100644 --- a/pkg/frontend/nvme_namespace.go +++ b/pkg/frontend/nvme_namespace.go @@ -75,7 +75,7 @@ func (s *Server) CreateNvmeNamespace(ctx context.Context, in *pb.CreateNvmeNames Nsid: int(in.NvmeNamespace.Spec.HostNsid), Subnqn: subsys.Spec.Nqn, Cntlid: 0, - UUID: in.NvmeNamespace.Spec.Uuid.Value, + UUID: in.NvmeNamespace.Spec.Uuid, Nguid: in.NvmeNamespace.Spec.Nguid, Eui64: strconv.FormatInt(in.NvmeNamespace.Spec.Eui64, 10), } diff --git a/pkg/frontend/nvme_namespace_test.go b/pkg/frontend/nvme_namespace_test.go index 08dd362f..b9369ec3 100644 --- a/pkg/frontend/nvme_namespace_test.go +++ b/pkg/frontend/nvme_namespace_test.go @@ -17,7 +17,6 @@ import ( "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/fieldmaskpb" - pc "github.com/opiproject/opi-api/common/v1/gen/go" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) @@ -26,14 +25,14 @@ func TestFrontEnd_CreateNvmeNamespace(t *testing.T) { spec := &pb.NvmeNamespaceSpec{ HostNsid: 0, VolumeNameRef: "Malloc1", - Uuid: &pc.Uuid{Value: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"}, + Uuid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Nguid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Eui64: 1967554867335598546, } namespaceSpec := &pb.NvmeNamespaceSpec{ HostNsid: 22, VolumeNameRef: "Malloc1", - Uuid: &pc.Uuid{Value: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"}, + Uuid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Nguid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Eui64: 1967554867335598546, } @@ -120,7 +119,7 @@ func TestFrontEnd_CreateNvmeNamespace(t *testing.T) { Spec: &pb.NvmeNamespaceSpec{ HostNsid: 22, VolumeNameRef: "Malloc1", - Uuid: &pc.Uuid{Value: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"}, + Uuid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Nguid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Eui64: 1967554867335598546, }, diff --git a/pkg/frontend/virtio_test.go b/pkg/frontend/virtio_test.go index ebad8876..984d029e 100644 --- a/pkg/frontend/virtio_test.go +++ b/pkg/frontend/virtio_test.go @@ -394,15 +394,6 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { size: 0, token: "", }, - "no required field": { - in: "", - out: []*pb.VirtioBlk{}, - spdk: []string{}, - errCode: codes.Unknown, - errMsg: "missing required field: parent", - size: 0, - token: "", - }, } // run tests @@ -413,7 +404,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 - request := &pb.ListVirtioBlksRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} + request := &pb.ListVirtioBlksRequest{PageSize: tt.size, PageToken: tt.token} response, err := testEnv.client.ListVirtioBlks(testEnv.ctx, request) if !utils.EqualProtoSlices(response.GetVirtioBlks(), tt.out) {