Skip to content

Commit

Permalink
kvm: support Rocky/RHEL/OL/Alma in the same cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Feb 12, 2024
1 parent 672206c commit 12c2542
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -72,6 +73,10 @@
public abstract class LibvirtServerDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
private static final Logger s_logger = Logger.getLogger(LibvirtServerDiscoverer.class);
private final int _waitTime = 5; /* wait for 5 minutes */

private final static HashSet<String> COMPATIBLE_HOST_OSES = new HashSet<>(Arrays.asList("Rocky", "Rocky Linux",
"Red", "Red Hat Enterprise Linux", "Oracle", "Oracle Linux Server", "AlmaLinux"));

private String _kvmPrivateNic;
private String _kvmPublicNic;
private String _kvmGuestNic;
Expand Down Expand Up @@ -470,7 +475,7 @@ public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
_hostDao.loadDetails(oneHost);
String hostOsInCluster = oneHost.getDetail("Host.OS");
String hostOs = ssCmd.getHostDetails().get("Host.OS");
if (!hostOsInCluster.equalsIgnoreCase(hostOs)) {
if (!isHostOsCompatibleWithOtherHost(hostOsInCluster, hostOs)) {
String msg = String.format("host: %s with hostOS, \"%s\"into a cluster, in which there are \"%s\" hosts added", firstCmd.getPrivateIpAddress(), hostOs, hostOsInCluster);
if (hostOs != null && hostOs.startsWith(hostOsInCluster)) {
s_logger.warn(String.format("Adding %s. This may or may not be ok!", msg));
Expand All @@ -485,6 +490,17 @@ public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
return _resourceMgr.fillRoutingHostVO(host, ssCmd, getHypervisorType(), host.getDetails(), null);
}

private boolean isHostOsCompatibleWithOtherHost(String hostOsInCluster, String hostOs) {
if (hostOsInCluster.equalsIgnoreCase(hostOs)) {
return true;
}
if (COMPATIBLE_HOST_OSES.contains(hostOsInCluster) && COMPATIBLE_HOST_OSES.contains(hostOs)) {
s_logger.info(String.format("The host OS (%s) is compatible with the existing host OS (%s) in the cluster.", hostOs, hostOsInCluster));
return true;
}
return false;
}

@Override
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
// TODO Auto-generated method stub
Expand Down

0 comments on commit 12c2542

Please sign in to comment.