Method: Beaker::OpenStack#provision_storage
- Defined in:
- lib/beaker/hypervisor/openstack.rb
#provision_storage(host, vm) ⇒ Object
Create and attach dynamic volumes
Creates an array of volumes and attaches them to the current host. The host bus type is determined by the image type, so by default devices appear as /dev/vdb, /dev/vdc etc. Setting the glance properties hw_disk_bus=scsi, hw_scsi_model=virtio-scsi will present them as /dev/sdb, /dev/sdc (or 2:0:0:1, 2:0:0:2 in SCSI addresses)
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/beaker/hypervisor/openstack.rb', line 135 def provision_storage host, vm if host['volumes'] # Lazily create the volume client if needed volume_client_create host['volumes'].keys.each_with_index do |volume, index| @logger.debug "Creating volume #{volume} for OpenStack host #{host.name}" # The node defintion file defines volume sizes in MB (due to precedent # with the vagrant virtualbox implementation) however OpenStack requires # this translating into GB openstack_size = host['volumes'][volume]['size'].to_i / 1000 # Create the volume and wait for it to become available vol = @volume_client.volumes.create( :size => openstack_size, :display_name => volume, :description => "Beaker volume: host=#{host.name} volume=#{volume}", ) vol.wait_for { ready? } # Fog needs a device name to attach as, so invent one. The guest # doesn't pay any attention to this device = "/dev/vd#{('b'.ord + index).chr}" vm.attach_volume(vol.id, device) end end end |