Class: Bcome::Node::Inventory::Base
- Inherits:
-
Base
- Object
- Base
- Bcome::Node::Inventory::Base
show all
- Defined in:
- lib/objects/node/inventory/base.rb
Constant Summary
Constants inherited
from Base
Base::DEFAULT_IDENTIFIER
LocalMetaDataFactory::META_DATA_FILE_PATH_PREFIX
Instance Attribute Summary
Attributes inherited from Base
#params
Instance Method Summary
collapse
Methods inherited from Base
#bootstrap?, #close_ssh_connections, #collection?, const_missing, #data_print_from_hash, #execute_local, #execute_script, #has_parent?, #has_proxy?, #identifier=, #invoke, #is_top_level_node?, #keyed_namespace, #list_attributes, #namespace, #no_nodes?, #nodes_loaded?, #open_ssh_connections, #pack_metadata, #prompt_breadcrumb, #proxy, #put, #recurse_resource_for_identifier, #requires_description?, #requires_type?, #resource_for_identifier, #rsync, #scp, #server?, #unpack_metadata, #validate_attributes, #validate_identifier
#registry, #user_command_wrapper
#do_create_metadata, #meta, #metadata, #metadata_for_namespace, #raw_metadata
#item_spacing, #menu, #menu_item_spacing_length, #mode, #tab_spacing
Methods included from Attributes
#description, #filters, #identifier, #network_data, #network_driver, #recurse_hash_data_for_instance_var, #ssh_data, #ssh_driver, #type
#back, #cd, #clear!, #disable, #disable!, #enable, #enable!, #interactive, #is_node_level_method?, #list_in_tree, #ls, #lsa, #method_in_registry?, #method_is_available_on_node?, #method_missing, #new_line, #parents, #ping, #pretty_description, #print_tree_view_for_resource, #resource_identifiers, #run, #tree, #tree_descriptions, #visual_hierarchy, #workon
Methods included from Context
#irb_workspace=, #is_current_context?, #previous_irb_workspace=
Constructor Details
#initialize(*params) ⇒ Base
Returns a new instance of Base.
4
5
6
7
8
9
|
# File 'lib/objects/node/inventory/base.rb', line 4
def initialize(*params)
super
raise Bcome::Exception::InventoriesCannotHaveSubViews, @views if @views[:views] && !@views[:views].empty?
@bootstrap = false
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Bcome::WorkspaceCommands
Instance Method Details
#cache_nodes_in_memory ⇒ Object
84
85
86
|
# File 'lib/objects/node/inventory/base.rb', line 84
def cache_nodes_in_memory
@cache_handler.do_cache_nodes!
end
|
#cloud_matches(matchers) ⇒ Object
16
17
18
19
|
# File 'lib/objects/node/inventory/base.rb', line 16
def cloud_matches(matchers)
data_wrapper = :cloud_tags
matches_for(data_wrapper, matchers)
end
|
#direct_invoke_all_servers(method) ⇒ Object
79
80
81
82
|
# File 'lib/objects/node/inventory/base.rb', line 79
def direct_invoke_all_servers(method)
resources.active.each {|m| m.send(method) }
return
end
|
#direct_invoke_server(method, identifier) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/objects/node/inventory/base.rb', line 66
def direct_invoke_server(method, identifier)
unless identifier
puts "\nPlease provide a machine identifier, e.g. #{method} machinename\n".warning unless identifier
return
end
if resource = resources.for_identifier(identifier)
resource.send(method)
else
raise Bcome::Exception::InvalidBreadcrumb, "Cannot find a node named '#{identifier}'"
end
end
|
39
40
41
|
# File 'lib/objects/node/inventory/base.rb', line 39
def
super + %i[ssh]
end
|
#inventory? ⇒ Boolean
96
97
98
|
# File 'lib/objects/node/inventory/base.rb', line 96
def inventory?
true
end
|
#list_key ⇒ Object
88
89
90
|
# File 'lib/objects/node/inventory/base.rb', line 88
def list_key
:server
end
|
#machine_by_identifier(identifier) ⇒ Object
21
22
23
|
# File 'lib/objects/node/inventory/base.rb', line 21
def machine_by_identifier(identifier)
resources.active.select { |machine| machine.identifier == identifier }.first
end
|
#machines ⇒ Object
92
93
94
|
# File 'lib/objects/node/inventory/base.rb', line 92
def machines
@resources.active
end
|
#matches_for(data_wrapper, matchers) ⇒ Object
25
26
27
28
29
|
# File 'lib/objects/node/inventory/base.rb', line 25
def matches_for(data_wrapper, matchers)
resources.active.select do |machine|
machine.send(data_wrapper).has_key_and_value?(matchers)
end
end
|
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/objects/node/inventory/base.rb', line 43
def
base_items = super.dup
base_items[:ssh] = {
description: 'ssh directly into a resource',
usage: 'ssh identifier',
console_only: true
}
base_items
end
|
11
12
13
14
|
# File 'lib/objects/node/inventory/base.rb', line 11
def meta_matches(matchers)
data_wrapper = :metadata
matches_for(data_wrapper, matchers)
end
|
#override_server_identifier? ⇒ Boolean
100
101
102
|
# File 'lib/objects/node/inventory/base.rb', line 100
def override_server_identifier?
!@override_identifier.nil?
end
|
#ssh(identifier = nil) ⇒ Object
58
59
60
|
# File 'lib/objects/node/inventory/base.rb', line 58
def ssh(identifier = nil)
direct_invoke_server(:ssh, identifier)
end
|
62
63
64
|
# File 'lib/objects/node/inventory/base.rb', line 62
def tags(identifier = nil)
identifier.nil? ? direct_invoke_all_servers(:tags) : direct_invoke_server(:tags, identifier)
end
|
#toggle_bootstrap(set_to = (@bootstrap ? false : true)) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/objects/node/inventory/base.rb', line 31
def toggle_bootstrap(set_to = (@bootstrap ? false : true))
resources.active.each do |machine|
machine.toggle_bootstrap(set_to)
end
@bootstrap = (@bootstrap ? false : true)
return
end
|