Skip to content

Commit

Permalink
fix(backend): add missing UpdateNvmeRemoteController
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Sep 23, 2023
1 parent 705155b commit 1c1f23f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/backend/nvme_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/google/uuid"
"go.einride.tech/aip/fieldbehavior"
"go.einride.tech/aip/fieldmask"
"go.einride.tech/aip/resourceid"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -92,6 +93,36 @@ func (s *Server) ResetNvmeRemoteController(_ context.Context, in *pb.ResetNvmeRe
return &emptypb.Empty{}, nil
}

// UpdateNvmeRemoteController resets an Nvme remote controller
func (s *Server) UpdateNvmeRemoteController(_ context.Context, in *pb.UpdateNvmeRemoteControllerRequest) (*pb.NvmeRemoteController, error) {
log.Printf("UpdateNvmeRemoteController: Received from client: %v", in)
// check input correctness
if err := s.validateUpdateNvmeRemoteControllerRequest(in); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// fetch object from the database
volume, ok := s.Volumes.NvmeControllers[in.NvmeRemoteController.Name]
if !ok {
if in.AllowMissing {
log.Printf("TODO: in case of AllowMissing, create a new resource, don;t return error")
}
err := status.Errorf(codes.NotFound, "unable to find key %s", in.NvmeRemoteController.Name)
log.Printf("error: %v", err)
return nil, err
}
resourceID := path.Base(volume.Name)
// update_mask = 2
if err := fieldmask.Validate(in.UpdateMask, in.NvmeRemoteController); err != nil {
log.Printf("error: %v", err)
return nil, err
}
log.Printf("TODO: use resourceID=%v", resourceID)
response := server.ProtoClone(in.NvmeRemoteController)
// s.Volumes.NvmeControllers[in.NvmeRemoteController.Name] = response
return response, nil
}

// ListNvmeRemoteControllers lists an Nvme remote controllers
func (s *Server) ListNvmeRemoteControllers(_ context.Context, in *pb.ListNvmeRemoteControllersRequest) (*pb.ListNvmeRemoteControllersResponse, error) {
log.Printf("ListNvmeRemoteControllers: Received from client: %v", in)
Expand Down

0 comments on commit 1c1f23f

Please sign in to comment.