private void updateNetworkLabels(HostVO host) { //check if networkLabels need to be updated in details //we send only private and storage network label to the resource. String privateNetworkLabel = _networkMgr.getDefaultManagementTrafficLabel(host.getDataCenterId(), host.getHypervisorType()); String storageNetworkLabel = _networkMgr.getDefaultStorageTrafficLabel(host.getDataCenterId(), host.getHypervisorType()); String privateDevice = host.getDetail("private.network.device"); String storageDevice = host.getDetail("storage.network.device1"); boolean update = false; if (privateNetworkLabel != null && !privateNetworkLabel.equalsIgnoreCase(privateDevice)) { host.setDetail("private.network.device", privateNetworkLabel); update = true; } if (storageNetworkLabel != null && !storageNetworkLabel.equalsIgnoreCase(storageDevice)) { host.setDetail("storage.network.device1", storageNetworkLabel); update = true; } if (update) { _hostDao.saveDetails(host); } }
@Override public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> transition, VirtualMachine vo, boolean status, Object opaque) { State newState = transition.getToState(); State oldState = transition.getCurrentState(); if (newState != State.Starting && newState != State.Error && newState != State.Expunging) { return true; } if (vo.getHypervisorType() != HypervisorType.BareMetal) { return true; } HostVO host = _hostDao.findById(vo.getHostId()); if (host == null) { s_logger.debug("Skip oldState " + oldState + " to " + "newState " + newState + " transimtion"); return true; } _hostDao.loadDetails(host); if (newState == State.Starting) { host.setDetail("vmName", vo.getInstanceName()); s_logger.debug("Add vmName " + host.getDetail("vmName") + " to host " + host.getId() + " details"); } else { if (host.getDetail("vmName") != null && host.getDetail("vmName").equalsIgnoreCase(vo.getInstanceName())) { s_logger.debug("Remove vmName " + host.getDetail("vmName") + " from host " + host.getId() + " details"); host.getDetails().remove("vmName"); } } _hostDao.saveDetails(host); return true; }