1 step 'Extraction'
diff --git a/acceptance/openstack/blockstorage/v1/snapshots_test.go b/acceptance/openstack/blockstorage/v1/snapshots_test.go
index 5038c8e..a792cf2 100644
--- a/acceptance/openstack/blockstorage/v1/snapshots_test.go
+++ b/acceptance/openstack/blockstorage/v1/snapshots_test.go
@@ -24,7 +24,7 @@
if gv.Status == "available" {
return nil
}
- time.Sleep(1 * time.Millisecond)
+ time.Sleep(1 * time.Second)
secondsSlept = secondsSlept + 1
}
@@ -51,6 +51,13 @@
if err != nil {
t.Fatal(err)
}
+ defer func() {
+ err = volumes.Delete(client, cv.ID)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ }()
var sss []*snapshots.Snapshot
for i := 0; i < numSnapshots; i++ {
@@ -63,6 +70,6 @@
}
sss = append(sss, css)
}
-
t.Logf("Created snapshots: %+v\n", sss)
+
}
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 97d0521..cdf5d40 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -56,11 +56,12 @@
return &respBody.Snapshot, nil
}
-func Get(client *gophercloud.ServiceClient, id string) (GetResult, error) {
+func Get(client *gophercloud.ServiceClient, id string) GetResult {
var gr GetResult
_, err := perigee.Request("GET", snapshotURL(client, id), perigee.Options{
- Results: &gr,
+ Results: &gr.r,
MoreHeaders: client.Provider.AuthenticatedHeaders(),
})
- return gr, err
+ gr.err = err
+ return gr
}
diff --git a/openstack/blockstorage/v1/snapshots/results.go b/openstack/blockstorage/v1/snapshots/results.go
index 440b3f8..d8178c1 100644
--- a/openstack/blockstorage/v1/snapshots/results.go
+++ b/openstack/blockstorage/v1/snapshots/results.go
@@ -1,5 +1,11 @@
package snapshots
+import (
+ "fmt"
+
+ "github.com/mitchellh/mapstructure"
+)
+
type Snapshot struct {
CreatedAt string
Description string
@@ -11,4 +17,23 @@
VolumeID string
}
-type GetResult map[string]interface{}
+type GetResult struct {
+ err error
+ r map[string]interface{}
+}
+
+func (gr GetResult) ExtractSnapshot() (*Snapshot, error) {
+ if gr.err != nil {
+ return nil, gr.err
+ }
+
+ var response struct {
+ Snapshot *Snapshot `json:"snapshot"`
+ }
+
+ err := mapstructure.Decode(gr.r, &response)
+ if err != nil {
+ return nil, fmt.Errorf("snapshots: Error decoding snapshot.GetResult: %v", err)
+ }
+ return response.Snapshot, nil
+}