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

US69000: Adding support for new volume attributes in schema #217

Merged
merged 6 commits into from
Sep 2, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/golangci/golangci-lint v1.58.2
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/hewlettpackard/hpegl-metal-client v1.5.19
github.com/hewlettpackard/hpegl-metal-client v1.5.21
github.com/hewlettpackard/hpegl-provider-lib v0.0.18
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hewlettpackard/hpegl-metal-client v1.5.19 h1:Y3RizmAi5H+RtzdozDywUg/0/aupDltW5b+HrzgIQeQ=
github.com/hewlettpackard/hpegl-metal-client v1.5.19/go.mod h1:+BO4BfQXf3IWnsxvk2IdE27Ijrm1jDVYIgpebYh1L9M=
github.com/hewlettpackard/hpegl-metal-client v1.5.21 h1:3/9hC2eByX9NpPUd9+0IM7axw4nlG9izyBqWaVc3RTA=
github.com/hewlettpackard/hpegl-metal-client v1.5.21/go.mod h1:+BO4BfQXf3IWnsxvk2IdE27Ijrm1jDVYIgpebYh1L9M=
github.com/hewlettpackard/hpegl-provider-lib v0.0.18 h1:87iXgq8Oe2ebBRicL5K+HknQF9e1ce6MHfIHeTVVqlI=
github.com/hewlettpackard/hpegl-provider-lib v0.0.18/go.mod h1:Bw2DhefBjqXQI6s5vBBGiWUkFz7fx4KkbGfwmo9wv3U=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
Expand Down
97 changes: 81 additions & 16 deletions internal/resources/resource_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@ import (
)

const (
vName = "name"
vDescription = "description"
vLocation = "location"
vLocationID = "location_id"
vFlavorID = "flavor_id"
vFlavor = "flavor"
vSize = "size"
vShareable = "shareable"
vState = "state"
vStatus = "status"
vLabels = "labels"
vWWN = "wwn"
vStoragePool = "storage_pool"
vStoragePoolID = "storage_pool_id"
vCollection = "volume_collection"
vCollectionID = "volume_collection_id"
vName = "name"
vDescription = "description"
vLocation = "location"
vLocationID = "location_id"
vFlavorID = "flavor_id"
vFlavor = "flavor"
vSize = "size"
vSizeInUse = "size_in_use"
vShareable = "shareable"
vState = "state"
vStatus = "status"
vLabels = "labels"
vWWN = "wwn"
vStoragePool = "storage_pool"
vStoragePoolID = "storage_pool_id"
vCollection = "volume_collection"
vCollectionID = "volume_collection_id"
vUnManaged = "unmanaged"
vActiveSite = "active_site"
vCreatedSite = "created_site"
vReplicationEnabled = "replication_enabled"

// volume Info constants.
vID = "id"
Expand Down Expand Up @@ -100,6 +105,14 @@ func volumeSchema() map[string]*schema.Schema {
},
},

vSizeInUse: {
Type: schema.TypeFloat,
Required: false,
Optional: false,
Computed: true,
Description: "The amount of the volume currently used as reported by the array in GBytes.",
mchuang3 marked this conversation as resolved.
Show resolved Hide resolved
},

vShareable: {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -157,6 +170,38 @@ func volumeSchema() map[string]*schema.Schema {
Computed: true,
Description: "The volume collection ID of the volume to be created.",
},

vUnManaged: {
Type: schema.TypeBool,
Required: false,
Optional: false,
Computed: true,
Description: "Indicates whether the volume is a native Metal created one or an external one.",
},

vReplicationEnabled: {
Type: schema.TypeBool,
Required: false,
Optional: false,
Computed: true,
Description: "Indicates whether replication is enabled for this volume.",
},

vActiveSite: {
Type: schema.TypeString,
Required: false,
Optional: false,
Computed: true,
Description: "The site where the remote copy role for the volume is Primary at the time of most recent import.",
},

vCreatedSite: {
Type: schema.TypeString,
Required: false,
Optional: false,
Computed: true,
Description: "The site where the volume was originally created.",
},
}
}

Expand Down Expand Up @@ -326,6 +371,26 @@ func resourceMetalVolumeRead(d *schema.ResourceData, meta interface{}) (err erro
return fmt.Errorf("set Size: %v", err)
}

if err = d.Set(vSizeInUse, math.Round(float64(volume.CapacityUsed)/KiBToGBConversion)); err != nil {
mchuang3 marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("set %s : %v", vSizeInUse, err)
}

if err := d.Set(vActiveSite, volume.ActiveSite); err != nil {
return fmt.Errorf("set %s : %v", vActiveSite, err)
}

if err := d.Set(vCreatedSite, volume.CreatedSite); err != nil {
return fmt.Errorf("set %s : %v", vCreatedSite, err)
}

if err := d.Set(vUnManaged, volume.UnmanagedVolume); err != nil {
return fmt.Errorf("set %s : %v", vUnManaged, err)
}

if err := d.Set(vReplicationEnabled, volume.ReplicationEnabled); err != nil {
return fmt.Errorf("set %s : %v", vReplicationEnabled, err)
}

d.Set(vName, volume.Name)
d.Set(vDescription, volume.Description)
flavorName, _ := p.GetVolumeFlavorName(volume.FlavorID)
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.59
1.3.61
Loading