Skip to content
Permalink
Browse files

Merge pull request #75 from pjdarton/launcher_improvement

[JENKINS-44796] vSphereCloudLauncher enhancement
  • Loading branch information
pjdarton committed Jul 28, 2017
2 parents f87d1de + aa4ba8c commit 421fbe60eea35660c79cd2df32aad0f6e28d2c1a
Showing with 15 additions and 8 deletions.
  1. +15 −8 src/main/java/org/jenkinsci/plugins/vSphereCloudLauncher.java
@@ -293,16 +293,21 @@ public synchronized void afterDisconnect(SlaveComputer slaveComputer, TaskListen
try {
vSphereCloud.Log(slaveComputer, taskListener, "Running disconnect procedure...");
super.afterDisconnect(slaveComputer, taskListener);
vSphereCloud.Log(slaveComputer, taskListener, "Shutting down Virtual Machine...");
MACHINE_ACTION localIdle = idleAction;
if (localIdle == null) {
localIdle = MACHINE_ACTION.SHUTDOWN;
}
vSphereCloud vsC = findOurVsInstance();
vSphereCloud.Log(slaveComputer, taskListener, "Disconnect done. Performing idle action %s...", localIdle);
final vSphereCloud vsC = findOurVsInstance();
vsC.markVMOffline(slaveComputer.getDisplayName(), vmName);
v = vsC.vSphereInstance();
VirtualMachine vm = v.getVmByName(vmName);
if (vm != null && !MACHINE_ACTION.NOTHING.equals(localIdle)) {
final VirtualMachine vm;
if( !MACHINE_ACTION.NOTHING.equals(localIdle) ) {
v = vsC.vSphereInstance();
vm = v.getVmByName(vmName);
} else {
vm = null;
}
if (vm != null ) {
//VirtualMachinePowerState power = vm.getRuntime().getPowerState();
VirtualMachinePowerState power = vm.getSummary().getRuntime().powerState;
if (power == VirtualMachinePowerState.poweredOn) {
@@ -340,13 +345,15 @@ public synchronized void afterDisconnect(SlaveComputer slaveComputer, TaskListen
// VM is already powered down.
}
}
if (v != null) {
v.disconnect();
}
vSphereCloud.Log(slaveComputer, taskListener, "Idle action %s complete.", localIdle);
} catch (Throwable t) {
vSphereCloud.Log(slaveComputer, taskListener, t, "Got an exception");
taskListener.fatalError(t.getMessage(), t);
} finally {
if (v != null) {
v.disconnect();
v = null;
}
vsSlave.slaveIsDisconnecting = Boolean.FALSE;
vsSlave.slaveIsStarting = Boolean.FALSE;
}

0 comments on commit 421fbe6

Please sign in to comment.
You can’t perform that action at this time.