Class: Kitchen::Driver::Gogetkitchen

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/driver/gogetkitchen.rb

Overview

Gogetkitchen driver for Kitchen.

Author:

Instance Method Summary collapse

Instance Method Details

#choose_provider(provider) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/kitchen/driver/gogetkitchen.rb', line 62

def choose_provider(provider)
  case provider
  when 'lxd'
    Gogetit.lxd
  when 'libvirt'
    Gogetit.libvirt
  end
end

#create(state) ⇒ Object



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

def create(state)
  provider = choose_provider(config[:provider])
  provider.create(instance.name)
  domain = Gogetit.maas.get_domain
  state[:hostname]      = instance.name + '.' + domain
  state[:username]      = config[:username]
        info 'Waiting for the new domain to be available..'
  wait_until_available(instance.name)

        info 'Waiting for SSH..'
  conn = instance.transport.connection(state)
  conn.wait_until_ready
  conn.close
end

#destroy(state) ⇒ Object



55
56
57
58
59
60
# File 'lib/kitchen/driver/gogetkitchen.rb', line 55

def destroy(state)
  provider = choose_provider(config[:provider])
  provider.destroy(instance.name)

  instance.transport.connection(state).close
end

#wait_until_available(hostname) ⇒ Object



71
72
73
74
75
# File 'lib/kitchen/driver/gogetkitchen.rb', line 71

def wait_until_available(hostname)
  until Gogetit.maas.domain_name_exists?(hostname)
    sleep 3
  end
end