Class: Skewer::Rackspace::Images

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeImages

Returns a new instance of Images.



6
7
8
9
10
11
12
# File 'lib/rackspace/images.rb', line 6

def initialize
  @distributions = {
    'ubuntu1004' => { :id => 112, :name => "Ubuntu 10.04 LTS"},
    'ubuntu1104' => { :id => 115, :name => "Ubuntu 11.04"},
    'ubuntu1110' => { :id => 119, :name => "Ubuntu 11.10"},
  }
end

Instance Attribute Details

#distributionsObject (readonly)

Returns the value of attribute distributions.



4
5
6
# File 'lib/rackspace/images.rb', line 4

def distributions
  @distributions
end

Instance Method Details

#get_id(name) ⇒ Object

If provided a name for an image, give back the ID.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rackspace/images.rb', line 15

def get_id(name)
  if name.nil?
    return @distributions['ubuntu1004'][:id]
  end
  name = Integer(name) rescue name

  if name.class == Fixnum
    return name
  end

  unless name.class == String
    return @distributions['ubuntu1004'][:id]
  end

  unless @distributions.has_key?(name)
    raise "An image with the name '#{name}' doesn't exist"
  end
  @distributions[name][:id]
end