Skip to content

Commit

Permalink
Merge pull request #11 from orgsync-cookbooks/fix-ephemeral-helper
Browse files Browse the repository at this point in the history
Make EphemeralLvm::Helper support all EC2 instance types
  • Loading branch information
douglaswth committed Feb 14, 2014
2 parents 49364fe + abfbd6a commit 5066046
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def self.get_ephemeral_devices(cloud, node)
#
def self.fix_device_mapping(devices, node_block_devices)
devices.map! do |device|
if node_block_devices.include?(device.match(/\/dev\/([a-z]+)$/)[1])
if node_block_devices.include?(device.match(/\/dev\/(.+)$/)[1])
device
else
fixed_device = device.sub("/sd", "/xvd")
if node_block_devices.include?(fixed_device.match(/\/dev\/([a-z]+)$/)[1])
if node_block_devices.include?(fixed_device.match(/\/dev\/(.+)$/)[1])
fixed_device
else
Chef::Log.warn "could not find ephemeral device: #{device}"
Expand Down
6 changes: 6 additions & 0 deletions spec/ephemeral_lvm_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
EphemeralLvm::Helper.fix_device_mapping(["/dev/sda", "/dev/sdb"], ["xvda"])
).to eq(["/dev/xvda"])
end

it 'map devices with a numeric suffix' do
expect(
EphemeralLvm::Helper.fix_device_mapping(['/dev/sda2'], ['xvda2'])
).to eq(['/dev/xvda2'])
end
end
end

0 comments on commit 5066046

Please sign in to comment.