lib/kitchen/driver/cloudstack.rb in kitchen-cloudstack-0.20.0 vs lib/kitchen/driver/cloudstack.rb in kitchen-cloudstack-0.20.1
- old
+ new
@@ -113,10 +113,11 @@
# jobstatus of 2 is an error response
if server_start['queryasyncjobresultresponse'].fetch('jobstatus').to_i == 2
errortext = server_start['queryasyncjobresultresponse'].fetch('jobresult').fetch('errortext')
error("ERROR! Job failed with #{errortext}")
+ raise ActionFailed, "Could not create server #{errortext}"
end
# jobstatus of 1 is a succesfully completed async job
if server_start['queryasyncjobresultresponse'].fetch('jobstatus').to_i == 1
server_info = server_start['queryasyncjobresultresponse']['jobresult']['virtualmachine']
@@ -142,31 +143,40 @@
end
# binding.pry
# debug("Keypair is #{keypair}")
state[:hostname] = config[:cloudstack_vm_public_ip] || server_info.fetch('nic').first.fetch('ipaddress')
- wait_for_sshd(state[:hostname])
-
- debug("SSH Connectivity Validated.")
if (!keypair.nil?)
debug("Using keypair: #{keypair}")
info("SSH for #{state[:hostname]} with keypair #{config[:cloudstack_ssh_keypair_name]}.")
ssh_key = File.read(keypair)
if ssh_key.split[0] == "ssh-rsa" or ssh_key.split[0] == "ssh-dsa"
error("SSH key #{keypair} is not a Private Key. Please modify your .kitchen.yml")
end
+
+ wait_for_sshd(state[:hostname], config[:username], {:keys => keypair})
+ debug("SSH connectivity validated with keypair.")
+
ssh = Fog::SSH.new(state[:hostname], config[:username], {:keys => keypair})
debug("Connecting to : #{state[:hostname]} as #{config[:username]} using keypair #{keypair}.")
elsif (server_info.fetch('passwordenabled') == true)
password = server_info.fetch('password')
# Print out IP and password so you can record it if you want.
info("Password for #{config[:username]} at #{state[:hostname]} is #{password}")
+
+ wait_for_sshd(state[:hostname], config[:username], {:password => password})
+ debug("SSH connectivity validated with cloudstack-set password.")
+
ssh = Fog::SSH.new(state[:hostname], config[:username], {:password => password})
debug("Connecting to : #{state[:hostname]} as #{config[:username]} using password #{password}.")
elsif (!config[:password].nil?)
info("Connecting with user #{config[:username]} with password #{config[:password]}")
+
+ wait_for_sshd(state[:hostname], config[:username], {:password => config[:password]})
+ debug("SSH connectivity validated with fixed password.")
+
ssh = Fog::SSH.new(state[:hostname], config[:username], {:password => config[:password]})
else
info("No keypair specified (or file not found) nor is this a password enabled template. You will have to manually copy your SSH public key to #{state[:hostname]} to use this Kitchen.")
end
# binding.pry
@@ -216,10 +226,10 @@
rescue Net::SSH::AuthenticationFailed
debug("SSH authentication has failed. Password or Keys may not be in place yet. Retrying.")
sleep 15
false
ensure
- sync_time = 45
+ sync_time = 0
if (config[:cloudstack_sync_time])
sync_time = config[:cloudstack_sync_time]
end
sleep(sync_time)
debug("Connecting to host and running ls")