egon 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/egon/undercloud/installer.rb +4 -4
- data/lib/egon/undercloud/ssh-connection.rb +16 -12
- data/lib/egon/version.rb +1 -1
- data/test/test_undercloud.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDUzYWU0NTIxMzExM2UzODBiMzY4YmJkYzBiODYyNGEwYTQxNDY3Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWUxNWFmM2RkZWNiNDQwZTdlYTkyNWUyMDlhNDg3ZGIwZmMyZjk4Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjAzMDQwNDVjNjgxZGU4ZTMyYjRhOWM4OTQ0MTE5NTQ4MDE5NTE0OTQxMjc1
|
10
|
+
ZDEyMGRjZWM4NTJjYTE3ZjIyODVhYjQzN2I4NTBkMDVhMDVhYTY3M2UyZjc4
|
11
|
+
NTJmOTBmNzVmNmU3OWRjNDlhNDM5NWU5MTkxOGNlZmVkZmZhODE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzlkNmNiMmNiNjc2ZGRhMzY5NzFiNTlmNTJlYzgzMzkxZmQyMTQ1MWUyZTQ4
|
14
|
+
MWJmNzU3NGFhOTAzOWM4MDczZDJiZDUyZTQ4Y2ZmN2JlNGVmMmJjNzVlNGM4
|
15
|
+
NWZiMjkzZjNmZTliNDliOGQ3YjgyYmI2YmY4MWVkNWI3NWU1ZWY=
|
@@ -27,7 +27,7 @@ module Egon
|
|
27
27
|
@failure = bool
|
28
28
|
end
|
29
29
|
|
30
|
-
def install(commands)
|
30
|
+
def install(commands, stringio=nil)
|
31
31
|
@started = true
|
32
32
|
@completed = false
|
33
33
|
|
@@ -35,15 +35,15 @@ module Egon
|
|
35
35
|
@connection.on_failure(lambda { set_failure(true) })
|
36
36
|
|
37
37
|
Thread.new {
|
38
|
-
@connection.execute(commands)
|
38
|
+
@connection.execute(commands, stringio)
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
-
def check_ports
|
42
|
+
def check_ports(stringio=nil)
|
43
43
|
# closed ports 5385, 36357
|
44
44
|
ports = [8774, 9292, 8777, 9696, 8004, 5000, 8585, 15672]
|
45
45
|
ports.each do |p|
|
46
|
-
if !@connection.port_open?(p)
|
46
|
+
if !@connection.port_open?(p, stringio)
|
47
47
|
set_failure(true)
|
48
48
|
end
|
49
49
|
end
|
@@ -14,7 +14,12 @@ module Egon
|
|
14
14
|
@password = password
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def stringio_write(stringio, text)
|
18
|
+
$stdout.puts text if stringio.nil?
|
19
|
+
stringio.puts text unless stringio.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def port_open?(port, stringio=nil, local_ip="127.0.0.1", remote_ip="192.0.2.1", seconds=1)
|
18
23
|
t = Thread.new {
|
19
24
|
begin
|
20
25
|
Net::SSH.start(@host, @user, :password => @password, :timeout => seconds,
|
@@ -25,23 +30,23 @@ module Egon
|
|
25
30
|
session.loop { true }
|
26
31
|
end
|
27
32
|
rescue => e
|
28
|
-
|
33
|
+
stringio_write(stringio, e.message)
|
29
34
|
end
|
30
35
|
}
|
31
36
|
|
32
37
|
sleep 1
|
33
38
|
begin
|
34
39
|
url = "http://#{local_ip}:#{port}"
|
35
|
-
|
40
|
+
stringio_write(stringio, "Testing #{url}")
|
36
41
|
res = Net::HTTP.get_response(URI(url))
|
37
|
-
|
38
|
-
|
42
|
+
stringio_write(stringio, res.body)
|
43
|
+
stringio_write(stringio, "Port #{port} is open")
|
39
44
|
t.kill
|
40
45
|
true
|
41
46
|
rescue => e
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
stringio_write(stringio, e.message)
|
48
|
+
stringio_write(stringio, e.backtrace)
|
49
|
+
stringio_write(stringio, "Port #{port} is closed")
|
45
50
|
t.kill
|
46
51
|
false
|
47
52
|
end
|
@@ -84,14 +89,13 @@ module Egon
|
|
84
89
|
|
85
90
|
# "on_data" is called when the process writes something to stdout
|
86
91
|
ch.on_data do |c, data|
|
87
|
-
|
88
|
-
stringio.puts data unless stringio.nil?
|
92
|
+
stringio_write(stringio, data)
|
89
93
|
end
|
90
94
|
|
91
95
|
# "on_extended_data" is called when the process writes something to stderr
|
92
96
|
ch.on_extended_data do |c, type, data|
|
93
97
|
$stderr.print data if stringio.nil?
|
94
|
-
stringio
|
98
|
+
stringio_write(stringio, data)
|
95
99
|
call_failure
|
96
100
|
end
|
97
101
|
|
@@ -107,7 +111,7 @@ module Egon
|
|
107
111
|
puts e.backtrace.inspect
|
108
112
|
call_failure
|
109
113
|
call_complete
|
110
|
-
stringio
|
114
|
+
stringio_write(stringio, e.message)
|
111
115
|
e.message if stringio.nil?
|
112
116
|
end
|
113
117
|
end
|
data/lib/egon/version.rb
CHANGED
data/test/test_undercloud.rb
CHANGED
@@ -45,6 +45,18 @@ describe "undercloud installer" do
|
|
45
45
|
@installer.check_ports
|
46
46
|
expect(@installer.failure?).to be true
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
|
+
it "consume stdout and stderr from commands" do
|
50
|
+
io = StringIO.new
|
51
|
+
@installer.install("time", io)
|
52
|
+
while !@installer.completed?
|
53
|
+
sleep 1
|
54
|
+
end
|
55
|
+
expect(io.string).to include("execution expired")
|
56
|
+
|
57
|
+
io = StringIO.new
|
58
|
+
@installer.check_ports(io)
|
59
|
+
expect(io.string).to include("Testing")
|
60
|
+
end
|
49
61
|
end
|
50
62
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Egon and Fusor team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|