class Confer::Inventory

Public: Encapsulates an inventory, which is simply a list of hosts and the credentials and transport mechanisms required to interact with them.

Attributes

hosts[RW]

Public: A Hash of the hosts and their options in this Inventory, indexed by name.

Public Class Methods

from_file(path) click to toggle source

Public: Loads an inventory from a YAML file.

path - A String containing the path to the YAML file to load.

Returns an Inventory instance.

# File lib/confer/inventory.rb, line 22
def self.from_file(path)
  self.from_hash YAML.load File.open(path, 'r').read
rescue Errno::ENOENT => e
  raise InventoryNotFoundError.new(e)
rescue Psych::SyntaxError => e
  raise InventorySyntaxError.new(e)
end
from_hash(hash) click to toggle source

Public: Loads an inventory from a Hash of hosts.

array - A Hash of hosts and their options, indexed by name.

Returns an Inventory instance.

# File lib/confer/inventory.rb, line 37
def self.from_hash(hash)
  Inventory.new Hash[hash.map { |k, v| [k, Host.new(k, v)] }]
end
new(hosts = {}) click to toggle source

Public: Creates a new Inventory instance.

hosts - A Hash of hosts their options in the inventory, indexed by name.

# File lib/confer/inventory.rb, line 52
def initialize(hosts = {})
  @hosts = hosts
end