bug 9282: set cluster guid if it is null

status 9282: resolved fixed
This commit is contained in:
anthony 2011-04-04 14:31:47 -07:00
parent d1650c6e60
commit 71f968a3e1
2 changed files with 31 additions and 11 deletions

View File

@ -4411,6 +4411,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
cmd.setHostDetails(details);
cmd.setName(hr.nameLabel);
cmd.setGuid(_host.uuid);
cmd.setPool(_host.pool);
cmd.setDataCenter(Long.toString(_dcId));
for (final String cap : hr.capabilities) {
if (cap.length() > 0) {
@ -4508,7 +4509,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
_name = _host.uuid;
_host.ip = (String) params.get("ipaddress");
_host.pool = (String) params.get("pool");
_username = (String) params.get("username");
_password = (String) params.get("password");
@ -4560,17 +4560,27 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
if( conn == null ) {
throw new ConfigurationException("Can not create slave connection to " + _host.ip);
}
Host.Record hostRec = null;
try {
Host host = Host.getByUuid(conn, _host.uuid);
hostRec = host.getRecord(conn);
} catch (Exception e) {
throw new ConfigurationException("Can not get host information from " + _host.ip);
}
if( !hostRec.address.equals(_host.ip) ) {
String msg = "Host " + _host.ip + " seems be reinstalled, please remove this host and readd";
s_logger.error(msg);
throw new ConfigurationException(msg);
Host.Record hostRec = null;
try {
Host host = Host.getByUuid(conn, _host.uuid);
hostRec = host.getRecord(conn);
Pool.Record poolRec = Pool.getAllRecords(conn).values().iterator().next();
_host.pool = poolRec.uuid;
} catch (Exception e) {
throw new ConfigurationException("Can not get host information from " + _host.ip);
}
if( !hostRec.address.equals(_host.ip) ) {
String msg = "Host " + _host.ip + " seems be reinstalled, please remove this host and readd";
s_logger.error(msg);
throw new ConfigurationException(msg);
}
} finally {
try {
Session.localLogout(conn);
} catch (Exception e) {
}
}
}

View File

@ -518,6 +518,16 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
HostVO host = _hostDao.findById(agentId);
ClusterVO cluster = _clusterDao.findById(host.getClusterId());
if ( cluster.getGuid() == null) {
cluster.setGuid(startup.getPool());
_clusterDao.update(cluster.getId(), cluster);
} else if (! cluster.getGuid().equals(startup.getPool()) ) {
String msg = "pool uuid for cluster " + cluster.getId() + " changed from " + cluster.getGuid() + " to " + cmd.getPod();
s_logger.warn(msg);
throw new CloudRuntimeException(msg);
}
if (host.isSetup()) {
return;
}