BlockDevice -> []BlockDevice in CreateOpts
diff --git a/rackspace/compute/v2/bootfromvolume/delegate.go b/rackspace/compute/v2/bootfromvolume/delegate.go
index 636ced6..2580459 100644
--- a/rackspace/compute/v2/bootfromvolume/delegate.go
+++ b/rackspace/compute/v2/bootfromvolume/delegate.go
@@ -1,12 +1,12 @@
package bootfromvolume
import (
- "github.com/rackspace/gophercloud"
- osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
- osServers "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
+ "github.com/rackspace/gophercloud"
+ osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
+ osServers "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
)
// Create requests the creation of a server from the given block device mapping.
-func Create(client *gophercloud.ServiceClient, opts osServers.CreateOptsBuilder) osBFV.CreateResult {
- return osBFV.Create(client, opts)
+func Create(client *gophercloud.ServiceClient, opts osServers.CreateOptsBuilder) osServers.CreateResult {
+ return osBFV.Create(client, opts)
}
diff --git a/rackspace/compute/v2/bootfromvolume/delegate_test.go b/rackspace/compute/v2/bootfromvolume/delegate_test.go
index 794f0c8..0b53527 100644
--- a/rackspace/compute/v2/bootfromvolume/delegate_test.go
+++ b/rackspace/compute/v2/bootfromvolume/delegate_test.go
@@ -17,11 +17,13 @@
ext := osBFV.CreateOptsExt{
CreateOptsBuilder: base,
- BlockDevice: osBFV.BlockDevice{
- UUID: "123456",
- SourceType: "image",
- DestinationType: "volume",
- VolumeSize: 10,
+ BlockDevice: []osBFV.BlockDevice{
+ osBFV.BlockDevice{
+ UUID: "123456",
+ SourceType: osBFV.Image,
+ DestinationType: "volume",
+ VolumeSize: 10,
+ },
},
}
diff --git a/rackspace/compute/v2/servers/requests.go b/rackspace/compute/v2/servers/requests.go
index 4f40e83..144e837 100644
--- a/rackspace/compute/v2/servers/requests.go
+++ b/rackspace/compute/v2/servers/requests.go
@@ -55,7 +55,7 @@
// BlockDevice [optional] will create the server from a volume, which is created from an image,
// a snapshot, or an another volume.
- BlockDevice bootfromvolume.BlockDevice
+ BlockDevice []bootfromvolume.BlockDevice
}
// ToServerCreateMap constructs a request body using all of the OpenStack extensions that are
@@ -89,9 +89,16 @@
serverMap := res["server"].(map[string]interface{})
serverMap["key_name"] = opts.KeyPair
- var bd bootfromvolume.BlockDevice
- if opts.BlockDevice != bd {
- serverMap["block_device_mapping_v2"] = []bootfromvolume.BlockDevice{opts.BlockDevice}
+ if len(opts.BlockDevice) != 0 {
+ bfv := bootfromvolume.CreateOptsExt{
+ CreateOptsBuilder: drive,
+ BlockDevice: opts.BlockDevice,
+ }
+
+ res, err = bfv.ToServerCreateMap()
+ if err != nil {
+ return nil, err
+ }
}
return res, nil