Skip to content

Commit

Permalink
disk: support different drivers
Browse files Browse the repository at this point in the history
Longhorn 7672

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Feb 19, 2024
1 parent e2f66cc commit 2b151ec
Show file tree
Hide file tree
Showing 14 changed files with 663 additions and 105 deletions.
1 change: 1 addition & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func ProtoEngineToEngine(e *spdkrpc.Engine) *Engine {

type DiskInfo struct {
ID string
Name string
UUID string
Path string
Type string
Expand Down
24 changes: 14 additions & 10 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (c *SPDKClient) ReplicaRestoreStatus(replicaName string) (*spdkrpc.ReplicaR

// DiskCreate creates a disk with the given name and path.
// diskUUID is optional, if not provided, it indicates the disk is newly added.
func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath string, blockSize int64) (*spdkrpc.Disk, error) {
func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath, diskDriver string, blockSize int64) (*spdkrpc.Disk, error) {
if diskName == "" || diskPath == "" {
return nil, fmt.Errorf("failed to create disk: missing required parameters")
}
Expand All @@ -692,14 +692,15 @@ func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath string, blockSize i
defer cancel()

return client.DiskCreate(ctx, &spdkrpc.DiskCreateRequest{
DiskName: diskName,
DiskUuid: diskUUID,
DiskPath: diskPath,
BlockSize: blockSize,
DiskName: diskName,
DiskUuid: diskUUID,
DiskPath: diskPath,
BlockSize: blockSize,
DiskDriver: diskDriver,
})
}

func (c *SPDKClient) DiskGet(diskName string) (*spdkrpc.Disk, error) {
func (c *SPDKClient) DiskGet(diskName, diskPath, diskDriver string) (*spdkrpc.Disk, error) {
if diskName == "" {
return nil, fmt.Errorf("failed to get disk info: missing required parameter")
}
Expand All @@ -709,11 +710,13 @@ func (c *SPDKClient) DiskGet(diskName string) (*spdkrpc.Disk, error) {
defer cancel()

return client.DiskGet(ctx, &spdkrpc.DiskGetRequest{
DiskName: diskName,
DiskName: diskName,
DiskPath: diskPath,
DiskDriver: diskDriver,
})
}

func (c *SPDKClient) DiskDelete(diskName, diskUUID string) error {
func (c *SPDKClient) DiskDelete(diskName, diskUUID, diskDriver string) error {
if diskName == "" || diskUUID == "" {
return fmt.Errorf("failed to delete disk: missing required parameters")
}
Expand All @@ -723,8 +726,9 @@ func (c *SPDKClient) DiskDelete(diskName, diskUUID string) error {
defer cancel()

_, err := client.DiskDelete(ctx, &spdkrpc.DiskDeleteRequest{
DiskName: diskName,
DiskUuid: diskUUID,
DiskName: diskName,
DiskUuid: diskUUID,
DiskDriver: diskDriver,
})
return err
}
Loading

0 comments on commit 2b151ec

Please sign in to comment.