class Loom::Inventory::InventoryList
Attributes
hosts[R]
Public Class Methods
active_inventory(loom_config)
click to toggle source
The list of hosts to apply patterns to
# File lib/loom/inventory.rb, line 26 def active_inventory(loom_config) return total_inventory loom_config if loom_config.inventory_all_hosts fileset = InventoryFileSet.new inventory_files(loom_config) groups = loom_config.inventory_groups.map(&:to_sym).reduce({}) do |map, group| Loom.log.debug2(self) { "looking for group => #{group}" } key = group.to_sym map[key] = fileset.hostgroup_map[key] if fileset.hostgroup_map.key? key map end Loom.log.debug1(self) { "groups map => #{groups}" } InventoryList.new loom_config.inventory_hosts, groups end
new(hostlist, hostgroup_map={})
click to toggle source
# File lib/loom/inventory.rb, line 49 def initialize(hostlist, hostgroup_map={}) @hostgroup_map = hostgroup_map all_hosts = hostgroup_map.values.flatten + hostlist @hosts = parse_hosts(all_hosts).uniq { |h| h.hostname } @disabled_hosts = {} end
total_inventory(loom_config)
click to toggle source
# File lib/loom/inventory.rb, line 17 def total_inventory(loom_config) fileset = InventoryFileSet.new inventory_files(loom_config) config_hostlist = loom_config.inventory_hosts hostlist = fileset.hostlist + config_hostlist InventoryList.new hostlist, fileset.hostgroup_map end
Private Class Methods
inventory_files(loom_config)
click to toggle source
# File lib/loom/inventory.rb, line 42 def inventory_files(loom_config) loom_config.files.find INVENTORY_FILE_NAMES end
Public Instance Methods
disable(hostname)
click to toggle source
# File lib/loom/inventory.rb, line 57 def disable(hostname) @disabled_hosts[hostname] = true end
disabled?(hostname)
click to toggle source
# File lib/loom/inventory.rb, line 61 def disabled?(hostname) !!@disabled_hosts[hostname] end
group_names()
click to toggle source
# File lib/loom/inventory.rb, line 69 def group_names @hostgroup_map.keys end
hostnames()
click to toggle source
# File lib/loom/inventory.rb, line 65 def hostnames @hosts.map { |h| h.hostname } end
Private Instance Methods
parse_hosts(list)
click to toggle source
# File lib/loom/inventory.rb, line 74 def parse_hosts(list) list.map do |hoststring| raise InvalidHostEntry, hoststring.class.name unless hoststring.is_a? String HostSpec.new hoststring end end