mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
server: save GUID for KVM cluster (#3398)
When a KVM host is added to a cluster, the cluster GUID is null. In case the KVM host fails to be added, the GUID is not set to null and if any other hosts are added an exception is thrown by the resource manager that does not allow addition of hosts to a cluster with existing hosts whose GUID is null. In case of KVM, other hosts may be added in parallel therefore this restriction can be safely removed. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
c4f6c43852
commit
aecfe6d500
@ -210,6 +210,12 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set cluster GUID based on cluster ID if null
|
||||
if (cluster.getGuid() == null) {
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
}
|
||||
|
||||
Map<KvmDummyResourceBase, Map<String, String>> resources = new HashMap<KvmDummyResourceBase, Map<String, String>>();
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
if (!uri.getScheme().equals("http")) {
|
||||
@ -230,8 +236,9 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
|
||||
if (existingHosts != null) {
|
||||
for (HostVO existingHost : existingHosts) {
|
||||
if (existingHost.getGuid().toLowerCase().startsWith(guid.toLowerCase())) {
|
||||
s_logger.debug("Skipping " + agentIp + " because " + guid + " is already in the database for resource " + existingHost.getGuid());
|
||||
return null;
|
||||
final String msg = "Skipping host " + agentIp + " because " + guid + " is already in the database for resource " + existingHost.getGuid() + " with ID " + existingHost.getUuid();
|
||||
s_logger.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -326,12 +333,6 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
|
||||
|
||||
details.put("guid", connectedHost.getGuid());
|
||||
|
||||
// place a place holder guid derived from cluster ID
|
||||
if (cluster.getGuid() == null) {
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
}
|
||||
|
||||
// save user name and password
|
||||
_hostDao.loadDetails(connectedHost);
|
||||
Map<String, String> hostDetails = connectedHost.getDetails();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user