get volume
diff --git a/acceptance/openstack/blockstorage_test.go b/acceptance/openstack/blockstorage_test.go
index 2aef3d4..11025a0 100644
--- a/acceptance/openstack/blockstorage_test.go
+++ b/acceptance/openstack/blockstorage_test.go
@@ -60,7 +60,7 @@
t.Error(err)
return
}
- v, err := volumes.Create(client, volumes.CreateOpts{
+ nv, err := volumes.Create(client, volumes.CreateOpts{
"size": 1,
"display_name": "test-volume",
})
@@ -68,10 +68,19 @@
t.Error(err)
return
}
+
defer func() {
err = volumes.Delete(client, volumes.DeleteOpts{
- "id": v.Id,
+ "id": nv.Id,
})
}()
- fmt.Printf("%+v\n", v)
+
+ gv, err := volumes.Get(client, volumes.GetOpts{
+ "id": nv.Id,
+ })
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ fmt.Printf("%+v\n", gv)
}
diff --git a/openstack/blockstorage/v1/volumes/requests.go b/openstack/blockstorage/v1/volumes/requests.go
index a6d51fb..5dcbca0 100644
--- a/openstack/blockstorage/v1/volumes/requests.go
+++ b/openstack/blockstorage/v1/volumes/requests.go
@@ -24,6 +24,22 @@
return v, err
}
+func Get(c *blockstorage.Client, opts GetOpts) (Volume, error) {
+ var v Volume
+ h, err := c.GetHeaders()
+ if err != nil {
+ return v, err
+ }
+ url := c.GetVolumeURL(opts["id"])
+ _, err = perigee.Request("GET", url, perigee.Options{
+ Results: &struct {
+ Volume *Volume `json:"volume"`
+ }{&v},
+ MoreHeaders: h,
+ })
+ return v, err
+}
+
func Delete(c *blockstorage.Client, opts DeleteOpts) error {
h, err := c.GetHeaders()
if err != nil {
diff --git a/openstack/blockstorage/v1/volumes/volumes.go b/openstack/blockstorage/v1/volumes/volumes.go
index 77f19af..741e4bf 100644
--- a/openstack/blockstorage/v1/volumes/volumes.go
+++ b/openstack/blockstorage/v1/volumes/volumes.go
@@ -16,4 +16,5 @@
Size int
}
type CreateOpts map[string]interface{}
+type GetOpts map[string]string
type DeleteOpts map[string]string