Skip to content

Commit

Permalink
lxd: Rename GetStoragePoolVolumes to GetStorageVolumes
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <pedro.ribeiro@canonical.com>
  • Loading branch information
hamistao committed Apr 19, 2024
1 parent 4d9b022 commit 39cf55f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lxd/db/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestImportPreClusteringData(t *testing.T) {
PoolID: &id,
}}

dbVolumes, err = tx.GetStoragePoolVolumes(context.Background(), true, filters...)
dbVolumes, err = tx.GetStorageVolumes(context.Background(), true, filters...)
if err != nil {
return fmt.Errorf("Failed loading storage volumes: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions lxd/db/storage_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ WHERE storage_volumes.id = ?
return response, nil
}

// StorageVolumeFilter used for filtering storage volumes with GetStoragePoolVolumes().
// StorageVolumeFilter used for filtering storage volumes with GetStorageVolumes().
type StorageVolumeFilter struct {
Type *int
Project *string
Expand All @@ -126,11 +126,11 @@ type StorageVolume struct {
ID int64
}

// GetStoragePoolVolumes returns all storage volumes.
// GetStorageVolumes returns all storage volumes.
// If there are no volumes, it returns an empty list and no error.
// Accepts filters for narrowing down the results returned. If memberSpecific is true, then the search is
// restricted to volumes that belong to this member or belong to all members.
func (c *ClusterTx) GetStoragePoolVolumes(ctx context.Context, memberSpecific bool, filters ...StorageVolumeFilter) ([]*StorageVolume, error) {
func (c *ClusterTx) GetStorageVolumes(ctx context.Context, memberSpecific bool, filters ...StorageVolumeFilter) ([]*StorageVolume, error) {
var q = &strings.Builder{}
args := []any{}

Expand Down Expand Up @@ -261,7 +261,7 @@ func (c *ClusterTx) GetStoragePoolVolume(ctx context.Context, poolID int64, proj
PoolID: &poolID,
}}

volumes, err := c.GetStoragePoolVolumes(ctx, memberSpecific, filters...)
volumes, err := c.GetStorageVolumes(ctx, memberSpecific, filters...)
volumesLen := len(volumes)
if (err == nil && volumesLen <= 0) || errors.Is(err, sql.ErrNoRows) {
return nil, api.StatusErrorf(http.StatusNotFound, "Storage volume not found")
Expand Down
8 changes: 4 additions & 4 deletions lxd/patches.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ func patchZfsSetContentTypeUserProperty(name string, d *Daemon) error {
}

// Get the pool's custom storage volumes.
customVolumes, err := tx.GetStoragePoolVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{PoolID: &poolID})
customVolumes, err := tx.GetStorageVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{PoolID: &poolID})
if err != nil {
return fmt.Errorf("Failed getting custom storage volumes of pool %q: %w", pool, err)
}
Expand Down Expand Up @@ -979,7 +979,7 @@ func patchStorageZfsUnsetInvalidBlockSettings(_ string, d *Daemon) error {
}

// Get the pool's custom storage volumes.
volumes, err := tx.GetStoragePoolVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{Type: &volTypeVM}, db.StorageVolumeFilter{PoolID: &poolID})
volumes, err := tx.GetStorageVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{Type: &volTypeVM}, db.StorageVolumeFilter{PoolID: &poolID})
if err != nil {
return fmt.Errorf("Failed getting custom storage volumes of pool %q: %w", pool, err)
}
Expand Down Expand Up @@ -1097,7 +1097,7 @@ func patchStorageZfsUnsetInvalidBlockSettingsV2(_ string, d *Daemon) error {
}

// Get the pool's custom storage volumes.
volumes, err := tx.GetStoragePoolVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{Type: &volTypeVM}, db.StorageVolumeFilter{PoolID: &poolID})
volumes, err := tx.GetStorageVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{Type: &volTypeVM}, db.StorageVolumeFilter{PoolID: &poolID})
if err != nil {
return fmt.Errorf("Failed getting custom storage volumes of pool %q: %w", pool, err)
}
Expand Down Expand Up @@ -1338,7 +1338,7 @@ func patchStorageRenameCustomISOBlockVolumesV2(name string, d *Daemon) error {
}

// Get the pool's custom storage volumes.
customVolumes, err := tx.GetStoragePoolVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{PoolID: &poolID})
customVolumes, err := tx.GetStorageVolumes(ctx, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{PoolID: &poolID})
if err != nil {
return fmt.Errorf("Failed getting custom storage volumes of pool %q: %w", pool, err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func UsedBy(ctx context.Context, s *state.State, pool Pool, firstOnly bool, memb

err = s.DB.Cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
// Get all the volumes using the storage pool.
volumes, err := tx.GetStoragePoolVolumes(ctx, memberSpecific)
volumes, err := tx.GetStorageVolumes(ctx, memberSpecific)
if err != nil {
return fmt.Errorf("Failed loading storage volumes: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/storage_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func storagePoolDelete(d *Daemon, r *http.Request) response.Response {
// Only image volumes should remain now.
id := pool.ID() // Create local variable to get the pointer.

volumes, err := tx.GetStoragePoolVolumes(ctx, true, db.StorageVolumeFilter{PoolID: &id})
volumes, err := tx.GetStorageVolumes(ctx, true, db.StorageVolumeFilter{PoolID: &id})
if err != nil {
return fmt.Errorf("Failed loading storage volumes: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions lxd/storage_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ func storagePoolVolumesGet(d *Daemon, r *http.Request) response.Response {
}

if allPools {
dbVolumes, err = tx.GetStoragePoolVolumes(ctx, memberSpecific, filters...)
dbVolumes, err = tx.GetStorageVolumes(ctx, memberSpecific, filters...)
if err != nil {
return fmt.Errorf("Failed loading storage volumes: %w", err)
}
Expand All @@ -702,7 +702,7 @@ func storagePoolVolumesGet(d *Daemon, r *http.Request) response.Response {

filters = append(filters, poolFilter)

dbVolumes, err = tx.GetStoragePoolVolumes(ctx, memberSpecific, filters...)
dbVolumes, err = tx.GetStorageVolumes(ctx, memberSpecific, filters...)
if err != nil {
return fmt.Errorf("Failed loading storage volumes: %w", err)
}
Expand Down

0 comments on commit 39cf55f

Please sign in to comment.