From 5d856da392e2578e179febe39ec78f637d66dba7 Mon Sep 17 00:00:00 2001 From: anthony Date: Thu, 24 Mar 2011 17:25:07 -0700 Subject: [PATCH] bug 9157: check if the uuid changes when reconnect status 9157: resolved fixed --- .../xen/resource/CitrixResourceBase.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index c4a98354eab..1b9fe489338 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -4385,15 +4385,19 @@ public abstract class CitrixResourceBase implements ServerResource { @Override public boolean configure(String name, Map params) throws ConfigurationException { _name = name; - _host.uuid = (String) params.get("guid"); + try { _dcId = Long.parseLong((String) params.get("zone")); } catch (NumberFormatException e) { throw new ConfigurationException("Unable to get the zone " + params.get("zone")); } + + _host.uuid = (String) params.get("guid"); + _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"); _pod = (String) params.get("pod"); @@ -4433,10 +4437,31 @@ public abstract class CitrixResourceBase implements ServerResource { if (_host.uuid == null) { throw new ConfigurationException("Unable to get the uuid"); } + + CheckXenHostInfo(); return true; } + private void CheckXenHostInfo() throws ConfigurationException { + Connection conn = _connPool.slaveConnect(_host.ip, _username, _password); + 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); + } + } + void destroyVDI(Connection conn, VDI vdi) { try { vdi.destroy(conn);