53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/kitchen/driver/lxd_cli.rb', line 53
def create(state)
@@instance_name = get_or_create_unique_instance_name
install_proxy if config[:lxd_proxy_install] && config[:lxd_proxy_install] == true
unless exists?
image_name = create_image_if_missing
profile_args = setup_profile_args if config[:profile]
config_args = setup_config_args
info("Initializing container #{@@instance_name}")
run_lxc_command("init #{image_name} #{@@instance_name} #{profile_args} #{config_args}")
end
config_and_start_container unless running?
configure_dns
lxc_ip = wait_for_ip_address
state[:hostname] = lxc_ip
state[:username] = config[:username]
setup_ssh_access
wait_for_ssh_login(lxc_ip) if config[:enable_wait_for_ssh_login] == "true"
IO.popen("lxc exec #{@@instance_name} bash", "r+") do |p|
p.puts("if [ ! -d '#{config[:verifier_path]}' ]; then mkdir -p #{config[:verifier_path]}; fi")
p.puts("if [ ! -L '/tmp/verifier' ]; then ln -s #{config[:verifier_path]} /tmp/verifier; fi")
end if config[:verifier_path] && config[:verifier_path].length > 0
end
|