Class: Egon::Undercloud::Installer

Inherits:
Object
  • Object
show all
Includes:
PortCheckMixin
Defined in:
lib/egon/undercloud/installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PortCheckMixin

#port_open?, #stringio_write

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

#startedObject (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
# File 'lib/egon/undercloud/installer.rb', line 55

def check_ports(stringio=nil)
  # closed ports 5385, 36357
  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?("192.0.2.1", p, stringio)
    end
  end
end

#completed?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/egon/undercloud/installer.rb', line 20

def completed?
  @completed
end

#failure?Boolean

Returns:

  • (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