Class: Kitchen::Driver::Lxd

Inherits:
Base
  • Object
show all
Includes:
ShellOut
Defined in:
lib/kitchen/driver/lxd.rb,
lib/kitchen/driver/version.rb,
lib/kitchen/driver/lxd/container.rb

Overview

Lxd driver for Kitchen.

Author:

Defined Under Namespace

Classes: Container

Constant Summary collapse

MIN_LXD_VERSION =
'2.3'
VERSION =

Version string for Lxd Kitchen driver

'0.3.0'

Instance Method Summary collapse

Instance Method Details

#containerObject



76
77
78
# File 'lib/kitchen/driver/lxd.rb', line 76

def container
	@container ||= Lxd::Container.new(logger, config)
end

#create(state) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/driver/lxd.rb', line 51

def create(state)
	container.init(config[:config])
	container.attach_network config[:network] if config[:network]
	container.start

	if config[:wait_until_ready]
		state[:hostname] = instance.transport.connection(state).wait_until_ready
	end
	container.fix_chef_install(instance.platform.name) if config[:fix_chef_install]
	container.fix_hostnamectl_bug if config[:fix_hostnamectl_bug]
end

#destroy(state) ⇒ Object



63
64
65
66
67
# File 'lib/kitchen/driver/lxd.rb', line 63

def destroy(state)
	instance.transport.connection(state).close
	state.delete :hostname
	container.destroy
end

#verify_dependenciesObject

Raises:

  • (UserError)


69
70
71
72
73
74
# File 'lib/kitchen/driver/lxd.rb', line 69

def verify_dependencies
	version = run_command("#{config[:binary]} --version").strip
	return if Gem::Version.new(version) >= Gem::Version.new(MIN_LXD_VERSION)
	raise UserError, "Detected old version of Lxd (#{version}), please upgrade to version "\
		"#{MIN_LXD_VERSION} or higher."
end