Created
September 4, 2012 18:49
-
-
Save rubiojr/3624915 to your computer and use it in GitHub Desktop.
Upload AMI/AKI/ARI to OpenStack Glance
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
#!/usr/bin/env ruby | |
name = ARGV[0] | |
ids = {} | |
unless name and !name.empty? | |
puts "Usage: upload_ami <image-name>" | |
exit 1 | |
end | |
%w{aki ari}.each do |f| | |
puts "Uploading #{f} image (usually fast)..." | |
`glance add disk_format=#{f} container_format=#{f} name=#{name}-#{f} < #{f} 2>&1`.each_line do |l| | |
if l =~ /Added new image with ID:.*/ | |
ids[f.to_sym] = l.split[-1].chomp.strip | |
puts "#{f.upcase} ID: #{ids[f.to_sym]}" | |
end | |
end | |
end | |
puts "Uploading root image (this may take some time)..." | |
`glance add disk_format=ami container_format=ami name=#{name}-ami kernel_id=#{ids[:aki]} ramdisk_id=#{ids[:ari]} < root.img` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment