Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DeleteNamespace RPC #50

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions goopicsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,28 @@ func CreateNVMeNamespace(id string, subSystemID string, volumeID string, hostID
return resp.Spec.Id.Value, nil
}

// DeleteNVMeNamespace deletes the NVMe namespace
func DeleteNVMeNamespace(id string) error {
if conn == nil {
err := dialConnection()
if err != nil {
return err
}
}

client := pb.NewFrontendNvmeServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

resp, err := client.DeleteNVMeNamespace(ctx, &pb.DeleteNVMeNamespaceRequest{NamespaceId: &pbc.ObjectKey{Value: id}})
if err != nil {
log.Println(err)
return err
}
log.Println(resp)
return nil
}

func dialConnection() error {
var err error
conn, err = grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down
7 changes: 7 additions & 0 deletions goopicsi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ func TestCreateNVMeNamespace(t *testing.T) {
}
log.Println(resp)
}

func TestDeleteNVMeNamespace(t *testing.T) {
err := DeleteNVMeNamespace("1")
if err != nil {
log.Println(err)
}
}