NodeEntity node = nodes.get(i);
if (node.getMoId() == null) {
logger.info("VC vm does not exist for node: " + node.getVmName());
continue;
}
VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());
if (vcVm == null) {
// cannot find VM
logger.info("VC vm does not exist for node: " + node.getVmName());
continue;
}
StartVmSP.StartVmPrePowerOn prePowerOn = new StartVmSP.StartVmPrePowerOn(isMapDistro,
(new Gson()).toJson(node.getVolumns()));
StartVmPostPowerOn query =
new StartVmPostPowerOn(node.fetchAllPortGroups(),
Constants.VM_POWER_ON_WAITING_SEC, clusterEntityMgr);
VcHost host = null;
if (node.getHostName() != null) {
host = VcResourceUtils.findHost(node.getHostName());
}
StartVmSP startSp = new StartVmSP(vcVm, prePowerOn, query, host);
storeProcedures.add(startSp);
nodesStatus.put(node.getVmName(),
new NodeOperationStatus(node.getVmName()));
}
try {
if (storeProcedures.isEmpty()) {
logger.info("no VM is available. Return directly.");
return true;
}
Callable<Void>[] storeProceduresArray =
storeProcedures.toArray(new Callable[0]);
// execute store procedures to start VMs
logger.info("ClusteringService, start to start vms.");
BaseProgressCallback callback = new BaseProgressCallback(statusUpdator);
ExecutionResult[] result =
Scheduler
.executeStoredProcedures(
com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
storeProceduresArray, callback);
if (result == null) {
for (NodeOperationStatus status : nodesStatus.values()) {
status.setSucceed(false);
}
logger.error("No VM is started.");
failedNodes.addAll(nodesStatus.values());
return false;
}
boolean success = true;
int total = 0;
for (int i = 0; i < storeProceduresArray.length; i++) {
StartVmSP sp = (StartVmSP) storeProceduresArray[i];
NodeOperationStatus status = nodesStatus.get(sp.getVmName());
VcVirtualMachine vm = sp.getVcVm();
if (result[i].finished && result[i].throwable == null) {
++total;
nodesStatus.remove(status.getNodeName()); // do not return success node
} else if (result[i].throwable != null) {
status.setSucceed(false);
status.setErrorMessage(getErrorMessage(result[i].throwable));
if (vm != null
&& vm.isPoweredOn() && VcVmUtil.checkIpAddresses(vm)) {
++total;
nodesStatus.remove(status.getNodeName()); // do not return success node status
} else {
if (!vm.isConnected()
|| vm.getHost().isUnavailbleForManagement()) {
logger.error("Cannot start VM " + vm.getName()
+ " in connection state " + vm.getConnectionState()
+ " or in maintenance mode. "
+ "Ignore this VM and continue cluster operations.");
continue;
}
logger.error(