Class: UbuntuAmi

Inherits:
Object
  • Object
show all
Defined in:
lib/ubuntu_ami.rb

Instance Method Summary collapse

Constructor Details

#initialize(release) ⇒ UbuntuAmi

Returns a new instance of UbuntuAmi.



23
24
25
# File 'lib/ubuntu_ami.rb', line 23

def initialize(release)
  @uri = "http://uec-images.ubuntu.com/query/#{release}/server/released.current.txt"
end

Instance Method Details

#arch_size(arch) ⇒ Object



27
28
29
# File 'lib/ubuntu_ami.rb', line 27

def arch_size(arch)
  arch =~ /amd64/ ? "large" : "small"
end

#disk_store(store) ⇒ Object



31
32
33
# File 'lib/ubuntu_ami.rb', line 31

def disk_store(store)
  "_ebs" if store =~ /ebs/
end

#region_fix(region) ⇒ Object



35
36
37
# File 'lib/ubuntu_ami.rb', line 35

def region_fix(region)
  region.gsub(/-1/,'').gsub(/-/,'_')
end

#runObject



39
40
41
42
43
44
45
46
47
# File 'lib/ubuntu_ami.rb', line 39

def run
  amis = {}
  open(@uri).each do |a|
    key = a.split[4..6]
    ami = a.split[7]
    amis["#{region_fix(key[2])}_#{arch_size(key[1])}#{disk_store(key[0])}"] = ami
  end
  amis
end