Class: Kitchen::Driver::Digitalocean

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/digitalocean.rb

Overview

Digital Ocean driver for Kitchen.

Author:

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kitchen/driver/digitalocean.rb', line 40

def create(state)
  config[:name] ||= generate_name(instance.name)
  server = create_server
  state[:server_id] = server.id

  info("Digital Ocean 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"
  debug("digitalocean:create #{state[:hostname]}")
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
# File 'lib/kitchen/driver/digitalocean.rb', line 54

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

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