egon 0.3.4 → 0.3.5

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGI4YzRiNTE3ZTlkOThjOTRmODczN2Q3MDNhMTkyZTAyYTdlNDY3OA==
4
+ NDUzYWU0NTIxMzExM2UzODBiMzY4YmJkYzBiODYyNGEwYTQxNDY3Mg==
5
5
  data.tar.gz: !binary |-
6
- NDViMDZiNGE1NWQyNzAxNWJlNDNjMTc2NDllYzM4NjBhZjNjN2VmNQ==
6
+ YWUxNWFmM2RkZWNiNDQwZTdlYTkyNWUyMDlhNDg3ZGIwZmMyZjk4Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDYzN2E2ZTk5MWFjZGY0YTc5NTU1ZDIwMDYyNzIxMDRhYzU2MTNjNDk4NmE4
10
- NGE3ZjkzZDU5MmU2OWIwODQ3MDU5Y2YxYWZjZGU2ZmM5ZGE2ZDFjZThjMTZi
11
- MTUwYzg1Mjc4MmE1ZThiODNkNjEyM2Y0YmExMmE2YmRmMmVhNGQ=
9
+ ZjAzMDQwNDVjNjgxZGU4ZTMyYjRhOWM4OTQ0MTE5NTQ4MDE5NTE0OTQxMjc1
10
+ ZDEyMGRjZWM4NTJjYTE3ZjIyODVhYjQzN2I4NTBkMDVhMDVhYTY3M2UyZjc4
11
+ NTJmOTBmNzVmNmU3OWRjNDlhNDM5NWU5MTkxOGNlZmVkZmZhODE=
12
12
  data.tar.gz: !binary |-
13
- ODFhNjJiOWJlMzQxODY5NTU3N2ViOGIxM2YyYWI4NDgzNDU1NDc0MTk2MDZk
14
- MjMyODEzODJkZjQ4OGEyMDUwYjYxNjU3ZjU3MDBkMzQ3ZDQ5ZmZjMDBjMGIx
15
- MDEzY2VjZWJkNmI3ZTA4MzU3ZjI1MTY0NjI1ZTI1MWEwYTFjZTM=
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 port_open?(port, local_ip="127.0.0.1", remote_ip="192.0.2.1", seconds=1)
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
- puts e.message
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
- puts "Testing #{url}"
40
+ stringio_write(stringio, "Testing #{url}")
36
41
  res = Net::HTTP.get_response(URI(url))
37
- puts res.body
38
- puts "Port #{port} is open"
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
- puts e.message
43
- puts e.backtrace
44
- puts "Port #{port} is closed"
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
- $stdout.print data if stringio.nil?
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.puts data unless stringio.nil?
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.puts e.message unless stringio.nil?
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
@@ -1,3 +1,3 @@
1
1
  module Egon
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -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
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-16 00:00:00.000000000 Z
11
+ date: 2015-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler