Hypervisor hypervisor = vmL.findOurHypervisorInstance();
logger.log(Level.INFO, "Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down. reason: "+cause+" ("+cause.getClass().getName()+")");
taskListener.getLogger().println("Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down.");
try {
Map<String, IDomain> computers = hypervisor.getDomains();
IDomain domain = computers.get(virtualMachineName);
if (domain != null) {
if (domain.isRunningOrBlocked()) {
String snapshotName = slave.getSnapshotName();
if (snapshotName != null && snapshotName.length() > 0) {
taskListener.getLogger().println("Reverting to " + snapshotName + " and shutting down.");
domain.revertToSnapshot(domain.snapshotLookupByName(snapshotName));
} else {
taskListener.getLogger().println("Shutting down.");
System.err.println("method: " + slave.getShutdownMethod());
if (slave.getShutdownMethod().equals("suspend")) {
domain.suspend();
} else if (slave.getShutdownMethod().equals("destroy")) {
domain.destroy();
} else {
domain.shutdown();
}
}
} else {
taskListener.getLogger().println("Already suspended, no shutdown required.");
}