Skip to content

Commit

Permalink
Added attribute support for volume attachment. Recent aws updates als…
Browse files Browse the repository at this point in the history
…o called for fix to volume attchment process
  • Loading branch information
Curtis Stewart committed Feb 7, 2013
1 parent 982ff8f commit 0893799
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
18 changes: 18 additions & 0 deletions libraries/block_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ def self.translate_device_names(devices, skip = 0)
end
end

def self.available_device_id(range_regex)
current_devices = range_regex ? Dir.glob("#{range_regex}*") : Dir.glob('/dev/xvd*')
if current_devices.empty?
range = "#{range_regex}"
range.slice!('/dev/xvd')
range.slice!('[')
range.slice!(']')
devid = range[0,1]
else
last_device = current_devices.sort.last
last_device.slice!('/dev/xvd')
devid = last_device[0,1].succ
if devid == 'b'
devid.succ
end
end
end

def self.on_kvm?
`cat /proc/cpuinfo`.match(/QEMU/)
end
Expand Down
2 changes: 1 addition & 1 deletion recipes/raids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
node[:ebs][:raids].each do |device, options|
disks = []
if !options[:disks] && options[:num_disks]
next_mount = Dir.glob('/dev/xvd?').sort.last[-1,1].succ
next_mount = BlockDevice.available_device_id(node[:ebs][:block_range_regex])
1.upto(options[:num_disks].to_i) do |i|
disks << mount = "/dev/sd#{next_mount}"
next_mount = next_mount.succ
Expand Down
3 changes: 2 additions & 1 deletion recipes/volumes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node[:ebs][:volumes].each do |mount_point, options|
if !options[:device] && options[:size]
credentials = Chef::EncryptedDataBagItem.load(node[:ebs][:creds][:databag], node[:ebs][:creds][:item])
devid = Dir.glob('/dev/xvd?').sort.last[-1,1].succ

devid = BlockDevice.available_device_id(node[:ebs][:block_range_regex])
device = "/dev/sd#{devid}"

vol = aws_ebs_volume device do
Expand Down

0 comments on commit 0893799

Please sign in to comment.