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
Constants included
from Draw
Draw::BLIP, Draw::BOTTOM_ANCHOR, Draw::BOX_BOTTOM_LEFT, Draw::BOX_BOTTOM_RIGHT, Draw::BOX_HORIZONTAL_LINE, Draw::BOX_SIDE, Draw::BOX_TOP_LEFT, Draw::BOX_TOP_RIGHT, Draw::BRANCH, Draw::INGRESS, Draw::LEFT_PADDING, Draw::MID_SHIPS
LocalMetaDataFactory::META_DATA_FILE_PATH_PREFIX
Instance Attribute Summary
Attributes inherited from Base
#identifier, #params, #parent, #views
Instance Method Summary
collapse
Methods inherited from Base
#close_ssh_connections, #collection?, const_missing, #data_print_from_hash, #execute_local, #execute_script, #has_parent?, #has_proxy?, #hide?, #inspect, #invoke, #is_top_level_node?, #keyed_namespace, #list_attributes, #method_missing, #namespace, #no_nodes?, #nodes_loaded!, #nodes_loaded?, #prompt_breadcrumb, #proxy, #proxy_chain, #proxy_chain_link, #put, #put_str, #recurse_resource_for_identifier, #requires_description?, #requires_type?, #resource_for_identifier, #rsync, #scoped_resources, #scp, #server?, #ssh_connect, #validate_attributes, #validate_identifier
#cursor, #do_signal, #fork_process, #signal_failure, #signal_stop, #signal_success, #start_indicator, #stop_indicator, #wrap_indicator
Methods included from Tree
#build_tree, #deduce_tree_structure, #namespace_tree_line, #network_namespace_tree_data, #recurse_tree_lines, #routes, #routing_tree_data, #routing_tree_line, #to_nested_hash, #tree
Methods included from Draw
#box_it, #max_box_line_length
#registry, #user_command_wrapper
#do_create_metadata, #meta, #metadata, #metadata_for_namespace, #raw_metadata
#item_spacing, #menu, #menu_group_names, #menu_item_spacing_length, #mode, #print_menu_items, #tab_spacing
Methods included from Attributes
#filters, #identifier, #network_data, #network_driver, #recurse_hash_data_for_instance_key, #ssh_data, #ssh_driver, #ssh_driver=
#cd, #clear!, #disable, #disable!, #enable, #enable!, #interactive, #is_node_level_method?, #ls, #lsa, #method_in_registry?, #method_is_available_on_node?, #new_line, #parents, #ping, #pretty_description, #resource_identifiers, #run, #ssh_connect, #tree_descriptions, #visual_hierarchy, #workon
Methods included from Context
#current_context?, #irb_workspace=, #previous_irb_workspace=
Constructor Details
#initialize(*params) ⇒ Base
Returns a new instance of Base.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Bcome::Node::Base
Instance Method Details
#cache_nodes_in_memory ⇒ Object
88
89
90
|
# File 'lib/objects/node/inventory/base.rb', line 88
def cache_nodes_in_memory
@cache_handler.do_cache_nodes!
end
|
#cloud_matches(matchers) ⇒ Object
17
18
19
20
|
# 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) ⇒ Object
83
84
85
86
|
# 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) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/objects/node/inventory/base.rb', line 65
def direct_invoke_server(method, identifier)
if resources.size == 1
resource = resources.first
else
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
|
32
33
34
|
# File 'lib/objects/node/inventory/base.rb', line 32
def
super + %i[ssh tags]
end
|
#inventory? ⇒ Boolean
100
101
102
|
# File 'lib/objects/node/inventory/base.rb', line 100
def inventory?
true
end
|
#list_key ⇒ Object
92
93
94
|
# File 'lib/objects/node/inventory/base.rb', line 92
def list_key
:server
end
|
#machine_by_identifier(identifier) ⇒ Object
22
23
24
|
# 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) ⇒ Object
96
97
98
|
# 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) ⇒ Object
26
27
28
29
30
|
# 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
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/objects/node/inventory/base.rb', line 36
def
base_items = super.dup
base_items[:ssh] = {
description: 'ssh directly into a resource',
usage: 'ssh identifier',
console_only: true,
group: :ssh
}
base_items[:tags] = {
description: 'print out server tags/labels',
group: :informational
}
base_items
end
|
12
13
14
15
|
# 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? ⇒ Boolean
104
105
106
|
# File 'lib/objects/node/inventory/base.rb', line 104
def override_server_identifier?
respond_to?(:override_identifier) && !override_identifier.nil?
end
|
#ssh(identifier = nil) ⇒ Object
57
58
59
|
# File 'lib/objects/node/inventory/base.rb', line 57
def ssh(identifier = nil)
direct_invoke_server(:ssh, identifier)
end
|
61
62
63
|
# File 'lib/objects/node/inventory/base.rb', line 61
def tags(identifier = nil)
identifier.nil? ? direct_invoke_all_servers(:tags) : direct_invoke_server(:tags, identifier)
end
|