class Koma::Backend::Base

Attributes

host[R]
inventory_keys[R]
options[R]

Public Class Methods

new(host, options) click to toggle source
# File lib/koma/backend/base.rb, line 6
def initialize(host, options)
  @host = host
  @options = options
  @inventory_keys = Koma::HostInventory.inventory_keys
end

Public Instance Methods

out(key = nil) click to toggle source
# File lib/koma/backend/base.rb, line 12
def out(key = nil)
  out = {}
  keys = if key.nil?
           inventory_keys
         else
           key.split(',')
         end
  Koma::HostInventory.disabled_keys.each do |k|
    keys.push(k) if @options["enable-#{k}"]
  end

  keys.each do |k|
    raise Koma::NotImplementedKeyError unless Koma::HostInventory.all_inventory_keys.include?(k)
    begin
      out[k] = Specinfra.backend.host_inventory[k]
      out[k] = Specinfra.backend.host_inventory[k].inspect if k == 'ec2'
    rescue NotImplementedError
      out[k] = nil
    end
  end
  out
end