Nebula: add VM connection timeout
This commit is contained in:
parent
78c8a9e74e
commit
ec523ddfb4
|
@ -149,6 +149,7 @@ def runInNewVM(Map args, Closure body) {
|
||||||
def vmTemplate = args.get('vmTemplate', '')
|
def vmTemplate = args.get('vmTemplate', '')
|
||||||
def terminateOnExit = args.get('terminateOnExit', true)
|
def terminateOnExit = args.get('terminateOnExit', true)
|
||||||
def shell = args.get("shell", "/bin/sh")
|
def shell = args.get("shell", "/bin/sh")
|
||||||
|
def connectionTimeout = args.get('connectionTimeout', 10)
|
||||||
|
|
||||||
// On récupère les identifiants de connexion SSH pour la VM
|
// On récupère les identifiants de connexion SSH pour la VM
|
||||||
withCredentials([
|
withCredentials([
|
||||||
|
@ -160,13 +161,15 @@ def runInNewVM(Map args, Closure body) {
|
||||||
def sshArgs = "-i '${VM_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
def sshArgs = "-i '${VM_SSH_KEY}' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
|
||||||
// On attend que la connexion SSH soit disponible
|
// On attend que la connexion SSH soit disponible
|
||||||
println "En attente de l'accès SSH sur la machine ${host}..."
|
println "En attente de l'accès SSH sur la machine ${host}..."
|
||||||
while(true) {
|
timeout(connectionTimeout) {
|
||||||
def status = sh script: "nc -zv ${host} 22", returnStatus: true
|
while(true) {
|
||||||
if (status == 0) {
|
def status = sh script: "nc -zv ${host} 22", returnStatus: true
|
||||||
break;
|
if (status == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep(5)
|
||||||
}
|
}
|
||||||
sleep(5)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def remoteShell = { script ->
|
def remoteShell = { script ->
|
||||||
|
|
Loading…
Reference in New Issue