Class: Bcome::Stack::Instance
Constant Summary
Constants included
from Functions
Functions::CONFIGS_PATH
BecomeObject::CONFIGS_PATH
Orchestrator::Registry::CONFIGS_PATH
ContextFunctions::CONFIGS_PATH
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#direct_rsync, #direct_rsync_bootstrap, #execute_command, #jump_host_rsync, #jump_host_rsync_bootstrap, #rsync_is_sudo
Methods included from Functions
#F, #cmd_config_path, #cmd_for_ref, #cmd_functions, #functions, #has_cmd_functions?, #has_functions_config?, #load_cmd_functions
#all_items, #become_identifier, #context_breadcrumb, #has_main_context?, #has_potential_resources?, #identifier_for, #is_stack_level_resource?, #list, #local_download_path, #main_context, #main_context=, #mini_list, #namespace, #previous_workspace_object, #previous_workspace_object=, #resource_for_identifier, #resource_identifiers, #resources
Methods inherited from Base
#available_resources_options_string, #become, #become_identifier, const_missing, #construct_node, #describe, #init, #interactive, #machines, #menu, #method_missing, #node, #recipes, #respond_to_bcome_context_method?, #workon
#config_for_registry, #do_load_recipes, #has_registry_config?, #load_recipe_registry, #recipe_registry, #registry_configs_path
#run_local
#command_for_context, #context_cmd_config_path, #context_cmd_functions, #context_commands, #execute_command_for_context, #has_context_cmd_functions?, #has_context_functions_config?, #load_context_cmd_functions
Constructor Details
#initialize(meta_data, parent) ⇒ Instance
Returns a new instance of Instance.
36
37
38
39
|
# File 'lib/stack/instance.rb', line 36
def initialize(meta_data, parent)
@meta_data = meta_data
@environment = parent
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Bcome::Stack::Base
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def environment
@environment
end
|
Returns the value of attribute meta_data.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def meta_data
@meta_data
end
|
Class Method Details
.collection_from_config(parent, configuration) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/stack/instance.rb', line 24
def collection_from_config(parent, configuration)
conf_for_env = configuration[:instances]
collection = []
conf_for_env.each do |meta_data|
collection << new(meta_data, parent)
end
return collection
end
|
.collection_from_fog_data(parent, fog_instances) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/stack/instance.rb', line 9
def collection_from_fog_data(parent, fog_instances)
collection = []
fog_instances.each do |f_instance|
meta_data = {
:identifier => f_instance.tags["Name"],
:external_network_interface_address => f_instance.private_ip_address,
:public_ip_address => f_instance.public_ip_address,
:role => f_instance.tags["function"]
}
collection << new(meta_data, parent)
end
return collection
end
|
Instance Method Details
#child_reference_key ⇒ Object
102
103
104
|
# File 'lib/stack/instance.rb', line 102
def child_reference_key
:instance
end
|
#do_describe ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/stack/instance.rb', line 110
def do_describe
description = "\tNode Id:". + "\s\s#{node.identifier.}"
description += "\n\tsudo: ". + (is_sudo? ? "on".danger : "off" )
description += "\n\t" + "Internal IP: ". + "#{@meta_data[:external_network_interface_address]}".
description += "\n\t" + "External IP: ". + "#{node.public_ip_address}". if node.public_ip_address
description += "\n\t" + "Role: ". + "#{node.role}". if node.role
description += "\n\n"
return description
end
|
#do_load_resources ⇒ Object
49
50
51
|
# File 'lib/stack/instance.rb', line 49
def do_load_resources
[self]
end
|
#get(*params) ⇒ Object
67
68
69
|
# File 'lib/stack/instance.rb', line 67
def get(*params)
node.get(*params)
end
|
#has_sub_nodes? ⇒ Boolean
45
46
47
|
# File 'lib/stack/instance.rb', line 45
def has_sub_nodes?
return false
end
|
#highlight? ⇒ Boolean
106
107
108
|
# File 'lib/stack/instance.rb', line 106
def highlight?
@environment.object_in_selections?(self)
end
|
#identifier ⇒ Object
41
42
43
|
# File 'lib/stack/instance.rb', line 41
def identifier
node.identifier
end
|
#is_sudo? ⇒ Boolean
90
91
92
|
# File 'lib/stack/instance.rb', line 90
def is_sudo?
super || @environment.is_sudo?
end
|
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/stack/instance.rb', line 71
def
super + [
{ :command => "run", :description => "Execute a command.", :usage => "run 'command'" },
{ :command => "put", :description => "Copy files to remote (recursive - uses rsync)", :usage => "put 'local_path', 'remote_path'" },
{ :command => "get", :description => "Download from remote (recursive - uses rsync).", :usage => "get 'remote_path'"},
{ :command => "ssh", :description => "Initiate an SSH connection." },
{ :command => "sudo", :description => "Run 'get' and 'put' in sudo mode (assumes you have passwordless sudo setup)" },
{ :command => 'functions', :description => "List all available custom functions" }
]
end
|
#node_level_klass ⇒ Object
120
121
122
|
# File 'lib/stack/instance.rb', line 120
def node_level_klass
::Bcome::Node::Instance
end
|
82
83
84
|
# File 'lib/stack/instance.rb', line 82
def platform
@environment.platform
end
|
#put(*params) ⇒ Object
58
59
60
|
# File 'lib/stack/instance.rb', line 58
def put(*params)
node.put(*params)
end
|
#reference_key ⇒ Object
98
99
100
|
# File 'lib/stack/instance.rb', line 98
def reference_key
:instances
end
|
#responds_to_list? ⇒ Boolean
94
95
96
|
# File 'lib/stack/instance.rb', line 94
def responds_to_list?
false
end
|
#run(*params) ⇒ Object
62
63
64
65
|
# File 'lib/stack/instance.rb', line 62
def run(*params)
node.run(*params)
return
end
|
54
55
56
|
# File 'lib/stack/instance.rb', line 54
def ssh
node.ssh
end
|
86
87
88
|
# File 'lib/stack/instance.rb', line 86
def sudo
toggle_sudo
end
|