From 71f968a3e103fc0a1716b484870358e01bd66c99 Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 4 Apr 2011 14:31:47 -0700 Subject: [PATCH] bug 9282: set cluster guid if it is null status 9282: resolved fixed --- .../xen/resource/CitrixResourceBase.java | 32 ++++++++++++------- .../xen/discoverer/XcpServerDiscoverer.java | 10 ++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index b83a09e98d8..2e77392b87d 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -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) { + } } } diff --git a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 2f085518ff3..2da7594de01 100644 --- a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -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; }