egon 0.4.0 → 0.4.1

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
- ODI2YTNiNDM5NGU1NTBlZTc3NGM5M2ViNjI2YWEyNzg4ZDRhZDg2ZA==
4
+ NzE0ZTI5YTgxYTNlYWI1ZjE1MjgwZGVkZDc3MzA5NDkyNWQxMjdhMA==
5
5
  data.tar.gz: !binary |-
6
- MTJlMDY5OTA1YTk3MzgwNWJkNTk4ZWMxZmIwMGFjNjJhOTkyYTRjMg==
6
+ ODg3OTk1MjMyMDQ3OTg0MTJhNGU3ZTYwZjQzNTUzZDViYjg1YWYzOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGJlYjMyNzhlYTc2ZWE1Nzc3ZjFhMWZjM2U1YTA3MmMyZmE2NzEzOTA3YTVk
10
- MzAyMDNkOGM0ZGFiMmU4OWY5ZDg4YjIwYTQzYjM1ZjMyZmIyYjg4NWY0Y2Rh
11
- Y2RlZjA5MzA5ZmZhZjQ1MGQ4ZjgwNTRlYzc3MmNlYmFlYWM2ODM=
9
+ YzJiMmFlZTZmZDlkMDMxZDM5NGJkZjMyNDgzZjk1NDNhZGZmYjQ0ZTcwMGRj
10
+ NGM0OGQwODkwZmIyM2I3NjAxZGVmMWFjNzFiOGRlNmFiYmRkZTY4NzYyYzU3
11
+ ZWU1YzUwNWUyZmI5YzFmNGQyMDg5MDUzYTVkNDRlNGM0ZDNiZTc=
12
12
  data.tar.gz: !binary |-
13
- MTVkOWFjOWM5MjZiYTJiNDhhMWNkMGFmYzNkMTZlYTk3YWJiNmRmMzQzZGVh
14
- OTdmZDI0MjU2MWY1MmFkMzk2MzI3Mzg5N2I4OTBjODBkZDVjNDExY2NiMDUx
15
- YjljNTI0NmYyZjU0MjQ0YTk1YTJjNTE2OTAxMmM2Y2VkYzc4MGI=
13
+ YmI4MTA2N2MwNzU5Yzc4N2U0YTM2OTVkZjBjYzM5NDJkZjhmYmUwMWIxZTQ1
14
+ ZGYwNWE1Y2E0NTU3YzI2OGVmZTliMWFlMzVjZDhlNmY4NGZhZTE0ZGE3YWZi
15
+ YTY2MTFkZWQzZjcxN2M3ODA5ZjVjZjJiMjE3NzJmN2NkYmZmMjU=
@@ -0,0 +1,6 @@
1
+ require 'egon/undercloud/commands'
2
+ require 'egon/undercloud/installer'
3
+
4
+ installer = Egon::Undercloud::Installer.new
5
+ installer.install(Egon::Undercloud::Commands.OSP7_no_registration)
6
+ installer.check_ports
@@ -8,8 +8,7 @@ module Egon
8
8
  curl -k -O #{satellite_url}/pub/katello-ca-consumer-latest.noarch.rpm
9
9
  sudo yum install -y katello-ca-consumer-latest.noarch.rpm
10
10
  sudo subscription-manager register --org=\"#{org}\" --activationkey=\"#{activation_key}\"
11
- sudo yum clean all
12
- #{OSP7_COMMON}"
11
+ #{self.OSP7_COMMON_no_registration}"
13
12
  end
14
13
 
15
14
  def self.OSP7_vanilla_rhel(rhsm_user, rhsm_password, rhsm_pool_id)
@@ -19,19 +18,28 @@ module Egon
19
18
  sudo subscription-manager repos --enable=rhel-7-server-rpms \
20
19
  --enable=rhel-7-server-optional-rpms --enable=rhel-7-server-extras-rpms \
21
20
  --enable=rhel-7-server-openstack-6.0-rpms
22
- #{OSP7_COMMON}"
21
+ #{self.OSP7_no_registration}"
23
22
  end
24
23
 
25
- def self.OSP7_instack_virt
24
+ def self.OSP7_no_registration
25
+ return "
26
+ sudo yum install -y python-rdomanager-oscplugin
27
+ if [ ! -f ~/undercloud.conf ]; then
28
+ cp -f /usr/share/instack-undercloud/undercloud.conf.sample ~/undercloud.conf;
29
+ fi
30
+ #{self.OSP7_no_registration_no_packages}"
31
+ end
32
+
33
+ def self.OSP7_no_registration_no_packages
26
34
  return OSP7_COMMON
27
35
  end
28
36
 
29
37
  POST_INSTALL = "
30
- source stackrc
31
- source tripleo-undercloud-passwords
38
+ source ~/stackrc
39
+ source ~/tripleo-undercloud-passwords
32
40
 
33
- tripleo setup-overcloud-passwords -o tripleo-overcloud-passwords
34
- source tripleo-overcloud-passwords
41
+ tripleo setup-overcloud-passwords -o ~/tripleo-overcloud-passwords
42
+ source ~/tripleo-overcloud-passwords
35
43
  NeutronFlatNetworks=${NeutronFlatNetworks:-'datacentre'}
36
44
  NeutronPhysicalBridge=${NeutronPhysicalBridge:-'br-ex'}
37
45
  NeutronBridgeMappings=${NeutronBridgeMappings:-'datacentre:br-ex'}
@@ -222,19 +230,13 @@ module Egon
222
230
  "
223
231
 
224
232
  OSP7_COMMON = "
225
- sudo yum install -y http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
226
- sudo yum install -y https://rdoproject.org/repos/openstack-kilo/rdo-release-kilo.rpm
227
- sudo curl -o /etc/yum.repos.d/rdo-management-trunk.repo http://trunk-mgt.rdoproject.org/centos-kilo/current-passed-ci/delorean-rdo-management.repo
228
- sudo yum install -y python-rdomanager-oscplugin
229
- # TODO: answers file should come from RHCI
230
- cp -f /usr/share/instack-undercloud/undercloud.conf.sample ~/undercloud.conf;
231
- # TODO: for baremetal a nodes.csv file may also be required
232
233
  openstack undercloud install
233
- sudo cp /root/tripleo-undercloud-passwords .
234
- sudo chown $USER: tripleo-undercloud-passwords
235
- sudo cp /root/stackrc .
236
- sudo chown $USER: stackrc
234
+ sudo cp /root/tripleo-undercloud-passwords ~
235
+ sudo chown $USER: ~/tripleo-undercloud-passwords
236
+ sudo cp /root/stackrc ~
237
+ sudo chown $USER: ~/stackrc
237
238
  #{POST_INSTALL}"
239
+
238
240
  end
239
241
  end
240
242
  end
@@ -1,50 +1,69 @@
1
+ require 'egon/undercloud/port-check-mixin'
2
+ require 'stringio'
3
+
1
4
  module Egon
2
5
  module Undercloud
3
6
  class Installer
7
+ include PortCheckMixin
8
+
4
9
  attr_reader :started
5
10
  alias_method :started?, :started
6
-
7
- def initialize(connection)
11
+
12
+ # installs locally if ssh connection is not provided
13
+ def initialize(connection=nil)
8
14
  @connection = connection
9
15
  @completed = false
10
16
  @started = false
11
17
  @failure = false
12
18
  end
13
-
19
+
14
20
  def completed?
15
21
  @completed
16
22
  end
17
-
23
+
18
24
  def set_completed(bool)
19
25
  @completed = bool
20
26
  end
21
-
27
+
22
28
  def failure?
23
29
  @failure
24
30
  end
25
-
31
+
26
32
  def set_failure(bool)
27
33
  @failure = bool
28
34
  end
29
-
35
+
30
36
  def install(commands, stringio=nil)
31
37
  @started = true
32
38
  @completed = false
33
-
34
- @connection.on_complete(lambda { set_completed(true) })
35
- @connection.on_failure(lambda { set_failure(true) })
36
-
37
- Thread.new {
38
- @connection.execute(commands, stringio)
39
- }
39
+
40
+ if !@connection.nil?
41
+ # remote install
42
+ @connection.on_complete(lambda { set_completed(true) })
43
+ @connection.on_failure(lambda { set_failure(true) })
44
+
45
+ Thread.new {
46
+ @connection.execute(commands, stringio)
47
+ }
48
+ else
49
+ # local install
50
+ set_failure(true) unless system(commands)
51
+ set_completed(true)
52
+ end
40
53
  end
41
54
 
42
55
  def check_ports(stringio=nil)
43
56
  # closed ports 5385, 36357
44
57
  ports = [8774, 9292, 8777, 9696, 8004, 5000, 8585, 15672]
45
58
  ports.each do |p|
46
- if !@connection.port_open?(p, stringio)
47
- set_failure(true)
59
+ if !@connection.nil?
60
+ # remote check
61
+ if !@connection.remote_port_open?(p, stringio)
62
+ set_failure(true)
63
+ end
64
+ else
65
+ # local check
66
+ set_failure(true) unless !port_open?("192.0.2.1", p, stringio)
48
67
  end
49
68
  end
50
69
  end
@@ -0,0 +1,29 @@
1
+ require 'net/http'
2
+
3
+ module Egon
4
+ module Undercloud
5
+ module PortCheckMixin
6
+
7
+ def stringio_write(stringio, text)
8
+ $stdout.puts text if stringio.nil?
9
+ stringio.puts text unless stringio.nil?
10
+ end
11
+
12
+ def port_open?(ip, port, stringio=nil)
13
+ begin
14
+ url = "http://#{ip}:#{port}"
15
+ stringio_write(stringio, "Testing #{url}")
16
+ res = Net::HTTP.get_response(URI(url))
17
+ stringio_write(stringio, res.body)
18
+ stringio_write(stringio, "Port #{port} is open")
19
+ true
20
+ rescue => e
21
+ stringio_write(stringio, e.message)
22
+ stringio_write(stringio, e.backtrace)
23
+ stringio_write(stringio, "Port #{port} is closed")
24
+ false
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,4 @@
1
+ require 'egon/undercloud/port-check-mixin'
1
2
  require 'net/http'
2
3
  require 'net/ssh'
3
4
  require 'stringio'
@@ -8,6 +9,8 @@ require 'stringio'
8
9
  module Egon
9
10
  module Undercloud
10
11
  class SSHConnection
12
+ include PortCheckMixin
13
+
11
14
  def initialize(host, user, password)
12
15
  @host = host
13
16
  @user = user
@@ -19,7 +22,7 @@ module Egon
19
22
  stringio.puts text unless stringio.nil?
20
23
  end
21
24
 
22
- def port_open?(port, stringio=nil, local_ip="127.0.0.1", remote_ip="192.0.2.1", seconds=1)
25
+ def remote_port_open?(port, stringio=nil, local_ip="127.0.0.1", remote_ip="192.0.2.1", seconds=1)
23
26
  t = Thread.new {
24
27
  begin
25
28
  Net::SSH.start(@host, @user, :password => @password, :timeout => seconds,
@@ -35,39 +38,27 @@ module Egon
35
38
  }
36
39
 
37
40
  sleep 1
38
- begin
39
- url = "http://#{local_ip}:#{port}"
40
- stringio_write(stringio, "Testing #{url}")
41
- res = Net::HTTP.get_response(URI(url))
42
- stringio_write(stringio, res.body)
43
- stringio_write(stringio, "Port #{port} is open")
44
- t.kill
45
- true
46
- rescue => e
47
- stringio_write(stringio, e.message)
48
- stringio_write(stringio, e.backtrace)
49
- stringio_write(stringio, "Port #{port} is closed")
50
- t.kill
51
- false
52
- end
41
+ port_status = port_open?(local_ip, port, stringio)
42
+ t.kill
43
+ port_status
53
44
  end
54
-
45
+
55
46
  def call_complete
56
47
  @on_complete.call if @on_complete
57
48
  end
58
-
49
+
59
50
  def on_complete(hook)
60
51
  @on_complete = hook
61
52
  end
62
-
53
+
63
54
  def call_failure
64
55
  @on_failure.call if @on_failure
65
56
  end
66
-
57
+
67
58
  def on_failure(hook)
68
59
  @on_failure = hook
69
60
  end
70
-
61
+
71
62
  def execute(commands, stringio = nil)
72
63
  begin
73
64
  # :timeout => how long to wait for the initial connection to be made
@@ -86,23 +77,23 @@ module Egon
86
77
  end
87
78
  ch.exec commands do |ch, success|
88
79
  call_failure unless success
89
-
80
+
90
81
  # "on_data" is called when the process writes something to stdout
91
82
  ch.on_data do |c, data|
92
83
  stringio_write(stringio, data)
93
84
  end
94
-
85
+
95
86
  # "on_extended_data" is called when the process writes something to stderr
96
87
  ch.on_extended_data do |c, type, data|
97
88
  $stderr.print data if stringio.nil?
98
89
  stringio_write(stringio, data)
99
90
  call_failure
100
91
  end
101
-
92
+
102
93
  ch.on_close { call_complete }
103
94
  end
104
95
  end
105
-
96
+
106
97
  channel.wait
107
98
  end
108
99
  call_complete
data/lib/egon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Egon
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -12,6 +12,6 @@ describe "SSHConnection" do
12
12
 
13
13
  it "check port is open" do
14
14
  connection = Egon::Undercloud::SSHConnection.new("127.0.0.1", "stack", "test")
15
- connection.port_open?(1111).should eq false
15
+ connection.remote_port_open?(1111).should eq false
16
16
  end
17
17
  end
@@ -59,4 +59,31 @@ describe "undercloud installer" do
59
59
  expect(io.string).to include("Testing")
60
60
  end
61
61
  end
62
-
62
+
63
+ describe "local installer" do
64
+
65
+ before do
66
+ @installer = Egon::Undercloud::Installer.new
67
+ end
68
+
69
+ it "local installer runs successfully" do
70
+ @installer.install("date")
71
+ while !@installer.completed?
72
+ sleep 1
73
+ end
74
+ expect(@installer.failure?).to be false
75
+
76
+ io = StringIO.new
77
+ @installer.check_ports(io)
78
+ expect(io.string).to include("Testing")
79
+ end
80
+
81
+ it "local install fails and is detected" do
82
+ @installer.install("blah")
83
+ while !@installer.completed?
84
+ sleep 1
85
+ end
86
+ expect(@installer.failure?).to be true
87
+ end
88
+
89
+ end
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.4.0
4
+ version: 0.4.1
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-08-03 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,7 +84,7 @@ description: ''
84
84
  email:
85
85
  - foreman-dev+egon@googlegroups.com
86
86
  executables:
87
- - undercloud-install-instack-virt.rb
87
+ - undercloud-install-local.rb
88
88
  - undercloud-install-satellite.rb
89
89
  - undercloud-install-vanilla-rhel.rb
90
90
  extensions: []
@@ -96,7 +96,7 @@ files:
96
96
  - LICENSE
97
97
  - README.md
98
98
  - Rakefile
99
- - bin/undercloud-install-instack-virt.rb
99
+ - bin/undercloud-install-local.rb
100
100
  - bin/undercloud-install-satellite.rb
101
101
  - bin/undercloud-install-vanilla-rhel.rb
102
102
  - egon.gemspec
@@ -109,6 +109,7 @@ files:
109
109
  - lib/egon/overcloud/undercloud_handle/node.rb
110
110
  - lib/egon/undercloud/commands.rb
111
111
  - lib/egon/undercloud/installer.rb
112
+ - lib/egon/undercloud/port-check-mixin.rb
112
113
  - lib/egon/undercloud/ssh-connection.rb
113
114
  - lib/egon/version.rb
114
115
  - rubygem-egon.spec
@@ -1,15 +0,0 @@
1
- require 'egon/undercloud/commands'
2
- require 'egon/undercloud/ssh-connection'
3
- require 'egon/undercloud/installer'
4
-
5
- SSH_HOST = ARGV[0]
6
- SSH_USER = ARGV[1]
7
- SSH_PASSWORD = ARGV[2]
8
-
9
- connection = Egon::Undercloud::SSHConnection.new(SSH_HOST, SSH_USER, SSH_PASSWORD)
10
- installer = Egon::Undercloud::Installer.new(connection)
11
- installer.install(Egon::Undercloud::Commands.OSP7_instack_virt)
12
- while !installer.completed?
13
- sleep 1
14
- end
15
- installer.check_ports