bcome 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bcome +8 -39
  3. data/lib/bcome.rb +12 -3
  4. data/lib/objects/bcome/version.rb +3 -0
  5. data/lib/objects/bootup.rb +81 -0
  6. data/lib/objects/command/local.rb +40 -0
  7. data/lib/objects/config_factory.rb +36 -0
  8. data/lib/objects/driver/base.rb +30 -0
  9. data/lib/objects/driver/bucket.rb +20 -0
  10. data/lib/objects/driver/ec2.rb +44 -0
  11. data/lib/objects/driver/static.rb +4 -0
  12. data/lib/objects/exception/argument_error_invoking_method_from_command_line.rb +7 -0
  13. data/lib/objects/exception/base.rb +15 -0
  14. data/lib/objects/exception/can_only_subselect_on_inventory.rb +7 -0
  15. data/lib/objects/exception/cannot_find_internal_registry_klass.rb +7 -0
  16. data/lib/objects/exception/cannot_find_subselection_parent.rb +7 -0
  17. data/lib/objects/exception/cant_find_key_in_cloud_tags.rb +7 -0
  18. data/lib/objects/exception/cant_find_key_in_metadata.rb +7 -0
  19. data/lib/objects/exception/cant_find_proxy_host_by_identifier.rb +7 -0
  20. data/lib/objects/exception/cant_find_proxy_host_by_namespace.rb +7 -0
  21. data/lib/objects/exception/could_not_initiate_ssh_connection.rb +7 -0
  22. data/lib/objects/exception/could_not_initiate_ssh_connection_through_backend_proxy.rb +7 -0
  23. data/lib/objects/exception/deprecation_warning.rb +11 -0
  24. data/lib/objects/exception/duplicate_command_line_argument_key.rb +7 -0
  25. data/lib/objects/exception/ec2_driver_missing_provisioning_region.rb +7 -0
  26. data/lib/objects/exception/failed_to_run_local_command.rb +7 -0
  27. data/lib/objects/exception/interactive_session_halt.rb +4 -0
  28. data/lib/objects/exception/invalid_bcome_breadcrumb.rb +7 -0
  29. data/lib/objects/exception/invalid_breadcrumb.rb +7 -0
  30. data/lib/objects/exception/invalid_context_command.rb +7 -0
  31. data/lib/objects/exception/invalid_identifier.rb +7 -0
  32. data/lib/objects/exception/invalid_machines_cache_config.rb +7 -0
  33. data/lib/objects/exception/invalid_matcher_query.rb +7 -0
  34. data/lib/objects/exception/invalid_meta_data_config.rb +7 -0
  35. data/lib/objects/exception/invalid_network_config.rb +7 -0
  36. data/lib/objects/exception/invalid_network_driver_type.rb +7 -0
  37. data/lib/objects/exception/invalid_proxy_config.rb +7 -0
  38. data/lib/objects/exception/invalid_regexp_matcher_in_registry.rb +7 -0
  39. data/lib/objects/exception/invalid_registry_arguments_type.rb +7 -0
  40. data/lib/objects/exception/invalid_registry_data_config.rb +7 -0
  41. data/lib/objects/exception/invalid_restriction_key_in_registry.rb +7 -0
  42. data/lib/objects/exception/invalid_ssh_config.rb +7 -0
  43. data/lib/objects/exception/inventories_cannot_have_subviews.rb +7 -0
  44. data/lib/objects/exception/malformed_command_line_arguments.rb +7 -0
  45. data/lib/objects/exception/method_invocation_requires_parameter.rb +7 -0
  46. data/lib/objects/exception/method_name_conflict_in_registry.rb +7 -0
  47. data/lib/objects/exception/missing_argument_for_registry_command.rb +7 -0
  48. data/lib/objects/exception/missing_description_on_view.rb +7 -0
  49. data/lib/objects/exception/missing_execute_on_registry_object.rb +7 -0
  50. data/lib/objects/exception/missing_identifier_on_view.rb +7 -0
  51. data/lib/objects/exception/missing_ip_address_on_server.rb +7 -0
  52. data/lib/objects/exception/missing_network_config.rb +7 -0
  53. data/lib/objects/exception/missing_params_for_rsync.rb +7 -0
  54. data/lib/objects/exception/missing_params_for_scp.rb +7 -0
  55. data/lib/objects/exception/missing_subselection_key.rb +7 -0
  56. data/lib/objects/exception/missing_type_on_view.rb +7 -0
  57. data/lib/objects/exception/no_node_found_for_breadcrumb.rb +7 -0
  58. data/lib/objects/exception/no_node_named_by_identifier.rb +7 -0
  59. data/lib/objects/exception/node_identifiers_must_be_unique.rb +7 -0
  60. data/lib/objects/exception/orchestration_script_does_not_exist.rb +7 -0
  61. data/lib/objects/exception/proxy_host_node_does_not_have_public_ip_address.rb +7 -0
  62. data/lib/objects/exception/unknown_method_for_namespace.rb +7 -0
  63. data/lib/objects/interactive/session.rb +45 -0
  64. data/lib/objects/interactive/session_item/base.rb +36 -0
  65. data/lib/objects/interactive/session_item/capture_input.rb +20 -0
  66. data/lib/objects/interactive/session_item/transparent_ssh.rb +111 -0
  67. data/lib/objects/modules/context.rb +13 -0
  68. data/lib/objects/modules/registry_management.rb +14 -0
  69. data/lib/objects/modules/ui_output.rb +9 -0
  70. data/lib/objects/modules/workspace_commands.rb +198 -0
  71. data/lib/objects/modules/workspace_menu.rb +128 -0
  72. data/lib/objects/node/attributes.rb +47 -0
  73. data/lib/objects/node/base.rb +248 -0
  74. data/lib/objects/node/cache_handler.rb +24 -0
  75. data/lib/objects/node/collection.rb +51 -0
  76. data/lib/objects/node/factory.rb +108 -0
  77. data/lib/objects/node/inventory/base.rb +88 -0
  78. data/lib/objects/node/inventory/defined.rb +112 -0
  79. data/lib/objects/node/inventory/subselect.rb +54 -0
  80. data/lib/objects/node/meta/base.rb +36 -0
  81. data/lib/objects/node/meta/cloud.rb +4 -0
  82. data/lib/objects/node/meta/local.rb +4 -0
  83. data/lib/objects/node/meta_data_factory.rb +23 -0
  84. data/lib/objects/node/meta_data_loader.rb +32 -0
  85. data/lib/objects/node/resources/base.rb +98 -0
  86. data/lib/objects/node/resources/inventory.rb +25 -0
  87. data/lib/objects/node/resources/sub_inventory.rb +56 -0
  88. data/lib/objects/node/server/base.rb +218 -0
  89. data/lib/objects/node/server/dynamic.rb +39 -0
  90. data/lib/objects/node/server/static.rb +31 -0
  91. data/lib/objects/orchestration/base.rb +13 -0
  92. data/lib/objects/orchestrator.rb +24 -0
  93. data/lib/objects/parser/bread_crumb.rb +31 -0
  94. data/lib/objects/progress_bar.rb +30 -0
  95. data/lib/objects/registry/arguments/base.rb +36 -0
  96. data/lib/objects/registry/arguments/command_line.rb +35 -0
  97. data/lib/objects/registry/arguments/console.rb +15 -0
  98. data/lib/objects/registry/command/base.rb +66 -0
  99. data/lib/objects/registry/command/external.rb +55 -0
  100. data/lib/objects/registry/command/group.rb +76 -0
  101. data/lib/objects/registry/command/internal.rb +34 -0
  102. data/lib/objects/registry/command_list.rb +33 -0
  103. data/lib/objects/registry/loader.rb +70 -0
  104. data/lib/objects/ssh/bootstrap.rb +19 -0
  105. data/lib/objects/ssh/command.rb +46 -0
  106. data/lib/objects/ssh/command_exec.rb +65 -0
  107. data/lib/objects/ssh/connection_handler.rb +101 -0
  108. data/lib/objects/ssh/driver.rb +204 -0
  109. data/lib/objects/ssh/proxy_data.rb +56 -0
  110. data/lib/objects/ssh/script_exec.rb +43 -0
  111. data/lib/objects/system/local.rb +30 -0
  112. data/lib/objects/workspace.rb +75 -0
  113. data/patches/irb.rb +20 -7
  114. data/patches/string.rb +75 -0
  115. data/patches/string_stylesheet.rb +61 -0
  116. metadata +175 -93
  117. data/bin/bcome-bash-setup +0 -18
  118. data/bin/bcome-setup +0 -43
  119. data/bin/boot.rb +0 -148
  120. data/bin/boot_no_shell.rb +0 -3
  121. data/filters/ec2_filter.rb +0 -12
  122. data/lib/bcome/version.rb +0 -3
  123. data/lib/become_object.rb +0 -111
  124. data/lib/boot.rb +0 -13
  125. data/lib/command.rb +0 -56
  126. data/lib/context_functions.rb +0 -65
  127. data/lib/filters/base.rb +0 -10
  128. data/lib/filters/ec2_filter.rb +0 -4
  129. data/lib/functions.rb +0 -70
  130. data/lib/helpers/command_helper.rb +0 -13
  131. data/lib/helpers/environment_ssh.rb +0 -122
  132. data/lib/helpers/fog_helper.rb +0 -108
  133. data/lib/helpers/instance_command.rb +0 -71
  134. data/lib/helpers/instance_ssh.rb +0 -83
  135. data/lib/helpers/selections.rb +0 -117
  136. data/lib/interactive/interactive_session_halt.rb +0 -4
  137. data/lib/interactive/session.rb +0 -44
  138. data/lib/interactive/session_item/base.rb +0 -30
  139. data/lib/interactive/session_item/transparent_ssh.rb +0 -133
  140. data/lib/nodes/base.rb +0 -60
  141. data/lib/nodes/environment.rb +0 -30
  142. data/lib/nodes/estate.rb +0 -44
  143. data/lib/nodes/instance.rb +0 -94
  144. data/lib/nodes/platform.rb +0 -17
  145. data/lib/nodes/view.rb +0 -31
  146. data/lib/object.rb +0 -21
  147. data/lib/orchestrator/command_group/base.rb +0 -56
  148. data/lib/orchestrator/command_group/custom.rb +0 -13
  149. data/lib/orchestrator/command_group/direct.rb +0 -53
  150. data/lib/orchestrator/direct_command/group.rb +0 -21
  151. data/lib/orchestrator/direct_command/instance.rb +0 -19
  152. data/lib/orchestrator/factory.rb +0 -38
  153. data/lib/orchestrator/loader.rb +0 -47
  154. data/lib/orchestrator/node_target/all.rb +0 -14
  155. data/lib/orchestrator/node_target/all_excluding_roles.rb +0 -14
  156. data/lib/orchestrator/node_target/all_with_roles.rb +0 -14
  157. data/lib/orchestrator/node_target/base.rb +0 -43
  158. data/lib/orchestrator/node_target/single.rb +0 -12
  159. data/lib/orchestrator/recipe.rb +0 -60
  160. data/lib/orchestrator/registry.rb +0 -37
  161. data/lib/orchestrator/validate_and_set.rb +0 -10
  162. data/lib/patches/string.rb +0 -86
  163. data/lib/progress_bar.rb +0 -31
  164. data/lib/render_irb.rb +0 -53
  165. data/lib/scp.rb +0 -40
  166. data/lib/ssh.rb +0 -51
  167. data/lib/stack/base.rb +0 -148
  168. data/lib/stack/environment.rb +0 -222
  169. data/lib/stack/estate.rb +0 -50
  170. data/lib/stack/instance.rb +0 -130
  171. data/lib/stack/platform.rb +0 -74
  172. data/lib/stack/view.rb +0 -56
  173. data/lib/workspace_context.rb +0 -40
data/lib/stack/base.rb DELETED
@@ -1,148 +0,0 @@
1
- module ::Bcome::Stack
2
- class Base
3
-
4
- include ::Bcome::ContextFunctions
5
- include ::Bcome::CommandHelper
6
- include ::Bcome::Orchestrator::Registry
7
-
8
- def machines
9
- node.machines
10
- end
11
-
12
- def interactive
13
- ::Bcome::Interactive::Session.run(self)
14
- end
15
-
16
- def self.const_missing(constant_name)
17
- ## Hook for direct access to stack level resources by constant name where
18
- ## cd ServerName should yield the same outcome as cd "ServerName" or cd :ServerName does
19
- ## This works at all stack levels, and so is applied to environments and platforms too
20
- stack_level_instance = ::IRB.CurrentContext.workspace.main
21
- return constant_name.to_s if stack_level_instance.is_stack_level_resource?(constant_name)
22
- super
23
- end
24
-
25
- def method_missing(method_sym, *arguments, &block)
26
- if command_for_context = command_for_context(method_sym)
27
- execute_command_for_context(command_for_context, arguments)
28
- elsif recipe = ::Bcome::Orchestrator::Recipe.by_identifier(method_sym.to_s, self)
29
- puts "Executing Command Recipe #{recipe.recipe_identifier}".informational
30
- puts "Description: #{recipe.description}".command
31
- recipe.execute!(machines)
32
- return
33
- else
34
- # Else, this could be a resource level item
35
- return method_sym.to_s if is_stack_level_resource?(method_sym)
36
- super
37
- end
38
- end
39
-
40
- def has_sub_nodes?
41
- return true
42
- end
43
-
44
- ###
45
- ## Construction & Initialisation
46
- ##
47
-
48
- def recipes
49
- @recipes ||= do_load_recipes
50
- end
51
-
52
- def node
53
- @node ||= construct_node
54
- end
55
-
56
- def respond_to_bcome_context_method?(method_sym)
57
- return (command_for_context(method_sym) || ::Bcome::Orchestrator::Recipe.by_identifier(method_sym.to_s, self)) ? true : false
58
- end
59
-
60
- def should_eager_load_children?
61
- return true
62
- end
63
-
64
- def construct_node
65
- node_attributes = meta_data
66
- if respond_to?(:collection_key)
67
- collection = should_eager_load_children? ? (resources.collect(&:node)) : []
68
- node_attributes.merge!({
69
- collection_key => collection
70
- })
71
- end
72
-
73
- this_node = node_level_klass.new(node_attributes)
74
- this_node.set_stack_peer(self)
75
- this_node.set_parent_reference(this_node, child_reference_key, collection_key) if respond_to?(:collection_key) && respond_to?(:child_reference_key)
76
- return this_node
77
- end
78
-
79
- def node_level_klass
80
- raise "Should be overidden in derived stack type"
81
- end
82
-
83
- def init
84
- node
85
- end
86
-
87
- ###
88
- ## Core workspace behaviour
89
- ##
90
-
91
- def become_identifier
92
- ::START_PROMPT
93
- end
94
-
95
- def become(object)
96
- BECOME.set(object, self)
97
- end
98
-
99
- def workon(identifier)
100
- resource = resource_for_identifier(identifier)
101
-
102
- unless resource
103
- puts "\nNo matching #{collection_key} for identifier '#{identifier}'.".failure + "\n\n#{available_resources_options_string}" + "\n\n"
104
- else
105
- puts "\nFrom #{resource.reference_key}, working on '#{identifier}'.".informational + "\n\n"
106
- puts "Hit 'menu' or 'ls' to see what you can do here.\n\n"
107
- become(resource)
108
- end
109
- end
110
- alias :w :workon
111
- alias :cd :workon
112
-
113
- def menu
114
- ::RENDER.menu(menu_items, self)
115
- end
116
-
117
- def menu_items
118
- [
119
- { :command => "list / ls", :description => "List all available resources at the current context." },
120
- { :command => "describe", :description => "Describe the resource object at the current context." },
121
- { :command => "cd NodeName", :description => "Select a resource object, and switch to its context.", :usage => "cd YourServerName" },
122
- { :command => "exit", :description => "Return to the previous context" },
123
- { :command => "exit!", :description => "Close all contexts, and exit bcome."},
124
- { :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'},
125
- { :command => "machines", :description => "Return all servers below the current level to the console. These objects can be manipulated directly" },
126
- { :command => "interactive", :description => "Enter an interactive where you may transparently interact with all the machines in your selection at once" },
127
- ]
128
- end
129
-
130
- def highlight?
131
- false ## override in stack objects that should be highlighted within a list, e.g. instance objects at the environment level that have been selected to workon on
132
- end
133
-
134
- def available_resources_options_string
135
- "Please select from one of: #{all_items.join(', ')}'"
136
- end
137
-
138
- def describe
139
- if self.respond_to?(:do_describe)
140
- message = "\n\tCollection Key:".menu_item_cyan + "\s#{reference_key}\n\n#{self.do_describe}"
141
- else
142
- message = "\nNothing to describe. Use 'ls' or 'list' to see namespace options".headsup unless self.respond_to?(:do_describe)
143
- end
144
- puts message
145
- end
146
-
147
- end
148
- end
@@ -1,222 +0,0 @@
1
- module ::Bcome::Stack
2
- class Environment < ::Bcome::Stack::Base
3
-
4
- include ::Bcome::BecomeObject
5
- include ::Bcome::Selections
6
- include ::Bcome::FogHelper
7
- include ::Bcome::EnvironmentSSH
8
- include ::Bcome::Functions
9
-
10
- class << self
11
- def collection_from_config(parent, configuration)
12
- collection = []
13
- configuration.each do |meta_data|
14
- collection << new(meta_data, parent) if meta_data[:network].to_s == parent.identifier.to_s
15
- end
16
- return collection
17
- end
18
- end
19
-
20
- attr_reader :identifier, :platform, :meta_data
21
-
22
- def initialize(meta_data, parent)
23
- @meta_data = meta_data
24
- @identifier = meta_data[:environment]
25
- @platform = parent
26
- end
27
-
28
- def machines
29
- node_machines = node.machines
30
- do_load_resources unless node_machines.any?
31
- return node.machines
32
- end
33
-
34
- def should_eager_load_children?
35
- false
36
- end
37
-
38
- def views
39
- @views ||= do_create_views
40
- end
41
-
42
- def has_views?
43
- views.any?
44
- end
45
-
46
- def list_views
47
- if has_views?
48
- ::RENDER.list_items("Sub-views", views)
49
- else
50
- puts "\n" + "This environment has no configured sub-views".warning + "\n\n"
51
- end
52
- end
53
- alias :lv :list_views
54
-
55
- def resource_identifiers
56
- @resource_identifiers ||= resource_identifiers_with_views
57
- end
58
-
59
- def resource_identifiers_with_views
60
- return has_views? ? (resources.collect(&:identifier) << views.collect(&:identifier)).flatten : resources.collect(&:identifier)
61
- end
62
-
63
- def resource_for_identifier(identifier)
64
- match = super
65
- unless match
66
- # Unless we've found a match amongst our server instances, look in our views
67
- matches = views.select {|view| view.identifier.to_sym == identifier.to_sym }
68
- raise "Retrieved more than one match for #{collection_key} '#{identifier}'. Selection is ambiguous" if matches.size > 1
69
- match = matches.first
70
- end
71
- return match
72
- end
73
-
74
- def do_create_views
75
- return [] unless meta_data[:sub_views]
76
- view_collection = []
77
- meta_data[:sub_views].each do |sub_view_data|
78
- view_collection << ::Bcome::Stack::View.new(@meta_data, @platform, self, sub_view_data)
79
- end
80
- return view_collection
81
- end
82
-
83
- def menu_items
84
- super + [
85
- { :command => "add", :description => "Add a resource you wish to work on.", :usage => "add MyServerIdentifier, OR add [array, of, identifiers]" },
86
- { :command => "add!", :description => "Add all resources from the current context." },
87
- { :command => "remove", :description => "Remove a resource you no longer with to work on.", :usage => "remove MyServerIdentifier, OR remove [array, of, identifiers]" },
88
- { :command => "clear!", :description => "Remove all selected resources." },
89
- { :command => "selections", :description => "Show all added resources.", :usage => "selections / s"},
90
- { :command => "run", :description => "Execute a command on all selected resources", :usage => "run 'command'" },
91
- { :command => "get", :description => "Download from remote from all selected resources (recursive - uses rsync)", :usage => "get 'remote_path'" },
92
- { :command => "put", :description => "Copy files up to all selected resources (recursive - uses rsync)", :usage => "put 'local_path', 'remote_path'" },
93
- { :command => "sudo", :description => "Run 'get' and 'put' in sudo mode (assumes you have passwordless sudo setup)" },
94
- { :command => 'functions', :description => "List all available custom functions" },
95
- { :command => 'lv', :description => "List all configured sub-views" },
96
- ]
97
- end
98
-
99
- def load_from_static_inventory
100
- path = config_path
101
- raise "Missing instances.yml configuration for your environment. You've selected a static network lookup, and yet I cannot find #{config_path}".failure unless File.exist?(config_path)
102
- config = YAML.load_file(path)
103
- return collection_klass.collection_from_config(self, config)
104
- end
105
-
106
- def refresh_dynamic_inventory
107
- loaded_resources = collection_klass.collection_from_fog_data(self, servers)
108
- loaded_resources
109
- end
110
-
111
-
112
- def restock
113
- puts "\n/ Refreshing server inventory".menu_item_green
114
- take_stock!(collection_klass.collection_from_fog_data(self, servers))
115
- puts " Done. Inventory written to: #{config_path}\n".menu_item_green
116
- end
117
-
118
- def use_inventory_cache?
119
- (dynamic_network_lookup? && self.meta_data[:inventory_cache])
120
- end
121
-
122
- def static_inventory_is_set?
123
- File.exist?(config_path)
124
- end
125
-
126
- def load_and_take_stock
127
- loaded_resources = refresh_dynamic_inventory
128
- take_stock!(loaded_resources)
129
- loaded_resources
130
- end
131
-
132
- def do_load_resources(restock_inventory = false)
133
- loaded_resources = manage_inventory(restock_inventory)
134
- node.set_instances(loaded_resources)
135
- return loaded_resources
136
- end
137
-
138
- def manage_inventory(restock_inventory = false)
139
- return load_from_static_inventory unless dynamic_network_lookup? # No dynamic lookup, load from static
140
- return refresh_dynamic_inventory unless use_inventory_cache? # Dynamic lookup, with no cache, just load from dynamic
141
- return load_and_take_stock if !static_inventory_is_set? || restock_inventory # Dynamic lookup and stock, if stock not set or we're explicitly re-stocking
142
- return load_from_static_inventory # otherwise just load from static.
143
- end
144
-
145
-
146
- def config_dir
147
- "#{CONFIGS_PATH}/static_instances/"
148
- end
149
-
150
- def config_path
151
- "#{config_dir}#{platform.identifier}_#{identifier}-instances.yml"
152
- end
153
-
154
- def take_stock!(resources)
155
- `mkdir -p #{config_dir}`
156
- inventory = { :instances => [] }
157
- resources.each do |resource|
158
- inventory[:instances] << {
159
- :identifier => resource.identifier,
160
- :external_network_interface_address => resource.external_network_interface_address,
161
- :public_ip_address => resource.public_ip_address,
162
- :role => resource.role
163
- }
164
- end
165
- File.open(config_path, "w") do |file|
166
- file.write inventory.to_yaml
167
- end
168
- end
169
-
170
- def do_describe
171
- description
172
- end
173
-
174
- def description
175
- desc = "\tNode Id:".menu_item_cyan + "\s#{node.identifier}".menu_item_green + "\n"
176
- desc += "\tNet Lookup:".menu_item_cyan + "\s#{node.network_lookup_type}".menu_item_white + "\n"
177
- desc += "\tSSH Mode:".menu_item_cyan + "\s#{node.ssh_mode_type}".menu_item_white
178
- if has_views?
179
- views.each do |view|
180
- desc += "\n\t \\ #{"view".menu_item_cyan}: #{view.identifier.menu_item_green}"
181
- end
182
- end
183
- return desc + "\n\n"
184
- end
185
-
186
- def collection_klass
187
- ::INSTANCE_STACK_KLASS
188
- end
189
-
190
- def reference_key
191
- :environments
192
- end
193
-
194
- def child_reference_key
195
- :environment
196
- end
197
-
198
- def collection_key
199
- :instances
200
- end
201
-
202
- def node_level_klass
203
- ::Bcome::Node::Environment
204
- end
205
-
206
- def network_lookup
207
- raise "Missing network lookup in networks_environment configuration".failure unless @meta_data[:network_lookup]
208
- return @meta_data[:network_lookup]
209
- end
210
-
211
- def network_lookup_type
212
- type = network_lookup[:type]
213
- raise "Unknown network lookup type '#{type}" unless ["dynamic", "static"].include?(type)
214
- return type
215
- end
216
-
217
- def dynamic_network_lookup?
218
- return network_lookup_type == "dynamic"
219
- end
220
-
221
- end
222
- end
data/lib/stack/estate.rb DELETED
@@ -1,50 +0,0 @@
1
- module ::Bcome::Stack
2
- class Estate < ::Bcome::Stack::Base
3
-
4
- include ::Bcome::BecomeObject
5
-
6
- def config_path
7
- "#{CONFIGS_PATH}/platform.yml"
8
- end
9
-
10
- def collection_klass
11
- ::PLATFORM_STACK_KLASS
12
- end
13
-
14
- def collection_key
15
- :platforms
16
- end
17
-
18
- def to_s
19
- "Estate"
20
- end
21
-
22
- def become_identifier
23
- ::START_PROMPT
24
- end
25
-
26
- def namespace
27
- starting_namespace
28
- end
29
-
30
- def starting_namespace
31
- "" # Used to determine where to store downloaded file - this is the start point directory, relative to the bcome install directory
32
- end
33
-
34
- def init
35
- n = ::Bcome::Node::Estate.new({ :platforms => resources.collect(&:node) })
36
- n.set_stack_peer(self)
37
- n.set_parent_reference(n, :estate, :platforms)
38
- return n
39
- end
40
-
41
- def node
42
- @node ||= init
43
- end
44
-
45
- def menu_items
46
- super
47
- end
48
-
49
- end
50
- end
@@ -1,130 +0,0 @@
1
- module ::Bcome::Stack
2
- class Instance < ::Bcome::Stack::Base
3
-
4
- include ::Bcome::BecomeObject
5
- include ::Bcome::Functions
6
- include ::Bcome::InstanceCommand
7
-
8
- class << self
9
- def collection_from_fog_data(parent, fog_instances)
10
- collection = []
11
- fog_instances.each do |f_instance|
12
-
13
- meta_data = {
14
- :identifier => f_instance.tags["Name"],
15
- :external_network_interface_address => f_instance.private_ip_address,
16
- :public_ip_address => f_instance.public_ip_address,
17
- :role => f_instance.tags["function"]
18
- }
19
- collection << new(meta_data, parent)
20
- end
21
- return collection
22
- end
23
-
24
- def collection_from_config(parent, configuration)
25
- conf_for_env = configuration[:instances]
26
- collection = []
27
- conf_for_env.each do |meta_data|
28
- collection << new(meta_data, parent)
29
- end
30
- return collection
31
- end
32
- end
33
-
34
- attr_reader :environment, :meta_data, :external_network_interface_address, :public_ip_address, :role
35
-
36
- def initialize(meta_data, parent)
37
- @meta_data = meta_data
38
- @environment = parent
39
- @external_network_interface_address = meta_data[:external_network_interface_address]
40
- @public_ip_address = meta_data[:public_ip_address]
41
- @role = meta_data[:role]
42
- end
43
-
44
- def identifier
45
- node.identifier
46
- end
47
-
48
- def override_instance_identifier_for_wbz_stacks?
49
- environment.meta_data[:override_instance_identifier_for_wbz_stacks] ? true : false
50
- end
51
-
52
- def overriden_identifier_prefix
53
- environment.meta_data[:override_instance_identifier_for_wbz_stacks]
54
- end
55
-
56
- def has_sub_nodes?
57
- return false
58
- end
59
-
60
- def do_load_resources
61
- [self]
62
- end
63
-
64
- ## Commands
65
- def ssh
66
- node.ssh
67
- end
68
-
69
- def put(*params)
70
- node.put(*params)
71
- end
72
-
73
- def run(*params)
74
- node.run(*params)
75
- return
76
- end
77
-
78
- def get(*params)
79
- node.get(*params)
80
- end
81
-
82
- def menu_items
83
- super + [
84
- { :command => "run", :description => "Execute a command.", :usage => "run 'command'" },
85
- { :command => "put", :description => "Copy files to remote (recursive - uses rsync)", :usage => "put 'local_path', 'remote_path'" },
86
- { :command => "get", :description => "Download from remote (recursive - uses rsync).", :usage => "get 'remote_path'"},
87
- { :command => "ssh", :description => "Initiate an SSH connection." },
88
- { :command => 'functions', :description => "List all available custom functions" }
89
- ]
90
- end
91
-
92
- def platform
93
- @environment.platform
94
- end
95
-
96
- def is_sudo?
97
- super || @environment.is_sudo?
98
- end
99
-
100
- def responds_to_list?
101
- false
102
- end
103
-
104
- def reference_key
105
- :instances
106
- end
107
-
108
- def child_reference_key
109
- :instance
110
- end
111
-
112
- def highlight?
113
- @environment.object_in_selections?(self)
114
- end
115
-
116
- def do_describe
117
- description = "\tNode Id:".menu_item_cyan + "\s\s#{node.identifier.menu_item_yellow}"
118
- description += "\n\t" + "Internal IP: ".menu_item_cyan + "#{@meta_data[:external_network_interface_address]}".menu_item_white
119
- description += "\n\t" + "External IP: ".menu_item_cyan + "#{node.display_ip_address}".menu_item_white if node.public_ip_address
120
- description += "\n\t" + "Role: ".menu_item_cyan + "#{node.role}".menu_item_white if node.role
121
- description += "\n\n"
122
- return description
123
- end
124
-
125
- def node_level_klass
126
- ::Bcome::Node::Instance
127
- end
128
-
129
- end
130
- end