bcome 1.3.6 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bcome +13 -8
  3. data/lib/bcome.rb +7 -11
  4. data/lib/objects/bcome/version.rb +19 -1
  5. data/lib/objects/bootup.rb +13 -5
  6. data/lib/objects/command/local.rb +2 -0
  7. data/lib/objects/config_factory.rb +3 -0
  8. data/lib/objects/driver/base.rb +36 -4
  9. data/lib/objects/driver/bucket.rb +6 -4
  10. data/lib/objects/driver/ec2.rb +35 -4
  11. data/lib/objects/driver/gcp.rb +124 -0
  12. data/lib/objects/driver/gcp/authentication/api_key.rb +6 -0
  13. data/lib/objects/driver/gcp/authentication/oauth.rb +101 -0
  14. data/lib/objects/driver/gcp/authentication/service_account.rb +7 -0
  15. data/lib/objects/driver/static.rb +2 -0
  16. data/lib/objects/encryptor.rb +26 -24
  17. data/lib/objects/exception/argument_error_invoking_method_from_command_line.rb +8 -4
  18. data/lib/objects/exception/base.rb +14 -10
  19. data/lib/objects/exception/can_only_subselect_on_inventory.rb +8 -4
  20. data/lib/objects/exception/cannot_authenticate_to_gcp.rb +11 -0
  21. data/lib/objects/exception/cannot_find_internal_registry_klass.rb +8 -4
  22. data/lib/objects/exception/cannot_find_inventory.rb +11 -0
  23. data/lib/objects/exception/cannot_find_subselection_parent.rb +8 -4
  24. data/lib/objects/exception/cant_find_key_in_cloud_tags.rb +8 -4
  25. data/lib/objects/exception/cant_find_key_in_metadata.rb +8 -4
  26. data/lib/objects/exception/cant_find_proxy_host_by_identifier.rb +8 -4
  27. data/lib/objects/exception/cant_find_proxy_host_by_namespace.rb +8 -4
  28. data/lib/objects/exception/could_not_initiate_ssh_connection.rb +8 -4
  29. data/lib/objects/exception/could_not_initiate_ssh_connection_through_backend_proxy.rb +8 -4
  30. data/lib/objects/exception/could_not_retrieve_terraform_output.rb +11 -0
  31. data/lib/objects/exception/deprecation_warning.rb +9 -7
  32. data/lib/objects/exception/duplicate_command_line_argument_key.rb +8 -4
  33. data/lib/objects/exception/ec2_driver_missing_provisioning_region.rb +8 -4
  34. data/lib/objects/exception/failed_to_run_local_command.rb +8 -4
  35. data/lib/objects/exception/generic.rb +11 -0
  36. data/lib/objects/exception/interactive_session_halt.rb +6 -2
  37. data/lib/objects/exception/invalid_bcome_breadcrumb.rb +8 -4
  38. data/lib/objects/exception/invalid_breadcrumb.rb +8 -4
  39. data/lib/objects/exception/invalid_context_command.rb +8 -4
  40. data/lib/objects/exception/invalid_gcp_authentication_scheme.rb +11 -0
  41. data/lib/objects/exception/invalid_identifier.rb +8 -4
  42. data/lib/objects/exception/invalid_machines_cache_config.rb +8 -4
  43. data/lib/objects/exception/invalid_matcher_query.rb +8 -4
  44. data/lib/objects/exception/invalid_meta_data_config.rb +8 -4
  45. data/lib/objects/exception/invalid_metadata_encryption_key.rb +8 -4
  46. data/lib/objects/exception/invalid_network_config.rb +8 -4
  47. data/lib/objects/exception/invalid_network_driver_type.rb +8 -4
  48. data/lib/objects/exception/invalid_port_forward_request.rb +11 -0
  49. data/lib/objects/exception/invalid_proxy_config.rb +8 -4
  50. data/lib/objects/exception/invalid_regexp_matcher_in_registry.rb +8 -4
  51. data/lib/objects/exception/invalid_registry_arguments_type.rb +8 -4
  52. data/lib/objects/exception/invalid_registry_command_name_length.rb +8 -4
  53. data/lib/objects/exception/invalid_registry_data_config.rb +8 -4
  54. data/lib/objects/exception/invalid_restriction_key_in_registry.rb +8 -4
  55. data/lib/objects/exception/invalid_ssh_config.rb +8 -4
  56. data/lib/objects/exception/inventories_cannot_have_subviews.rb +8 -4
  57. data/lib/objects/exception/malformed_command_line_arguments.rb +8 -4
  58. data/lib/objects/exception/method_invocation_requires_parameter.rb +8 -4
  59. data/lib/objects/exception/method_name_conflict_in_registry.rb +8 -4
  60. data/lib/objects/exception/missing_argument_for_registry_command.rb +8 -4
  61. data/lib/objects/exception/missing_description_on_view.rb +8 -4
  62. data/lib/objects/exception/missing_execute_on_registry_object.rb +8 -4
  63. data/lib/objects/exception/missing_gcp_authentication_scheme.rb +11 -0
  64. data/lib/objects/exception/missing_gcp_service_scopes.rb +11 -0
  65. data/lib/objects/exception/missing_identifier_on_view.rb +8 -4
  66. data/lib/objects/exception/missing_inventory_contributors.rb +11 -0
  67. data/lib/objects/exception/missing_ip_address_on_server.rb +8 -4
  68. data/lib/objects/exception/missing_network_config.rb +8 -4
  69. data/lib/objects/exception/missing_or_invalid_client_secrets.rb +11 -0
  70. data/lib/objects/exception/missing_params_for_rsync.rb +8 -4
  71. data/lib/objects/exception/missing_params_for_scp.rb +8 -4
  72. data/lib/objects/exception/missing_subselection_key.rb +8 -4
  73. data/lib/objects/exception/missing_type_on_view.rb +8 -4
  74. data/lib/objects/exception/no_node_found_for_breadcrumb.rb +8 -4
  75. data/lib/objects/exception/no_node_named_by_identifier.rb +8 -4
  76. data/lib/objects/exception/node_identifiers_must_be_unique.rb +8 -4
  77. data/lib/objects/exception/orchestration_script_does_not_exist.rb +8 -4
  78. data/lib/objects/exception/proxy_host_node_does_not_have_public_ip_address.rb +8 -4
  79. data/lib/objects/exception/unknown_dynamic_server_type.rb +11 -0
  80. data/lib/objects/exception/unknown_method_for_namespace.rb +8 -4
  81. data/lib/objects/interactive/session.rb +4 -1
  82. data/lib/objects/interactive/session_item/base.rb +2 -0
  83. data/lib/objects/interactive/session_item/capture_input.rb +2 -0
  84. data/lib/objects/interactive/session_item/transparent_ssh.rb +29 -23
  85. data/lib/objects/loading_bar/handler.rb +80 -0
  86. data/lib/objects/loading_bar/indicator/base.rb +64 -0
  87. data/lib/objects/loading_bar/indicator/basic.rb +34 -0
  88. data/lib/objects/loading_bar/indicator/progress.rb +26 -0
  89. data/lib/objects/loading_bar/pid_bucket.rb +27 -0
  90. data/lib/objects/modules/context.rb +13 -9
  91. data/lib/objects/modules/registry_management.rb +16 -10
  92. data/lib/objects/modules/ui_output.rb +10 -6
  93. data/lib/objects/modules/workspace_commands.rb +159 -155
  94. data/lib/objects/modules/workspace_menu.rb +129 -130
  95. data/lib/objects/node/attributes.rb +13 -21
  96. data/lib/objects/node/base.rb +113 -71
  97. data/lib/objects/node/cache_handler.rb +2 -0
  98. data/lib/objects/node/collection.rb +10 -9
  99. data/lib/objects/node/factory.rb +35 -28
  100. data/lib/objects/node/inventory/base.rb +100 -100
  101. data/lib/objects/node/inventory/defined.rb +110 -89
  102. data/lib/objects/node/inventory/merge.rb +43 -0
  103. data/lib/objects/node/inventory/subselect.rb +64 -46
  104. data/lib/objects/node/kube/base.rb +51 -0
  105. data/lib/objects/node/kube/container.rb +9 -0
  106. data/lib/objects/node/kube/estate.rb +19 -0
  107. data/lib/objects/node/kube/namespace.rb +24 -0
  108. data/lib/objects/node/kube/pod.rb +24 -0
  109. data/lib/objects/node/kube_wrap.rb +26 -0
  110. data/lib/objects/node/meta/base.rb +8 -1
  111. data/lib/objects/node/meta/cloud.rb +2 -0
  112. data/lib/objects/node/meta/local.rb +2 -0
  113. data/lib/objects/node/meta_data_factory.rb +3 -1
  114. data/lib/objects/node/meta_data_loader.rb +27 -28
  115. data/lib/objects/node/resources/base.rb +5 -1
  116. data/lib/objects/node/resources/inventory.rb +7 -5
  117. data/lib/objects/node/resources/merged.rb +38 -0
  118. data/lib/objects/node/resources/sub_inventory.rb +7 -4
  119. data/lib/objects/node/server/base.rb +88 -66
  120. data/lib/objects/node/server/dynamic/base.rb +23 -0
  121. data/lib/objects/node/server/{dynamic.rb → dynamic/ec2.rb} +14 -13
  122. data/lib/objects/node/server/dynamic/gcp.rb +47 -0
  123. data/lib/objects/node/server/static.rb +13 -2
  124. data/lib/objects/orchestration/base.rb +10 -0
  125. data/lib/objects/orchestration/interactive_terraform.rb +62 -27
  126. data/lib/objects/orchestrator.rb +22 -0
  127. data/lib/objects/parser/bread_crumb.rb +3 -1
  128. data/lib/objects/registry/arguments/base.rb +3 -1
  129. data/lib/objects/registry/arguments/command_line.rb +6 -1
  130. data/lib/objects/registry/arguments/console.rb +4 -1
  131. data/lib/objects/registry/command/base.rb +3 -0
  132. data/lib/objects/registry/command/external.rb +4 -2
  133. data/lib/objects/registry/command/group.rb +6 -3
  134. data/lib/objects/registry/command/internal.rb +3 -1
  135. data/lib/objects/registry/command/shortcut.rb +17 -9
  136. data/lib/objects/registry/command_list.rb +2 -0
  137. data/lib/objects/registry/loader.rb +10 -10
  138. data/lib/objects/ssh/bootstrap.rb +3 -1
  139. data/lib/objects/ssh/command.rb +10 -5
  140. data/lib/objects/ssh/command_exec.rb +13 -9
  141. data/lib/objects/ssh/connection_wrangler.rb +105 -0
  142. data/lib/objects/ssh/connector.rb +100 -0
  143. data/lib/objects/ssh/driver.rb +27 -230
  144. data/lib/objects/ssh/driver_concerns/command_strings.rb +17 -0
  145. data/lib/objects/ssh/driver_concerns/connection.rb +78 -0
  146. data/lib/objects/ssh/driver_concerns/functions.rb +89 -0
  147. data/lib/objects/ssh/driver_concerns/user.rb +32 -0
  148. data/lib/objects/ssh/{proxy_data.rb → proxy_hop.rb} +52 -7
  149. data/lib/objects/ssh/script_exec.rb +4 -1
  150. data/lib/objects/ssh/tunnel/local_port_forward.rb +5 -6
  151. data/lib/objects/ssh/tunnel_keeper.rb +21 -0
  152. data/lib/objects/ssh/window.rb +31 -0
  153. data/lib/objects/startup.rb +52 -0
  154. data/lib/objects/system/local.rb +3 -0
  155. data/lib/objects/terraform/output.rb +41 -0
  156. data/lib/objects/workspace.rb +3 -14
  157. data/patches/irb.rb +27 -3
  158. data/patches/string-encrypt.rb +20 -23
  159. data/patches/string.rb +5 -1
  160. data/patches/string_stylesheet.rb +2 -0
  161. metadata +95 -18
  162. data/lib/objects/progress_bar.rb +0 -30
  163. data/lib/objects/ssh/connection_handler.rb +0 -101
  164. data/lib/objects/terraform/parser.rb +0 -23
  165. data/lib/objects/terraform/state.rb +0 -40
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module LoadingBar
5
+ module Indicator
6
+ class Base
7
+ CHARACTERS = %w[⣾ ⣷ ⣯ ⣟ ⡿ ⢿ ⣻ ⣽].freeze
8
+
9
+ SIGNAL_SUCCESS = 'USR1'
10
+ SIGNAL_FAILURE = 'USR2'
11
+ SIGNAL_STOP = 'SIGKILL'
12
+
13
+ def initialize(config = {})
14
+ @progress_size = config[:size]
15
+ @title = config[:title]
16
+ @completed_title = config[:completed_title]
17
+
18
+ @current_character = 0
19
+ @progression = ''
20
+ @results = []
21
+ end
22
+
23
+ def indicate
24
+ print "\n"
25
+ loop do
26
+ increment
27
+ show
28
+ end
29
+ end
30
+
31
+ def show
32
+ raise 'Should be overidden'
33
+ end
34
+
35
+ def increment_success
36
+ raise 'Should be overidden'
37
+ end
38
+
39
+ def increment_failure
40
+ raise 'Should be overidden'
41
+ end
42
+
43
+ private
44
+
45
+ def increment
46
+ @current_character += 1
47
+ @current_character = 0 if completed_cycle?
48
+ end
49
+
50
+ def completed_cycle?
51
+ @current_character == CHARACTERS.length
52
+ end
53
+
54
+ def progressed_glyph
55
+ CHARACTERS[0]
56
+ end
57
+
58
+ def glyph
59
+ CHARACTERS[@current_character]
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module LoadingBar
5
+ module Indicator
6
+ class Basic < Base
7
+ def initialize(*params)
8
+ super
9
+ @progress_colour = :bc_green
10
+ end
11
+
12
+ def show(done = false)
13
+ print "\r#{progress_prefix}#{done ? "\s#{@completed_title}\s" : ''}\s"
14
+ rescue ThreadError
15
+ end
16
+
17
+ def progress_prefix
18
+ "#{@title}\s#{glyph.send(progress_colour)}"
19
+ end
20
+
21
+ attr_reader :progress_colour
22
+
23
+ def increment_success
24
+ done = true
25
+ show(done)
26
+ end
27
+
28
+ def increment_failure
29
+ @progress_colour = :bc_red
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module LoadingBar
5
+ module Indicator
6
+ class Progress < Base
7
+ def show
8
+ line = ''
9
+ @results.map { |r| line += (r == 1 ? progressed_glyph.to_s.bc_green.bold : progressed_glyph.to_s.bc_red.bold) }
10
+ line += glyph.bc_orange.to_s * (@progress_size - @results.size)
11
+ print "\r#{@title}\s#{line}\s(#{@results.size}/#{@progress_size})\s"
12
+ end
13
+
14
+ def increment_success
15
+ @results << 1
16
+ @progression += progressed_glyph.bc_green.bold
17
+ end
18
+
19
+ def increment_failure
20
+ @results << 0
21
+ @progression += progressed_glyph.bc_red.bold
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module LoadingBar
5
+ class PidBucket
6
+ include Singleton
7
+
8
+ def initialize
9
+ @pids = []
10
+ end
11
+
12
+ def <<(pid)
13
+ @pids << pid
14
+ end
15
+
16
+ def -(pid)
17
+ @pids -= [pid]
18
+ end
19
+
20
+ def stop_all
21
+ @pids.map do |pid|
22
+ ::Process.kill(::Bcome::LoadingBar::Indicator::Base::SIGNAL_STOP, pid)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,13 +1,17 @@
1
- module Bcome::Context
2
- def is_current_context?
3
- ::Bcome::Workspace.instance.object_is_current_context?(self)
4
- end
1
+ # frozen_string_literal: true
5
2
 
6
- def irb_workspace=(workspace)
7
- @irb_workspace = workspace
8
- end
3
+ module Bcome
4
+ module Context
5
+ def current_context?
6
+ ::Bcome::Workspace.instance.object_is_current_context?(self)
7
+ end
8
+
9
+ def irb_workspace=(workspace)
10
+ @irb_workspace = workspace
11
+ end
9
12
 
10
- def previous_irb_workspace=(workspace)
11
- @previous_workspace = workspace
13
+ def previous_irb_workspace=(workspace)
14
+ @previous_workspace = workspace
15
+ end
12
16
  end
13
17
  end
@@ -1,14 +1,20 @@
1
- module Bcome::Node::RegistryManagement
2
- def user_command_wrapper
3
- @user_command_wrapper ||= ::Bcome::Registry::CommandList.instance.group_for_node(self)
4
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module Node
5
+ module RegistryManagement
6
+ def user_command_wrapper
7
+ @user_command_wrapper ||= ::Bcome::Registry::CommandList.instance.group_for_node(self)
8
+ end
5
9
 
6
- def registry
7
- command_group = user_command_wrapper
8
- if command_group && command_group.has_commands?
9
- command_group.pretty_print
10
- else
11
- puts "\nYou have no registry commands configured for this namespace.\n".warning
10
+ def registry
11
+ command_group = user_command_wrapper
12
+ if command_group&.has_commands?
13
+ command_group.pretty_print
14
+ else
15
+ puts "\nYou have no registry commands configured for this namespace.\n".warning
16
+ end
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -1,9 +1,13 @@
1
- module Bcome::UiOutput
2
- def output_error(string)
3
- no_console_output(string.error)
4
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module UiOutput
5
+ def output_error(string)
6
+ no_console_output(string.error)
7
+ end
5
8
 
6
- def no_console_output(string)
7
- puts "\t\n#{string}\n\n"
9
+ def no_console_output(string)
10
+ puts "\t\n#{string}\n\n"
11
+ end
8
12
  end
9
13
  end
@@ -1,197 +1,201 @@
1
- module Bcome::WorkspaceCommands
2
- def ls(active_only = false)
3
- puts "\n\n" + visual_hierarchy.hierarchy + "\n"
4
- puts "\t" + "Available #{list_key}s:".title + "\n\n"
5
-
6
- iterate_over = active_only ? @resources.active : @resources
7
-
8
- if iterate_over.any?
9
- iterate_over.sort_by(&:identifier).each do |resource|
10
- is_active = @resources.is_active_resource?(resource)
11
- puts resource.pretty_description(is_active)
12
- puts "\n"
1
+ # frozen_string_literal: true
2
+
3
+ module Bcome
4
+ module WorkspaceCommands
5
+ def ssh_connect(params = {})
6
+ ::Bcome::Ssh::Connector.connect(self, params)
7
+ end
8
+
9
+ def ls(node = self, active_only = false)
10
+ if node != self && (resource = resources.for_identifier(node))
11
+ resource.send(:ls, active_only)
12
+ else
13
+ puts "\n\n" + visual_hierarchy.hierarchy + "\n"
14
+ puts "\t" + "Available #{list_key}s:" + "\n\n"
15
+
16
+ iterate_over = active_only ? @resources.active : @resources
17
+
18
+ if iterate_over.any?
19
+
20
+ iterate_over.sort_by(&:identifier).each do |resource|
21
+ next if resource.hide?
22
+
23
+ is_active = @resources.is_active_resource?(resource)
24
+ puts resource.pretty_description(is_active)
25
+
26
+ puts "\n"
27
+ end
28
+ else
29
+ puts "\tNo resources found".informational
30
+ end
31
+
32
+ new_line
33
+ nil
13
34
  end
14
- else
15
- puts "\tNo resources found".informational
16
35
  end
17
36
 
18
- new_line
19
- nil
20
- end
37
+ def lsa
38
+ show_active_only = true
39
+ ls(self, show_active_only)
40
+ end
21
41
 
22
- def lsa
23
- show_active_only = true
24
- ls(show_active_only)
25
- end
42
+ def interactive
43
+ ::Bcome::Interactive::Session.run(self, :interactive_ssh)
44
+ end
26
45
 
27
- def interactive
28
- ::Bcome::Interactive::Session.run(self, :interactive_ssh)
29
- end
46
+ def tree
47
+ puts "\nTree view\n".title
48
+ tab = ''
49
+ print_tree_view_for_resource(tab, self)
50
+ list_in_tree("#{tab}\t", resources)
51
+ print "\n"
52
+ end
30
53
 
31
- def tree
32
- puts "\nTree view\n".title
33
- tab = ''
34
- parents.reverse.each do |p|
35
- print_tree_view_for_resource(tab, p)
36
- tab = "#{tab}\t"
54
+ def parents
55
+ ps = []
56
+ ps << [parent, parent.parents] if has_parent?
57
+ ps.flatten
37
58
  end
38
- print_tree_view_for_resource(tab, self)
39
- list_in_tree("#{tab}\t", resources)
40
- print "\n"
41
- end
42
59
 
43
- def parents
44
- ps = []
45
- ps << [parent, parent.parents] if has_parent?
46
- ps.flatten
47
- end
60
+ def list_in_tree(tab, resources)
61
+ resources.sort_by(&:identifier).each do |resource|
62
+ next if resource.parent && !resource.parent.resources.is_active_resource?(resource)
63
+ next if resource.hide?
48
64
 
49
- def list_in_tree(tab, resources)
50
- resources.sort_by(&:identifier).each do |resource|
51
- next if resource.parent && !resource.parent.resources.is_active_resource?(resource)
52
- resource.load_nodes if resource.inventory? && !resource.nodes_loaded?
53
- print_tree_view_for_resource(tab, resource)
54
- list_in_tree("#{tab}\t", resource.resources)
65
+ resource.load_nodes if resource.inventory? && !resource.nodes_loaded?
66
+ print_tree_view_for_resource(tab, resource)
67
+ list_in_tree("#{tab}\t", resource.resources)
68
+ end
55
69
  end
56
- end
57
70
 
58
- def print_tree_view_for_resource(tab, resource)
59
- separator = '-'
60
- tree_item = tab.to_s + separator.resource_key + " #{resource.type.resource_key} \s#{resource.identifier.resource_value}"
61
- tree_item += ' (empty set)' if !resource.server? && !resource.resources.has_active_nodes?
62
- puts tree_item
63
- end
71
+ def print_tree_view_for_resource(tab, resource)
72
+ separator = '-'
73
+ tree_item = tab.to_s + separator.resource_key + " #{resource.type.resource_key} \s#{resource.identifier.resource_value}"
74
+ tree_item += ' (empty set)' if !resource.server? && !resource.resources.has_active_nodes?
75
+ puts tree_item
76
+ end
64
77
 
65
- def cd(identifier)
66
- if resource = resources.for_identifier(identifier)
67
- if resource.parent.resources.is_active_resource?(resource)
68
- ::Bcome::Workspace.instance.set(current_context: self, context: resource)
78
+ def cd(identifier)
79
+ if (resource = resources.for_identifier(identifier))
80
+ if resource.parent.resources.is_active_resource?(resource)
81
+ ::Bcome::Workspace.instance.set(current_context: self, context: resource)
82
+ else
83
+ puts "\nCannot enter context - #{identifier} is disabled. To enable enter 'enable #{identifier}'\n".error
84
+ end
69
85
  else
70
- puts "\nCannot enter context - #{identifier} is disabled. To enable enter 'enable #{identifier}'\n".error
86
+ raise Bcome::Exception::InvalidBreadcrumb, "Cannot find a node named '#{identifier}'"
87
+ puts "#{identifier} not found"
71
88
  end
72
- else
73
- raise Bcome::Exception::InvalidBreadcrumb, "Cannot find a node named '#{identifier}'"
74
- puts "#{identifier} not found"
75
89
  end
76
- end
77
90
 
78
- def run(*raw_commands)
79
- raise Bcome::Exception::MethodInvocationRequiresParameter, "Please specify commands when invoking 'run'" if raw_commands.empty?
80
- results = {}
91
+ def run(*raw_commands)
92
+ raise Bcome::Exception::MethodInvocationRequiresParameter, "Please specify commands when invoking 'run'" if raw_commands.empty?
93
+
94
+ results = {}
81
95
 
82
- ::Bcome::Ssh::ConnectionHandler.connect(self, {})
96
+ ssh_connect(show_progress: true)
83
97
 
84
- machines.pmap do |machine|
85
- commands = machine.do_run(raw_commands)
86
- results[machine.namespace] = commands
98
+ machines.pmap do |machine|
99
+ commands = machine.do_run(raw_commands)
100
+ results[machine.namespace] = commands
101
+ end
102
+ results
87
103
  end
88
- results
89
- end
90
104
 
91
- def ping
92
- ::Bcome::Ssh::ConnectionHandler.connect(self, is_ping: true)
93
- end
105
+ def ping
106
+ ssh_connect(is_ping: true, show_progress: true)
107
+ end
94
108
 
95
- def pretty_description(is_active = true)
96
- desc = ''
97
- list_attributes.each do |key, value|
98
- next unless respond_to?(value) || instance_variable_defined?("@#{value}")
99
- attribute_value = send(value)
100
- next unless attribute_value
101
-
102
- desc += "\t"
103
- desc += is_active ? key.to_s.resource_key : key.to_s.resource_key_inactive
104
- desc += "\s" * (12 - key.length)
105
- desc += is_active ? attribute_value.resource_value : attribute_value.resource_value_inactive
106
- desc += "\n"
107
- desc = desc unless is_active
108
- end
109
- desc
110
- end
109
+ def pretty_description(is_active = true)
110
+ desc = ''
111
+ list_attributes.each do |key, value|
112
+ next unless respond_to?(value) || instance_variable_defined?("@#{value}")
111
113
 
112
- def back
113
- exit
114
- end
114
+ attribute_value = send(value)
115
+ next unless attribute_value
115
116
 
116
- def disable(*ids)
117
- ids.each { |id| resources.do_disable(id) }
118
- end
117
+ desc += "\t"
118
+ desc += is_active ? key.to_s.resource_key : key.to_s.resource_key_inactive
119
+ desc += "\s" * (12 - key.length)
120
+ desc += is_active ? attribute_value.resource_value : attribute_value.resource_value_inactive
121
+ desc += "\n"
122
+ desc = desc unless is_active
123
+ end
124
+ desc
125
+ end
119
126
 
120
- def enable(*ids)
121
- ids.each { |id| resources.do_enable(id) }
122
- end
127
+ def back
128
+ exit
129
+ end
123
130
 
124
- def clear!
125
- # Clear any disabled selection at this level and at all levels below
126
- resources.clear!
127
- resources.each(&:clear!)
128
- nil
129
- end
131
+ def disable(*ids)
132
+ ids.each { |id| resources.do_disable(id) }
133
+ end
130
134
 
131
- def workon(*ids)
132
- resources.disable!
133
- ids.each { |id| resources.do_enable(id) }
134
- puts "\nYou are now working on '#{ids.join(', ')}\n".informational
135
- end
135
+ def enable(*ids)
136
+ ids.each { |id| resources.do_enable(id) }
137
+ end
136
138
 
137
- def disable!
138
- resources.disable!
139
- resources.each(&:disable!)
140
- nil
141
- end
139
+ def clear!
140
+ # Clear any disabled selection at this level and at all levels below
141
+ resources.clear!
142
+ resources.each(&:clear!)
143
+ nil
144
+ end
142
145
 
143
- def enable!
144
- resources.enable!
145
- resources.each(&:enable!)
146
- nil
147
- end
146
+ def workon(*ids)
147
+ resources.disable!
148
+ ids.each { |id| resources.do_enable(id) }
149
+ puts "\nYou are now working on '#{ids.join(', ')}\n".informational
150
+ end
148
151
 
149
- ## Helpers --
152
+ def disable!
153
+ resources.disable!
154
+ resources.each(&:disable!)
155
+ nil
156
+ end
150
157
 
151
- def resource_identifiers
152
- resources.collect(&:identifier)
153
- end
158
+ def enable!
159
+ resources.enable!
160
+ resources.each(&:enable!)
161
+ nil
162
+ end
154
163
 
155
- def is_node_level_method?(method_sym)
156
- respond_to?(method_sym) || method_is_available_on_node?(method_sym)
157
- end
164
+ ## Helpers --
158
165
 
159
- def method_missing(method_sym, *arguments)
160
- unless method_is_available_on_node?(method_sym)
161
- raise NameError, "NameError: undefined local variable or method '#{method_sym}'"
166
+ def resource_identifiers
167
+ resources.collect(&:identifier)
162
168
  end
163
169
 
164
- if resource_identifiers.include?(method_sym.to_s)
165
- method_sym.to_s
166
- elsif instance_variable_defined?("@#{method_sym}")
167
- instance_variable_get("@#{method_sym}")
168
- else
169
- command = user_command_wrapper.command_for_console_command_name(method_sym)
170
- command.execute(self, arguments)
170
+ def is_node_level_method?(method_sym)
171
+ respond_to?(method_sym) || method_is_available_on_node?(method_sym)
171
172
  end
172
- end
173
173
 
174
- def method_in_registry?(method_sym)
175
- ::Bcome::Registry::CommandList.instance.command_in_list?(self, method_sym)
176
- end
174
+ def method_in_registry?(method_sym)
175
+ ::Bcome::Registry::CommandList.instance.command_in_list?(self, method_sym)
176
+ end
177
177
 
178
- def method_is_available_on_node?(method_sym)
179
- resource_identifiers.include?(method_sym.to_s) || instance_variable_defined?("@#{method_sym}") || method_in_registry?(method_sym) || respond_to?(method_sym)
180
- end
178
+ def method_is_available_on_node?(method_sym)
179
+ resource_identifiers.include?(method_sym.to_s) || method_in_registry?(method_sym) || respond_to?(method_sym) || instance_variable_defined?("@#{method_sym}")
180
+ end
181
181
 
182
- def visual_hierarchy
183
- tabs = 0
184
- hierarchy = ''
185
- tree_descriptions.each { |d| hierarchy += "#{"\s\s\s" * tabs}|- #{d}\n"; tabs += 1; }
186
- hierarchy
187
- end
182
+ def visual_hierarchy
183
+ tabs = 0
184
+ hierarchy = ''
185
+ tree_descriptions.each do |d|
186
+ hierarchy += "#{"\s\s\s" * tabs}|- #{d}\n"
187
+ tabs += 1
188
+ end
189
+ hierarchy
190
+ end
188
191
 
189
- def tree_descriptions
190
- d = parent ? parent.tree_descriptions + [description] : [description]
191
- d.flatten
192
- end
192
+ def tree_descriptions
193
+ d = parent ? parent.tree_descriptions + [description] : [description]
194
+ d.flatten
195
+ end
193
196
 
194
- def new_line
195
- puts "\n"
197
+ def new_line
198
+ puts "\n"
199
+ end
196
200
  end
197
201
  end