def execute
with_target_vms(nil, {:single_target=>true}) do |machine|
secrets_path = machine.data_dir
hIP = machine.ssh_info[:host]
hport = machine.ssh_info[:port]
husername = machine.ssh_info[:username]
if machine.provider_name == :virtualbox then
command = "ip addr show eth1 | awk 'NR==3 {print $2}' | cut -f1 -d\/"
else
command = "ip route get 8.8.8.8 | awk 'NR==1 {print $NF}'"
end
guest_ip = ""
machine.communicate.execute(command) do |type, data|
guest_ip << data.chomp if type == :stdout
end
port = 2376
if !File.directory?(File.expand_path(".docker", secrets_path)) then
if machine.provider_name == :virtualbox then
command2 = "test ! -f /opt/adb/cert-gen.sh || (sudo rm /etc/docker/ca.pem && sudo systemctl restart docker)"
machine.communicate.execute(command2)
end
if !OS.windows? then
hprivate_key_path = machine.ssh_info[:private_key_path][0]
%xscp -r -P #{hport} -o LogLevel=FATAL -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{hprivate_key_path} #{husername}@#{hIP}:/home/vagrant/.docker #{secrets_path}`
else
%xpscp -r -P #{hport} -pw #@@vagrant_box_password -p #{husername}@#{hIP}:/home/vagrant/.docker #{secrets_path}`
end
end
print_info(guest_ip, port, secrets_path, machine.index_uuid)
end
end