Class: Specinfra::HostInventory

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/specinfra/host_inventory.rb,
lib/specinfra/host_inventory/cpu.rb,
lib/specinfra/host_inventory/ec2.rb,
lib/specinfra/host_inventory/fqdn.rb,
lib/specinfra/host_inventory/domain.rb,
lib/specinfra/host_inventory/memory.rb,
lib/specinfra/host_inventory/hostname.rb,
lib/specinfra/host_inventory/platform.rb,
lib/specinfra/host_inventory/filesystem.rb,
lib/specinfra/host_inventory/platform_version.rb

Defined Under Namespace

Classes: Cpu, Domain, Ec2, Filesystem, Fqdn, Hostname, Memory, Platform, PlatformVersion

Instance Method Summary collapse

Constructor Details

#initializeHostInventory

Returns a new instance of HostInventory.



15
16
17
18
# File 'lib/specinfra/host_inventory.rb', line 15

def initialize
  property[:host_inventory] ||= {}
  @inventory = property[:host_inventory]
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/specinfra/host_inventory.rb', line 20

def [](key)
  @inventory[key.to_sym] ||= {}
  if @inventory[key.to_sym].empty?
    begin
      inventory_class = Specinfra::HostInventory.const_get(key.to_s.to_camel_case)
      @inventory[key.to_sym] = inventory_class.get
    rescue
      @inventory[key.to_sym] = nil
    end
  end
  @inventory[key.to_sym]
end