Class: Jamie::Driver::Ec2

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

Overview

Amazon EC2 driver for Jamie.

Author:

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jamie/driver/ec2.rb', line 40

def create(state)
  server = create_server
  state[:server_id] = server.id

  info("EC2 instance <#{state[:server_id]}> created.")
  server.wait_for { print "."; ready? } ; print "(server ready)"
  state[:hostname] = server.public_ip_address
  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



52
53
54
55
56
57
58
59
60
# File 'lib/jamie/driver/ec2.rb', line 52

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

  server = connection.servers.get(state[:server_id])
  server.destroy unless server.nil?
  info("EC2 instance <#{state[:server_id]}> destroyed.")
  state.delete(:server_id)
  state.delete(:hostname)
end