Created
January 14, 2013 18:18
-
-
Save craigtracey/4532074 to your computer and use it in GitHub Desktop.
Puppet fact to handle Xen device offsets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'facter' | |
def get_xen_ephemeral_device(index) | |
dev = Facter.value("ec2_block_device_mapping_ephemeral#{index}") | |
if !dev.nil? | |
xendev = "xvd",(dev[2] + 4).chr | |
if dev.length > 3 | |
xendev = format("%s%s", xendev, dev[3, dev.length]) | |
end | |
return xendev | |
else | |
xendev = nil | |
end | |
end | |
if system 'lsmod | grep xen_blkfront >> /dev/null' | |
`uname -r` =~ /(\d)\.(\d)\.(\d+)/ | |
if Integer($1) == 2 and Integer($2) == 6 and Integer($3) >= 32 | |
(0..8).each { |i| | |
Facter.add("ec2_xen_block_device_mapping_ephemeral#{i}") do | |
setcode do | |
dev = get_xen_ephemeral_device(i) | |
end | |
end | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment