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?, #should_eager_load_children?, #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
40
41
42
|
# File 'lib/stack/instance.rb', line 36
def initialize(meta_data, parent)
@meta_data = meta_data
@environment = parent
@external_network_interface_address = meta_data[:external_network_interface_address]
@public_ip_address = meta_data[:public_ip_address]
@role = meta_data[:role]
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
|
#external_network_interface_address ⇒ Object
Returns the value of attribute external_network_interface_address.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def external_network_interface_address
@external_network_interface_address
end
|
Returns the value of attribute meta_data.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def meta_data
@meta_data
end
|
#public_ip_address ⇒ Object
Returns the value of attribute public_ip_address.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def public_ip_address
@public_ip_address
end
|
Returns the value of attribute role.
34
35
36
|
# File 'lib/stack/instance.rb', line 34
def role
@role
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
108
109
110
|
# File 'lib/stack/instance.rb', line 108
def child_reference_key
:instance
end
|
#do_describe ⇒ Object
116
117
118
119
120
121
122
123
|
# File 'lib/stack/instance.rb', line 116
def do_describe
description = "\tNode Id:". + "\s\s#{node.identifier.}"
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
60
61
62
|
# File 'lib/stack/instance.rb', line 60
def do_load_resources
[self]
end
|
#get(*params) ⇒ Object
78
79
80
|
# File 'lib/stack/instance.rb', line 78
def get(*params)
node.get(*params)
end
|
#has_sub_nodes? ⇒ Boolean
56
57
58
|
# File 'lib/stack/instance.rb', line 56
def has_sub_nodes?
return false
end
|
#highlight? ⇒ Boolean
112
113
114
|
# File 'lib/stack/instance.rb', line 112
def highlight?
@environment.object_in_selections?(self)
end
|
#identifier ⇒ Object
44
45
46
|
# File 'lib/stack/instance.rb', line 44
def identifier
node.identifier
end
|
#is_sudo? ⇒ Boolean
96
97
98
|
# File 'lib/stack/instance.rb', line 96
def is_sudo?
super || @environment.is_sudo?
end
|
82
83
84
85
86
87
88
89
90
|
# File 'lib/stack/instance.rb', line 82
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 => 'functions', :description => "List all available custom functions" }
]
end
|
#node_level_klass ⇒ Object
125
126
127
|
# File 'lib/stack/instance.rb', line 125
def node_level_klass
::Bcome::Node::Instance
end
|
#override_instance_identifier_for_wbz_stacks? ⇒ Boolean
48
49
50
|
# File 'lib/stack/instance.rb', line 48
def override_instance_identifier_for_wbz_stacks?
environment.meta_data[:override_instance_identifier_for_wbz_stacks] ? true : false
end
|
#overriden_identifier_prefix ⇒ Object
52
53
54
|
# File 'lib/stack/instance.rb', line 52
def overriden_identifier_prefix
environment.meta_data[:override_instance_identifier_for_wbz_stacks]
end
|
92
93
94
|
# File 'lib/stack/instance.rb', line 92
def platform
@environment.platform
end
|
#put(*params) ⇒ Object
69
70
71
|
# File 'lib/stack/instance.rb', line 69
def put(*params)
node.put(*params)
end
|
#reference_key ⇒ Object
104
105
106
|
# File 'lib/stack/instance.rb', line 104
def reference_key
:instances
end
|
#responds_to_list? ⇒ Boolean
100
101
102
|
# File 'lib/stack/instance.rb', line 100
def responds_to_list?
false
end
|
#run(*params) ⇒ Object
73
74
75
76
|
# File 'lib/stack/instance.rb', line 73
def run(*params)
node.run(*params)
return
end
|
65
66
67
|
# File 'lib/stack/instance.rb', line 65
def ssh
node.ssh
end
|