Module: OpenNebula

Defined in:
lib/fog/bin/opennebula.rb

Overview

deviates from other bin stuff to accomodate gem

Class Method Summary collapse

Class Method Details

.[](service) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/bin/opennebula.rb', line 13

def [](service)
  @@connections ||= Hash.new do |hash, key|
    hash[key] = case key
    when :compute
      Fog::Logger.warning("OpenNebula[:compute] is not recommended, use Compute[:opennebula] for portability")
      Fog::Compute.new(:provider => 'OpenNebula')
    else
      raise ArgumentError, "Unrecognized service: #{key.inspect}"
    end
  end
  @@connections[service]
end

.available?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/bin/opennebula.rb', line 26

def available?
  begin
    availability=true unless Gem::Specification::find_by_name("opennebula").nil?
  rescue Gem::LoadError
    availability=false
  rescue
    availability_gem=Gem.available?("opennebula")
  end

  if availability
    for service in services
      for collection in self.class_for(service).collections
        unless self.respond_to?(collection)
          self.class_eval <<-EOS, __FILE__, __LINE__
            def self.#{collection}
              self[:#{service}].#{collection}
            end
          EOS
        end
      end
    end
  end
  availability
end

.class_for(key) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/fog/bin/opennebula.rb', line 4

def class_for(key)
  case key
  when :compute
    Fog::Compute::OpenNebula
  else
    raise ArgumentError, "Unrecognized service: #{key}"
  end
end

.collectionsObject



51
52
53
# File 'lib/fog/bin/opennebula.rb', line 51

def collections
  services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
end

.servicesObject



55
56
57
# File 'lib/fog/bin/opennebula.rb', line 55

def services
  Fog::OpenNebula.services
end