class Bcome::Node::Inventory::Base
Public Class Methods
new(*params)
click to toggle source
Calls superclass method
Bcome::Node::Base::new
# File lib/objects/node/inventory/base.rb, line 7 def initialize(*params) super raise Bcome::Exception::InventoriesCannotHaveSubViews, @views if @views[:views] && !@views[:views].empty? end
Public Instance Methods
cache_nodes_in_memory()
click to toggle source
# File lib/objects/node/inventory/base.rb, line 88 def cache_nodes_in_memory @cache_handler.do_cache_nodes! end
cloud_matches(matchers)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 17 def cloud_matches(matchers) data_wrapper = :cloud_tags matches_for(data_wrapper, matchers) end
direct_invoke_all_servers(method)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 83 def direct_invoke_all_servers(method) resources.active.each { |m| m.send(method) } nil end
direct_invoke_server(method, identifier)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 65 def direct_invoke_server(method, identifier) # If we only have a single resource in our inventory, then just allow direct invocation if resources.size == 1 resource = resources.first else # Otherwise, we expect to find the resource by its identifier unless identifier puts "\nPlease provide a machine identifier, e.g. #{method} machinename\n".warning unless identifier return end resource = resources.for_identifier(identifier) raise Bcome::Exception::InvalidBreadcrumb, "Cannot find a node named '#{identifier}'" unless resource end resource.send(method) end
inventory?()
click to toggle source
# File lib/objects/node/inventory/base.rb, line 100 def inventory? true end
list_key()
click to toggle source
# File lib/objects/node/inventory/base.rb, line 92 def list_key :server end
machine_by_identifier(identifier)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 22 def machine_by_identifier(identifier) resources.active.select { |machine| machine.identifier == identifier }.first end
machines(skip_for_hidden = true)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 96 def machines(skip_for_hidden = true) skip_for_hidden ? resources.active : resources.active.reject(&:hide?) end
matches_for(data_wrapper, matchers)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 26 def matches_for(data_wrapper, matchers) resources.active.select do |machine| machine.send(data_wrapper).has_key_and_value?(matchers) end end
meta_matches(matchers)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 12 def meta_matches(matchers) data_wrapper = :metadata matches_for(data_wrapper, matchers) end
override_server_identifier?()
click to toggle source
# File lib/objects/node/inventory/base.rb, line 104 def override_server_identifier? respond_to?(:override_identifier) && !override_identifier.nil? end
resources()
click to toggle source
# File lib/objects/node/inventory/base.rb, line 53 def resources @resources ||= ::Bcome::Node::Resources::Inventory.new(self) end
ssh(identifier = nil)
click to toggle source
# File lib/objects/node/inventory/base.rb, line 57 def ssh(identifier = nil) direct_invoke_server(:ssh, identifier) end