diskconfig.Extract* functions.
diff --git a/openstack/compute/v2/extensions/diskconfig/results.go b/openstack/compute/v2/extensions/diskconfig/results.go
new file mode 100644
index 0000000..05a29a8
--- /dev/null
+++ b/openstack/compute/v2/extensions/diskconfig/results.go
@@ -0,0 +1,60 @@
+package diskconfig
+
+import (
+ "github.com/mitchellh/mapstructure"
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
+ "github.com/rackspace/gophercloud/pagination"
+)
+
+func commonExtract(result gophercloud.Result) (*DiskConfig, error) {
+ var resp struct {
+ Server struct {
+ DiskConfig string `mapstructure:"OS-DCF:diskConfig"`
+ } `mapstructure:"server"`
+ }
+
+ err := mapstructure.Decode(result.Body, &resp)
+ if err != nil {
+ return nil, err
+ }
+
+ config := DiskConfig(resp.Server.DiskConfig)
+ return &config, nil
+}
+
+// ExtractGet returns the disk configuration from a servers.Get call.
+func ExtractGet(result servers.GetResult) (*DiskConfig, error) {
+ return commonExtract(result.Result)
+}
+
+// ExtractUpdate returns the disk configuration from a servers.Update call.
+func ExtractUpdate(result servers.UpdateResult) (*DiskConfig, error) {
+ return commonExtract(result.Result)
+}
+
+// ExtractRebuild returns the disk configuration from a servers.Rebuild call.
+func ExtractRebuild(result servers.RebuildResult) (*DiskConfig, error) {
+ return commonExtract(result.Result)
+}
+
+// ExtractDiskConfig returns the DiskConfig setting for a specific server acquired from an
+// servers.ExtractServers call, while iterating through a Pager.
+func ExtractDiskConfig(page pagination.Page, index int) (*DiskConfig, error) {
+ casted := page.(servers.ServerPage).Body
+
+ type server struct {
+ DiskConfig string `mapstructure:"OS-CDF:diskConfig"`
+ }
+ var response struct {
+ Servers []server `mapstructure:"servers"`
+ }
+
+ err := mapstructure.Decode(casted, &response)
+ if err != nil {
+ return nil, err
+ }
+
+ config := DiskConfig(response.Servers[index].DiskConfig)
+ return &config, nil
+}
diff --git a/openstack/compute/v2/extensions/diskconfig/results_test.go b/openstack/compute/v2/extensions/diskconfig/results_test.go
new file mode 100644
index 0000000..adbd031
--- /dev/null
+++ b/openstack/compute/v2/extensions/diskconfig/results_test.go
@@ -0,0 +1,48 @@
+package diskconfig
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
+ th "github.com/rackspace/gophercloud/testhelper"
+ "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func TestExtractGet(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ servers.HandleServerGetSuccessfully(t)
+
+ config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf"))
+ th.AssertNoErr(t, err)
+ th.CheckEquals(t, Manual, *config)
+}
+
+func TestExtractUpdate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ servers.HandleServerUpdateSuccessfully(t)
+
+ r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{
+ Name: "new-name",
+ })
+ config, err := ExtractUpdate(r)
+ th.AssertNoErr(t, err)
+ th.CheckEquals(t, Manual, *config)
+}
+
+func TestExtractRebuild(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ servers.HandleRebuildSuccessfully(t, servers.SingleServerBody)
+
+ r := servers.Rebuild(client.ServiceClient(), "1234asdf", servers.RebuildOpts{
+ Name: "new-name",
+ AdminPass: "swordfish",
+ ImageID: "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
+ AccessIPv4: "1.2.3.4",
+ })
+ config, err := ExtractRebuild(r)
+ th.AssertNoErr(t, err)
+ th.CheckEquals(t, Manual, *config)
+}