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?, #invoke, #is_top_level_node?, #keyed_namespace, #list_attributes, #namespace, #no_nodes?, #nodes_loaded?, #open_ssh_connections, #prompt_breadcrumb, #proxy, #put, #recurse_resource_for_identifier, #requires_description?, #requires_type?, #resource_for_identifier, #rsync, #scp, #server?, #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.
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
68
69
70
|
# File 'lib/objects/node/inventory/base.rb', line 68
def cache_nodes_in_memory
@cache_handler.do_cache_nodes!
end
|
#cloud_matches(matchers) ⇒ Object
13
14
15
16
|
# File 'lib/objects/node/inventory/base.rb', line 13
def cloud_matches(matchers)
data_wrapper = :cloud_tags
matches_for(data_wrapper, matchers)
end
|
#direct_invoke_server(method, identifier) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/objects/node/inventory/base.rb', line 55
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
|
28
29
30
|
# File 'lib/objects/node/inventory/base.rb', line 28
def
super + %i[ssh]
end
|
#inventory? ⇒ Boolean
80
81
82
|
# File 'lib/objects/node/inventory/base.rb', line 80
def inventory?
true
end
|
#list_key ⇒ Object
72
73
74
|
# File 'lib/objects/node/inventory/base.rb', line 72
def list_key
:server
end
|
#machine_by_identifier(identifier) ⇒ Object
18
19
20
|
# File 'lib/objects/node/inventory/base.rb', line 18
def machine_by_identifier(identifier)
resources.active.select { |machine| machine.identifier == identifier }.first
end
|
#machines ⇒ Object
76
77
78
|
# File 'lib/objects/node/inventory/base.rb', line 76
def machines
@resources.active
end
|
#matches_for(data_wrapper, matchers) ⇒ Object
22
23
24
25
26
|
# File 'lib/objects/node/inventory/base.rb', line 22
def matches_for(data_wrapper, matchers)
resources.active.select do |machine|
machine.send(data_wrapper).has_key_and_value?(matchers)
end
end
|
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/objects/node/inventory/base.rb', line 32
def
base_items = super.dup
base_items[:ssh] = {
description: 'ssh directly into a resource',
usage: 'ssh identifier',
console_only: true
}
base_items
end
|
8
9
10
11
|
# File 'lib/objects/node/inventory/base.rb', line 8
def meta_matches(matchers)
data_wrapper = :metadata
matches_for(data_wrapper, matchers)
end
|
#override_server_identifier? ⇒ Boolean
84
85
86
|
# File 'lib/objects/node/inventory/base.rb', line 84
def override_server_identifier?
!@override_identifier.nil?
end
|
#ssh(identifier = nil) ⇒ Object
47
48
49
|
# File 'lib/objects/node/inventory/base.rb', line 47
def ssh(identifier = nil)
direct_invoke_server(:ssh, identifier)
end
|
51
52
53
|
# File 'lib/objects/node/inventory/base.rb', line 51
def tags(identifier = nil)
direct_invoke_server(:tags, identifier)
end
|