Class: Jamie::Driver::Bluebox

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/jamie/driver/bluebox.rb

Overview

Blue Box blocks API driver for Jamie.

Author:

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jamie/driver/bluebox.rb', line 42

def create(state)
  server = create_server
  state[:block_id] = server.id
  state[:hostname] = server.ips.first['address']

  info("Blocks instance <#{state[:block_id]}> created.")
  server.wait_for { print "."; ready? } ; print "(server ready)"
  wait_for_sshd(state[:hostname])       ; print "(ssh ready)\n"
rescue Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end

#destroy(state) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/jamie/driver/bluebox.rb', line 54

def destroy(state)
  return if state[:block_id].nil?

  connection.destroy_block(state[:block_id])
  info("Blocks instance <#{state[:block_id]}> destroyed.")
  state.delete(:block_id)
  state.delete(:hostname)
rescue Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end