@DB private void updateClusterNativeHAState(Host host, StartupCommand cmd) { ClusterVO cluster = _clusterDao.findById(host.getClusterId()); if (cluster.getClusterType() == ClusterType.ExternalManaged) { if (cmd instanceof StartupRoutingCommand) { StartupRoutingCommand hostStartupCmd = (StartupRoutingCommand) cmd; Map<String, String> details = hostStartupCmd.getHostDetails(); if (details.get("NativeHA") != null && details.get("NativeHA").equalsIgnoreCase("true")) { _clusterDetailsDao.persist(host.getClusterId(), "NativeHA", "true"); } else { _clusterDetailsDao.persist(host.getClusterId(), "NativeHA", "false"); } } } }
@Override public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) { StartupCommand firstCmd = cmd[0]; if (!(firstCmd instanceof StartupRoutingCommand)) { return null; } StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd); if (ssCmd.getHypervisorType() != HypervisorType.KVM) { return null; } /* KVM requires host are the same in cluster */ ClusterVO clusterVO = _clusterDao.findById(host.getClusterId()); List<HostVO> hostsInCluster = _resourceMgr.listAllHostsInCluster(clusterVO.getId()); if (!hostsInCluster.isEmpty()) { HostVO oneHost = hostsInCluster.get(0); _hostDao.loadDetails(oneHost); String hostOsInCluster = oneHost.getDetail("Host.OS"); String hostOs = ssCmd.getHostDetails().get("Host.OS"); if (!hostOsInCluster.equalsIgnoreCase(hostOs)) { throw new IllegalArgumentException( "Can't add host: " + firstCmd.getPrivateIpAddress() + " with hostOS: " + hostOs + " into a cluster," + "in which there are " + hostOsInCluster + " hosts added"); } } _hostDao.loadDetails(host); return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.KVM, host.getDetails(), null); }