Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/main/java/org/jenkinsci/plugins/vSphereCloudLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down