Skip to content

Commit

Permalink
Merge pull request #111 from dell/storagepool-volumes
Browse files Browse the repository at this point in the history
Add GetStoragePoolVolumes api to get all volumes connected to given s…
  • Loading branch information
alikdell authored May 14, 2024
2 parents a475de1 + f963a6a commit 91f179d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,18 @@ func (c *Client) GetSnapshotPolicy(
sps = append(sps, sp)
return sps, nil
}

// GetStoragePoolVolumes returns list of volumes connected to storage pool Storagepool by ID
func (c *Client) GetStoragePoolVolumes(id string) ([]*types.Volume, error) {
defer TimeSpent("GetStoragePoolByID", time.Now())

path := fmt.Sprintf("/api/instances/StoragePool::%s/relationships/Volume", id)
var storagepoolVolumes []*types.Volume
err := c.getJSONWithRetry(
http.MethodGet, path, nil, &storagepoolVolumes)
if err != nil {
return nil, err
}

return storagepoolVolumes, err
}
26 changes: 26 additions & 0 deletions inttests/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,29 @@ func TestSetCompressionMethod(t *testing.T) {
err = deleteVolume(t, volID)
assert.Nil(t, err)
}

func TestGetStoragePoolVolumes(t *testing.T) {
name := fmt.Sprintf("%s-%s", testPrefix, "instanceCreated")

poolName := getStoragePoolName(t)
assert.NotNil(t, poolName)

pool := getStoragePool(t)
size := fmt.Sprintf("%d", defaultVolumeSize)

volParams := siotypes.VolumeParam{
VolumeSizeInKb: size,
VolumeType: "ThinProvisioned",
Name: name,
}

volResp, err := C.CreateVolume(&volParams, poolName, "")
assert.Nil(t, err)
assert.NotNil(t, volResp)

volumes, err := C.GetStoragePoolVolumes(pool.StoragePool.ID)
assert.Nil(t, err)
assert.NotNil(t, volumes)

deleteVolume(t, volResp.ID)
}

0 comments on commit 91f179d

Please sign in to comment.