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



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

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

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

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

  wait_for_up_instance(instance, state)

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

#destroy(state) ⇒ Object



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

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

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