Class: Egon::Undercloud::Installer
- Inherits:
-
Object
- Object
- Egon::Undercloud::Installer
- Includes:
- PortCheckMixin
- Defined in:
- lib/egon/undercloud/installer.rb
Instance Attribute Summary collapse
-
#started ⇒ Object
(also: #started?)
readonly
Returns the value of attribute started.
Instance Method Summary collapse
- #check_ports(stringio = nil) ⇒ Object
- #completed? ⇒ Boolean
- #failure? ⇒ Boolean
-
#initialize(connection = nil) ⇒ Installer
constructor
installs locally if ssh connection is not provided.
- #install(commands, stringio = nil) ⇒ Object
- #set_completed(bool) ⇒ Object
- #set_failure(bool) ⇒ Object
Methods included from PortCheckMixin
Constructor Details
#initialize(connection = nil) ⇒ Installer
installs locally if ssh connection is not provided
13 14 15 16 17 18 |
# File 'lib/egon/undercloud/installer.rb', line 13 def initialize(connection=nil) @connection = connection @completed = false @started = false @failure = false end |
Instance Attribute Details
#started ⇒ Object (readonly) Also known as: started?
Returns the value of attribute started.
9 10 11 |
# File 'lib/egon/undercloud/installer.rb', line 9 def started @started end |
Instance Method Details
#check_ports(stringio = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/egon/undercloud/installer.rb', line 55 def check_ports(stringio=nil) # closed ports 5385, 36357 address = File.foreach('/home/stack/undercloud.conf') .grep(/^local_ip/).first .match(/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/).to_s ports = [8774, 9292, 8777, 9696, 8004, 5000, 8585, 15672] ports.each do |p| if !@connection.nil? # remote check if !@connection.remote_port_open?(p, stringio) set_failure(true) end else # local check set_failure(true) unless !port_open?(address, p, stringio) end end end |
#completed? ⇒ Boolean
20 21 22 |
# File 'lib/egon/undercloud/installer.rb', line 20 def completed? @completed end |
#failure? ⇒ Boolean
28 29 30 |
# File 'lib/egon/undercloud/installer.rb', line 28 def failure? @failure end |
#install(commands, stringio = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/egon/undercloud/installer.rb', line 36 def install(commands, stringio=nil) @started = true @completed = false if !@connection.nil? # remote install @connection.on_complete(lambda { set_completed(true) }) @connection.on_failure(lambda { set_failure(true) }) Thread.new { @connection.execute(commands, stringio) } else # local install set_failure(true) unless system(commands) set_completed(true) end end |
#set_completed(bool) ⇒ Object
24 25 26 |
# File 'lib/egon/undercloud/installer.rb', line 24 def set_completed(bool) @completed = bool end |
#set_failure(bool) ⇒ Object
32 33 34 |
# File 'lib/egon/undercloud/installer.rb', line 32 def set_failure(bool) @failure = bool end |