Adds block storage extend's action support (#67)
* created Godeps dependency tree
* added vendor folder to gitignore
* added support for extend size action to volumes's client
* Revert "created Godeps dependency tree"
This reverts commit b9366e292c2e99e262240b98151c98f49c69df32.
* Revert "added vendor folder to gitignore"
This reverts commit 34403f85dad4f0514d7e0d8ce882b1712b82cd87.
* set volumeactions.ExtendSizeOpts.NewSize as required
diff --git a/openstack/blockstorage/v2/extensions/volumeactions/requests.go b/openstack/blockstorage/v2/extensions/volumeactions/requests.go
index 05a76f7..d2a2c79 100644
--- a/openstack/blockstorage/v2/extensions/volumeactions/requests.go
+++ b/openstack/blockstorage/v2/extensions/volumeactions/requests.go
@@ -172,3 +172,36 @@
})
return
}
+
+// ExtendSizeOptsBuilder allows extensions to add additional parameters to the
+// ExtendSize request.
+type ExtendSizeOptsBuilder interface {
+ ToVolumeExtendSizeMap() (map[string]interface{}, error)
+}
+
+// ExtendSizeOpts contain options for extending the size of an existing Volume. This object is passed
+// to the volumes.ExtendSize function.
+type ExtendSizeOpts struct {
+ // NewSize is the new size of the volume, in GB
+ NewSize int `json:"new_size" required:"true"`
+}
+
+// ToVolumeExtendSizeMap assembles a request body based on the contents of an
+// ExtendSizeOpts.
+func (opts ExtendSizeOpts) ToVolumeExtendSizeMap() (map[string]interface{}, error) {
+ return gophercloud.BuildRequestBody(opts, "os-extend")
+}
+
+// ExtendSize will extend the size of the volume based on the provided information.
+// This operation does not return a response body.
+func ExtendSize(client *gophercloud.ServiceClient, id string, opts ExtendSizeOptsBuilder) (r ExtendSizeResult) {
+ b, err := opts.ToVolumeExtendSizeMap()
+ if err != nil {
+ r.Err = err
+ return
+ }
+ _, r.Err = client.Post(extendSizeURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{202},
+ })
+ return
+}