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

feat: add func BdevLvolGetByName #187

Merged
merged 1 commit into from
Dec 27, 2024
Merged
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
18 changes: 18 additions & 0 deletions pkg/spdk/client/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"encoding/json"
"fmt"
"strconv"
"strings"

Expand Down Expand Up @@ -243,6 +244,23 @@
return deleted, json.Unmarshal(cmdOutput, &deleted)
}

// BdevLvolGetByName gets information about a single lvol bdevs with the specified name.
//
// "name": Required. UUID or alias of a logical volume (lvol) bdev.
// The alias of a lvol bdev is <LVSTORE NAME>/<LVOL NAME>. And the name of a lvol bdev is UUID.
//
// "timeout": Optional. 0 by default, meaning the method returns immediately whether the lvol bdev exists or not.
func (c *Client) BdevLvolGetByName(name string, timeout uint64) (bdevLvol spdktypes.BdevInfo, err error) {
bdevLvolList, err := c.BdevLvolGetWithFilter(name, timeout, func(*spdktypes.BdevInfo) bool { return true })
if err != nil {
return spdktypes.BdevInfo{}, err
}
if len(bdevLvolList) != 1 {
return spdktypes.BdevInfo{}, fmt.Errorf("zero or multiple lvols with name %s found", name)
}
return bdevLvolList[0], nil

Check warning on line 261 in pkg/spdk/client/basic.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/client/basic.go#L253-L261

Added lines #L253 - L261 were not covered by tests
}

// BdevLvolGet gets information about lvol bdevs if a name is not specified.
//
// "name": Optional. UUID or alias of a logical volume (lvol) bdev.
Expand Down
Loading