Class: Zombees::Worker

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Celluloid, Yell::Loggable
Defined in:
lib/zombees/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Worker

Returns a new instance of Worker.



17
18
19
# File 'lib/zombees/worker.rb', line 17

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/zombees/worker.rb', line 12

def config
  @config
end

#serverObject (readonly)

Returns the value of attribute server.



13
14
15
# File 'lib/zombees/worker.rb', line 13

def server
  @server
end

Instance Method Details

#bootstrapObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/zombees/worker.rb', line 21

def bootstrap
  @server = @connection.servers.bootstrap(
    private_key_path:  'tourfleet',
    key_name:          :fog_default,
    username:          'ubuntu'
  )

  @server.wait_for { ready? }
  self
end

#run_command(command) ⇒ Object



32
33
34
35
# File 'lib/zombees/worker.rb', line 32

def run_command(command)
  result = @server.ssh(command)
  result
end

#shutdownObject



37
38
39
40
41
42
43
# File 'lib/zombees/worker.rb', line 37

def shutdown
  if @server && @server.ready?
    @server.destroy
  else
    logger.error "zombie bee is too badly damaged to get to the graveyard"
  end
end