awslanes 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lanes.rb +56 -54
- data/lib/lanes/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e7eb766d1083a44fa8002155a81c1cb6af9e5cf
|
4
|
+
data.tar.gz: 071f6c24c852a18788f22cf92ead1d8965d95d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41c4c032841db120724ef2264b2d8b68c5d8d941c92adf472d11446f2dab3d7e15a4c23cf8e0c59b6e29cab5884f8df8ce6779425bf31147a7d19bcb109a91cd
|
7
|
+
data.tar.gz: 662db8edaa74645b8ed87f086510775831dd142f3606930a5b18cada5fb4ea40f0e74e4ba01be640a587b925c9254080a35de191b8b5c93bbd195c8cd17ae321
|
data/lib/lanes.rb
CHANGED
@@ -3,8 +3,7 @@ require "lanes/aws"
|
|
3
3
|
require "lanes/props"
|
4
4
|
require "thor"
|
5
5
|
require 'yaml'
|
6
|
-
require '
|
7
|
-
require 'AwsCli/CLI/EC2/Instances'
|
6
|
+
require 'awscli'
|
8
7
|
require 'rest_client'
|
9
8
|
|
10
9
|
class Lanes < Thor
|
@@ -36,6 +35,7 @@ class Lanes < Thor
|
|
36
35
|
method_option :urlConfirm, :type => :string
|
37
36
|
method_option :urlConfirmTimeout, :type => :numeric
|
38
37
|
method_option :v, :type => :boolean
|
38
|
+
method_option :confirm, :type => :boolean
|
39
39
|
desc "sh [LANE] ", "Executes a command on all machines with support for confirming an endpoint is available after"
|
40
40
|
def sh(lane)
|
41
41
|
servers = AWS.instance.fetchServers(lane)
|
@@ -53,67 +53,69 @@ class Lanes < Thor
|
|
53
53
|
|
54
54
|
if options[:confirm] then
|
55
55
|
puts "Confirmed via command line. Moving forward with execution"
|
56
|
+
confirm = 'CONFIRM'
|
56
57
|
else
|
57
58
|
command = options[:cmd].join(' ')
|
58
59
|
confirm = ask "Type CONFIRM to execute \"#{command} \" on these machines:"
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
if confirm == 'CONFIRM' then
|
63
|
+
servers.each{ |server|
|
64
|
+
Net::SSH.start( server[:ip], 'ec2-user',
|
65
|
+
:keys => [identity],
|
66
|
+
# :verbose => :debug,
|
67
|
+
:encryption => "blowfish-cbc",
|
68
|
+
:compression => "zlib",
|
69
|
+
:host_key => "ssh-rsa") do |ssh|
|
70
|
+
puts "Executing on %{name} ( %{ip} ):\t #{command} \n" % server
|
71
|
+
stdout = ''
|
72
|
+
ssh.exec!(command) do |channel, stream, data|
|
73
|
+
stdout << data
|
73
74
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
puts "\t XX #{server[:ip]} connection failed: #{e}" if options[:v]
|
75
|
+
puts "Completed. %{name}\n\tOutput: #{stdout}\n\n " % server
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
confirmPath = options[:urlConfirm]
|
81
|
+
if confirmPath != nil then
|
82
|
+
confirmTimeout = (options[:urlConfirmTimeout] or 30);
|
83
|
+
startTime = Time.new.to_i
|
84
|
+
|
85
|
+
# we better sleep for a few, otherwise the shutdown won't have executed
|
86
|
+
puts "Sleeping for 5 seconds, then trying the confirmation endpoint for #{confirmTimeout} seconds..."
|
87
|
+
sleep 5
|
88
|
+
while Time.new.to_i - startTime < confirmTimeout && servers.length > 0 do
|
89
|
+
servers.each_with_index{ |server, index|
|
90
|
+
begin
|
91
|
+
res = RestClient.get (confirmPath % server)
|
92
|
+
if res.code >= 200 && res.code < 300 then
|
93
|
+
puts "\t => #{server[:ip]} responded with #{res.code}"
|
94
|
+
servers.delete_at(index)
|
95
|
+
else
|
96
|
+
puts "\t XX #{server[:ip]} responded with #{res.code}" if options[:v]
|
97
97
|
end
|
98
|
-
|
98
|
+
rescue => e
|
99
|
+
puts "\t XX #{server[:ip]} connection failed: #{e}" if options[:v]
|
100
|
+
end
|
101
|
+
}
|
99
102
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
+
sleep 5 if servers.length > 0
|
104
|
+
puts "\t => #{servers.length} server(s) remaining..." if servers.length > 0
|
105
|
+
end
|
103
106
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
107
|
+
if servers.length == 0 then
|
108
|
+
puts "Successfully confirmed endpoints responded with a 2XX"
|
109
|
+
else
|
110
|
+
puts "The following server(s) did not respond with a 2XX:"
|
111
|
+
servers.each{ |server|
|
112
|
+
puts "\t%{name} (%{lane}) \t %{ip} \t %{id} " % server
|
113
|
+
}
|
112
114
|
end
|
113
|
-
else
|
114
|
-
puts 'Aborted!'
|
115
|
-
exit 1
|
116
115
|
end
|
116
|
+
else
|
117
|
+
puts 'Aborted!'
|
118
|
+
exit 1
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
data/lib/lanes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awslanes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Welch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.1.11
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Manage "lanes" of AWS machines
|