lockMgr.refreshNodeByMobId(clusterName, moId, null, true);
}
break;
}
case VmDisconnected: {
VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
if (vm == null) {
NodeEntity node = clusterEntityMgr.getNodeByMobId(moId);
if (node != null) {
String clusterName =
CommonUtil.getClusterName(node.getVmName());
logger.debug("vm " + moId + " is already removed");
lockMgr.removeVmReference(clusterName, moId);
}
break;
}
if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
vm.updateRuntime();
if ((!vm.isConnected())
|| vm.getHost().isUnavailbleForManagement()) {
String clusterName = CommonUtil.getClusterName(vm.getName());
lockMgr.setNodeConnectionState(clusterName, vm.getName());
logConnectionChangeEvent(vm.getName());
}
}
break;
}
case VmPoweredOn: {
logger.debug("vm is powered on");
// ignore this event if waitForPowerState failed
if (waitForPowerState(moId, PowerState.poweredOn)) {
refreshNodeWithAction(moId, true, Constants.NODE_ACTION_WAITING_IP,
"Powered On");
if (external) {
NodePowerOnRequest request =
new NodePowerOnRequest(lockMgr, moId, clusterManager,
softwareManagerCollector);
CmsWorker.addRequest(WorkQueue.VC_TASK_NO_DELAY, request);
}
}
break;
}
case VmCloned: {
refreshNodeWithAction(moId, true,
Constants.NODE_ACTION_RECONFIGURE, "Cloned");
break;
}
case VmSuspended: {
refreshNodeWithAction(moId, true, null, "Suspended");
break;
}
case VmPoweredOff: {
if (waitForPowerState(moId, PowerState.poweredOff)) {
refreshNodeWithAction(moId, true, null, "Powered Off");
}
break;
}
case VmConnected: {
try {
refreshNodeWithAction(moId, false, null, type.name());
} catch (AuroraException ex) {
// vm is not able to be accessed immediately after it's created,
// ignore the exception here to continue other event processing
logger.warn("Catch aurora exception " + ex.getMessage()
+ ", ignore it.");
}
break;
}
case VmMigrated: {
refreshNodeWithAction(moId, false, null, type.name());
break;
}
case VhmError:
case VhmWarning: {
EventEx event = (EventEx) e;
VcVirtualMachine vm =
VcCache.getIgnoreMissing(event.getVm().getVm());
if (vm == null) {
break;
}
if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
logger.info("received vhm event " + event.getEventTypeId()
+ " for vm " + vm.getName() + ": " + event.getMessage());
vm.updateRuntime();
String clusterName = CommonUtil.getClusterName(vm.getName());
lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
event.getMessage(), true);
}
break;
}
case VhmInfo: {
EventEx event = (EventEx) e;
VcVirtualMachine vm =
VcCache.getIgnoreMissing(event.getVm().getVm());
if (vm == null) {
break;
}
if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
logger.info("received vhm event " + event.getEventTypeId()
+ " for vm " + vm.getName() + ": " + event.getMessage());
vm.updateRuntime();
String clusterName = CommonUtil.getClusterName(vm.getName());
lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(), "",
true);
}
break;
}
default: {
if (external) {
VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
if (vm == null) {
break;
}
String clusterName = CommonUtil.getClusterName(vm.getName());
lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
true);
}
break;
}
}