Class: Kitchen::Driver::Gce

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

Overview

Google Compute Engine driver for Test Kitchen

Author:

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/kitchen/driver/gce.rb', line 43

def create(state)
  return if state[:server_id]

  server = create_instance
  state[:server_id] = server.identity

  info("GCE instance <#{state[:server_id]}> created.")

  wait_for_up_instance(server, state)

rescue Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end

#destroy(state) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/kitchen/driver/gce.rb', line 57

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

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