Merge pull request #338 from jrperritt/bfv-bug
BFV bug
diff --git a/acceptance/rackspace/compute/v2/bootfromvolume_test.go b/acceptance/rackspace/compute/v2/bootfromvolume_test.go
index c8c8e21..d7e6aa7 100644
--- a/acceptance/rackspace/compute/v2/bootfromvolume_test.go
+++ b/acceptance/rackspace/compute/v2/bootfromvolume_test.go
@@ -41,6 +41,9 @@
}).Extract()
th.AssertNoErr(t, err)
t.Logf("Created server: %+v\n", server)
- //defer deleteServer(t, client, server)
- t.Logf("Deleting server [%s]...", name)
+ defer deleteServer(t, client, server)
+
+ getServer(t, client, server)
+
+ listServers(t, client)
}
diff --git a/openstack/compute/v2/servers/results.go b/openstack/compute/v2/servers/results.go
index 3a145f8..d63d7c8 100644
--- a/openstack/compute/v2/servers/results.go
+++ b/openstack/compute/v2/servers/results.go
@@ -1,6 +1,8 @@
package servers
import (
+ "reflect"
+
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -20,8 +22,21 @@
Server Server `mapstructure:"server"`
}
- err := mapstructure.Decode(r.Body, &response)
- return &response.Server, err
+ config := &mapstructure.DecoderConfig{
+ DecodeHook: toMapFromString,
+ Result: &response,
+ }
+ decoder, err := mapstructure.NewDecoder(config)
+ if err != nil {
+ return nil, err
+ }
+
+ err = decoder.Decode(r.Body)
+ if err != nil {
+ return nil, err
+ }
+
+ return &response.Server, nil
}
// CreateResult temporarily contains the response from a Create call.
@@ -164,7 +179,19 @@
var response struct {
Servers []Server `mapstructure:"servers"`
}
- err := mapstructure.Decode(casted, &response)
+
+ config := &mapstructure.DecoderConfig{
+ DecodeHook: toMapFromString,
+ Result: &response,
+ }
+ decoder, err := mapstructure.NewDecoder(config)
+ if err != nil {
+ return nil, err
+ }
+
+ err = decoder.Decode(casted)
+
+ //err := mapstructure.Decode(casted, &response)
return response.Servers, err
}
@@ -235,3 +262,10 @@
err := mapstructure.Decode(r.Body, &response)
return response.Metadatum, err
}
+
+func toMapFromString(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error) {
+ if (from == reflect.String) && (to == reflect.Map) {
+ return map[string]interface{}{}, nil
+ }
+ return data, nil
+}