bcome 0.6.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e0ef34cf4079f32b9f5a8472f55f8e7fe3186cf
4
- data.tar.gz: 3e14c57b673789e26c1f3553ab478351ffc21cb3
3
+ metadata.gz: 72e854219fe3f3151e3beab00428c300540f1ca6
4
+ data.tar.gz: 5abe63e971b7994a35a5e45fe07a51f8f4ed657f
5
5
  SHA512:
6
- metadata.gz: 91e0a4100fa35de6558e854509ff45303ec6c86f15190b8f5feddc47440e732c778c6663a735de45426880671e03bde0a5b67405406e6a5590513d20563016e3
7
- data.tar.gz: ea5ee12c471a79b03252598e92d0160da2426625ce065a31600f971f8c298fb37433a76ab10d8acbfecb667eb4d28b6783e0da2cd5d2924de9ea1eb282c9e884
6
+ metadata.gz: 8031edcc26bff2f693e28fbe65a254569d12be4e8e1ea7c6329775bbfcb800014d35cff7e760f8c2f4bf07f7d4da9b6c57d232ac795bb5e097736ca9c4c1a002
7
+ data.tar.gz: 443b70d8c51e468f1658756e60e65c02bd7adf673a1aa3872f6a70be2675a02ca3189596bbe6b5464ab0f55db58b548d938741f9b6be3e1c2c07fec062946f09
data/lib/bcome.rb CHANGED
@@ -2,7 +2,7 @@ require 'rainbow'
2
2
  require 'aws-sdk'
3
3
  require 'net/scp'
4
4
  require 'net/ssh/proxy/command'
5
- require 'fog'
5
+ require 'fog/aws'
6
6
  require 'require_all'
7
7
  require 'pmap'
8
8
 
data/lib/bcome/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.3"
3
3
  end
@@ -4,7 +4,8 @@ module Bcome::Interactive::SessionItem
4
4
  END_SESSION_KEY = "\\q"
5
5
  HELP_KEY = "\\?"
6
6
  LIST_KEY = "\\l"
7
-
7
+
8
+ DANGER_CMD = "rm\s+-r|rm\s+-f|rm\s+-fr|rm\s+-rf|rm"
8
9
  def do
9
10
  input = get_input
10
11
  raise ::Bcome::Interactive::SessionHalt.new if exit?(input)
@@ -12,6 +13,8 @@ module Bcome::Interactive::SessionItem
12
13
  show_menu
13
14
  elsif list_machines?(input)
14
15
  list_machines
16
+ elsif command_may_be_unwise?(input)
17
+ handle_the_unwise(input)
15
18
  else
16
19
  execute_on_machines(input)
17
20
  end
@@ -22,11 +25,28 @@ module Bcome::Interactive::SessionItem
22
25
  system("clear") ; print start_message
23
26
  end
24
27
 
28
+ def handle_the_unwise(input)
29
+ if prompt_for_confirmation("Command may be dangerous to run on all machines. Are you sure you want to proceed? [Y|N] > ".danger)
30
+ execute_on_machines(input)
31
+ end
32
+ end
33
+
34
+ def command_may_be_unwise?(input)
35
+ input =~ /#{DANGER_CMD}/
36
+ end
37
+
38
+ def prompt_for_confirmation(message)
39
+ answer = get_input(message)
40
+ unless ["Y", "N"].include?(answer)
41
+ prompt_for_confirmation(message)
42
+ end
43
+ return answer == "Y" ? true : false
44
+ end
45
+
25
46
  def start_message
26
- warning = "\nCommands entered here will be executed on every machine in your selection.".danger
27
- second_warning = "\nUse with CAUTION.".danger
47
+ warning = "\nCommands entered here will be executed on EVERY machine in your selection.".danger
48
+ second_warning = "\n\nUse with CAUTION.".danger
28
49
  info = "\n\n\\l list machines\n\\q to quit\n\\? this message".informational
29
-
30
50
  return "#{warning}#{second_warning}#{info}\n"
31
51
  end
32
52
 
@@ -51,8 +71,8 @@ module Bcome::Interactive::SessionItem
51
71
  input == LIST_KEY
52
72
  end
53
73
 
54
- def get_input
55
- return ::Readline.readline("\n#{terminal_prompt}", true).squeeze(" " ).to_s
74
+ def get_input(message = terminal_prompt)
75
+ return ::Readline.readline("\n#{message}", true).squeeze(" " ).to_s
56
76
  end
57
77
 
58
78
  def execute_on_machines(user_input)
@@ -62,12 +82,23 @@ module Bcome::Interactive::SessionItem
62
82
  end
63
83
 
64
84
  def list_machines
65
- listed = "\n#{machines.collect(&:identifier).join(", ")}\n"
66
- print listed.friendly
85
+ puts "\n" + machines.collect {|m|
86
+ env = m.environment
87
+ platform = env.platform
88
+ "* #{platform.identifier.cyan}:#{env.identifier.orange}:#{m.identifier.yellow}"
89
+ }.join("\n")
67
90
  end
68
91
 
69
92
  def machines
70
- @machines ||= has_selected_machines? ? selected_machines : @irb_session.resources.collect(&:node)
93
+ @machines ||= has_selected_machines? ? selected_machines : flat_list_of_machines
94
+ end
95
+
96
+ def flat_list_of_machines
97
+ resources.collect{|resource| resource.node.machines }.flatten
98
+ end
99
+
100
+ def resources
101
+ @irb_session.resources
71
102
  end
72
103
 
73
104
  def has_selected_machines?
@@ -49,7 +49,9 @@ class String
49
49
  :menu_title_cyan => { :colour => :cyan, :highlight => true },
50
50
  :headsup => { :colour => :orange, :highlight => true },
51
51
  :menu_item_magenta => { :colour => :magenta },
52
- :cyan => { :colour => :cyan }
52
+ :cyan => { :colour => :cyan },
53
+ :yellow => { :colour => :yellow },
54
+ :orange => { :colour => :orange }
53
55
  }
54
56
  end
55
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Roderick (Webzakimbo)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -73,19 +73,19 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: fog
76
+ name: fog-aws
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '='
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 1.33.0
81
+ version: 0.12.0
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '='
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 1.33.0
88
+ version: 0.12.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: require_all
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.2.2
208
+ rubygems_version: 2.6.7
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Toolkit for managing machines - simplify your workflow.