fog/fog — pull request #3189 by smashwilson (2014-10-01 21:23:50+00:00)
Title: [rackspace] Boot from volume

This adds the ability to boot Rackspace servers from a volume, including:

* Creating a bootable volume from an image explicitly, then creating a server referencing that volume id;
* Creating a server and a bootable volume at once from an image id; and
* Specifying arbitrary custom volume mounts explicitly in a `create_server` request.

Here's some example code:

```ruby
block = Fog::Rackspace::BlockStorage.new(rackspace_username: '' ... )
compute = Fog::Compute.new(provider: :rackspace

image_id = compute.images.find { |i| i.name =~ /Ubuntu/ }.id
flavor_id = compute.flavors.find { |f| f.name =~ /Performance/ }.id

# Two-step with explicit volume creation
volume = block.volumes.create size: 100, image_id: image_id
volume.wait_for { ready? }
server = compute.servers.create name: 'two-step', image_id: '', flavor_id: flavor_id, boot_volume_id: volume.id

# One-step with implicit volume creation
server = compute.servers.create name: 'one-step', image_id: '', flavor_id: flavor_id, boot_image_id: image_id

# Direct server request with explicit volume initialization
compute.create_server 'explicit', '', flavor_id, 1, 1, block_device_mapping: [
{
"device_name" => "/dev/sdb1",
"source_type" => "blank",
"destination_type" => "local",
"delete_on_termination" => "True",
"guest_format" => "swap",
"boot_index" => "-1"
},
{
"device_name" => "/dev/sda1",
"source_type" => "volume",
"destination_type" => "volume",
"uuid" => "fake-volume-id-1",
"boot_index" => "0"
}
]
```

Here's the Openstack reference for it: http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-block-device-mapping-v2-boot

/cc @mdarby