From 1c832535bd9d699033bf3e8016b45e21db3fa71d Mon Sep 17 00:00:00 2001 From: Artsiom Koltun Date: Tue, 12 Dec 2023 12:51:14 +0100 Subject: [PATCH] fix(storage/backend): adjust nvme to parent member Signed-off-by: Artsiom Koltun --- storage/backend.go | 21 ++++++++++----------- storage/goopicsi.go | 8 ++++---- storage/resource.go | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/storage/backend.go b/storage/backend.go index cf77bbe..4299dea 100644 --- a/storage/backend.go +++ b/storage/backend.go @@ -77,7 +77,7 @@ func executeNvmeRemoteController(ctx context.Context, c4 pb.NvmeRemoteController } newResourceID = parsed.String() } - fullname := resourceIDToVolumeName(newResourceID) + fullname := resourceIDToRemoteControllerName(newResourceID) if rr0.Name != fullname { return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", rr0.Name, fullname) } @@ -88,7 +88,7 @@ func executeNvmeRemoteController(ctx context.Context, c4 pb.NvmeRemoteController return err } log.Printf("Reset Nvme: %v", rr2) - rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{Parent: "todo"}) + rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{}) if err != nil { return err } @@ -150,11 +150,11 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien for _, resourceID := range []string{"opi-nvme8-path", ""} { np0, err := c5.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{ + Parent: rr0.Name, NvmePathId: resourceID, NvmePath: &pb.NvmePath{ - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, - Traddr: addr[0].String(), - ControllerNameRef: rr0.Name, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, + Traddr: addr[0].String(), Fabrics: &pb.FabricsPath{ Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, Trsvcid: int64(port), @@ -175,7 +175,7 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien } newResourceID = parsed.String() } - fullname := resourceIDToVolumeName(newResourceID) + fullname := resourceIDToNvmePathName(ctrlrResourceID, newResourceID) if np0.Name != fullname { return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", np0.Name, fullname) } @@ -183,10 +183,9 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien np3, err := c5.UpdateNvmePath(ctx, &pb.UpdateNvmePathRequest{ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}}, NvmePath: &pb.NvmePath{ - Name: np0.Name, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, - Traddr: addr[0].String(), - ControllerNameRef: rr0.Name, + Name: np0.Name, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, + Traddr: addr[0].String(), Fabrics: &pb.FabricsPath{ Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, Trsvcid: int64(port), @@ -198,7 +197,7 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien return err } log.Printf("Updated Nvme path: %v", np3) - np4, err := c5.ListNvmePaths(ctx, &pb.ListNvmePathsRequest{Parent: "todo"}) + np4, err := c5.ListNvmePaths(ctx, &pb.ListNvmePathsRequest{Parent: rr0.Name}) if err != nil { return err } diff --git a/storage/goopicsi.go b/storage/goopicsi.go index 49d9b5d..e4b42bf 100644 --- a/storage/goopicsi.go +++ b/storage/goopicsi.go @@ -65,11 +65,11 @@ func NvmeControllerConnect(id string, trAddr string, subnqn string, trSvcID int6 log.Printf("Connected: %v", response) pathResponse, err := client.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{ + Parent: response.Name, NvmePathId: nvmeControllerToPathResourceID(id), NvmePath: &pb.NvmePath{ - ControllerNameRef: response.Name, - Traddr: trAddr, - Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, + Traddr: trAddr, + Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP, Fabrics: &pb.FabricsPath{ Subnqn: subnqn, Trsvcid: trSvcID, @@ -107,7 +107,7 @@ func NvmeControllerList() ([]NvmeConnection, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - response, err := client.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{Parent: "todo"}) + response, err := client.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{}) if err != nil { log.Printf("could not list the connections to Remote Nvme controller: %v", err) return []NvmeConnection{}, err diff --git a/storage/resource.go b/storage/resource.go index e22a2c3..c7d6a67 100644 --- a/storage/resource.go +++ b/storage/resource.go @@ -35,3 +35,18 @@ func resourceIDToControllerName(subsysResourceID, ctrlrResourceID string) string "controllers", ctrlrResourceID, ) } + +func resourceIDToRemoteControllerName(resourceID string) string { + return resourcename.Join( + "//storage.opiproject.org/", + "nvmeRemoteControllers", resourceID, + ) +} + +func resourceIDToNvmePathName(ctrlrResourceID, pathResourceID string) string { + return resourcename.Join( + "//storage.opiproject.org/", + "nvmeRemoteControllers", ctrlrResourceID, + "nvmePaths", pathResourceID, + ) +}