18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/kitchen/driver/lxc.rb', line 18
def create(state)
name = instance.platform.name.gsub(/[_\-.]/, '')
names = Dir.glob(instance.driver.config.fetch(:lxc_directory, '/var/lib/lxc/*')).map do |path|
if(File.directory?(path))
File.basename(path)
end
end.compact.sort
config[:original] = names.detect{|n| n.gsub(/[_\-.]/, '').start_with?(name)}
container = ::Lxc::Ephemeral.new(config.to_hash)
container.create!
state[:container_name] = container.name
lxc = ::Lxc.new(state[:container_name])
lxc.start
state[:hostname] = lxc.container_ip(10, true)
wait_for_sshd(state[:hostname])
end
|