Skip to content

Commit

Permalink
fix: update code with changes in opi api
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun authored and sandersms committed Jan 23, 2024
1 parent 8de029f commit 9e69e4b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 31 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"
Expand All @@ -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'}"
Expand Down
1 change: 1 addition & 0 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/frontend/nvme_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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),
},
},
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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),
},
},
Expand All @@ -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,
Expand All @@ -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,
},
Expand All @@ -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),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/nvme_controller_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/nvme_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/frontend/nvme_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
}
Expand Down Expand Up @@ -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,
},
Expand Down
11 changes: 1 addition & 10 deletions pkg/frontend/virtio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 9e69e4b

Please sign in to comment.