diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 9852edac11d..14e993e9921 100755 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -204,17 +204,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L List clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId); if (clusterHosts != null && clusterHosts.size() > 0) { if (!clu.getGuid().equals(poolUuid)) { - if (hosts.size() == 1) { - if (!addHostsToPool(conn, hostIp, clusterId)) { - String msg = "Unable to add host(" + hostIp + ") to cluster " + clusterId; - s_logger.warn(msg); - throw new DiscoveryException(msg); - } - } else { - String msg = "Host (" + hostIp + ") is already in pool(" + poolUuid + "), can to join pool(" + clu.getGuid() + ")"; - s_logger.warn(msg); - throw new DiscoveryException(msg); - } + String msg = "Please join the host " + hostIp + " to XS pool " + + clu.getGuid() + " through XC/XS before adding it through CS UI"; + s_logger.warn(msg); + throw new DiscoveryException(msg); } } else { setClusterGuid(clu, poolUuid); @@ -370,54 +363,6 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L } } - protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId) throws XenAPIException, XmlRpcException, DiscoveryException { - - List hosts; - hosts = _resourceMgr.listAllHostsInCluster(clusterId); - - String masterIp = null; - String username = null; - String password = null; - Queue pass = new LinkedList(); - for (HostVO host : hosts) { - _hostDao.loadDetails(host); - username = host.getDetail("username"); - password = host.getDetail("password"); - pass.add(password); - String address = host.getPrivateIpAddress(); - Connection hostConn = _connPool.getConnect(address, username, pass); - if (hostConn == null) { - continue; - } - try { - Set pools = Pool.getAll(hostConn); - Pool pool = pools.iterator().next(); - masterIp = pool.getMaster(hostConn).getAddress(hostConn); - break; - - } catch (Exception e) { - s_logger.warn("Can not get master ip address from host " + address); - } finally { - try{ - Session.logout(hostConn); - } catch (Exception e ) { - } - hostConn.dispose(); - hostConn = null; - } - } - - if (masterIp == null) { - s_logger.warn("Unable to reach the pool master of the existing cluster"); - throw new CloudRuntimeException("Unable to reach the pool master of the existing cluster"); - } - - if (!_connPool.joinPool(conn, hostIp, masterIp, username, pass)) { - s_logger.warn("Unable to join the pool"); - throw new DiscoveryException("Unable to join the pool"); - } - return true; - } protected CitrixResourceBase createServerResource(long dcId, Long podId, Host.Record record) { String prodBrand = record.softwareVersion.get("product_brand"); diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java index 646d595def8..6a8d1cdd784 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java @@ -148,65 +148,6 @@ public class XenServerConnectionPool { } } - public boolean joinPool(Connection conn, String hostIp, String masterIp, String username, Queue password) { - try { - join(conn, masterIp, username, password); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Host(" + hostIp + ") Join the pool at " + masterIp); - } - try { - // slave will restart xapi in 10 sec - Thread.sleep(10000); - } catch (InterruptedException e) { - } - for (int i = 0; i < 15; i++) { - Connection slaveConn = null; - Session slaveSession = null; - try { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Logging on as the slave to " + hostIp); - } - slaveConn = new Connection(getURL(hostIp), 10); - slaveSession = slaveLocalLoginWithPassword(slaveConn, username, password); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Slave logon successful. session= " + slaveSession); - } - Pool.Record pr = getPoolRecord(slaveConn); - Host master = pr.master; - String ma = master.getAddress(slaveConn); - if (ma.trim().equals(masterIp.trim())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Host(" + hostIp + ") Joined the pool at " + masterIp); - } - return true; - } - } catch (Exception e) { - } finally { - if (slaveSession != null) { - try { - Session.logout(slaveConn); - } catch (Exception e) { - } - slaveConn.dispose(); - } - } - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - } - } - - } catch (Exception e) { - String msg = "Catch " + e.getClass().getName() + " Unable to allow host " + hostIp + " to join pool " + masterIp + " due to " + e.toString(); - s_logger.warn(msg, e); - } - if (s_logger.isDebugEnabled()) { - s_logger.debug("Host(" + hostIp + ") unable to Join the pool at " + masterIp); - } - return false; - } - - public Connection getConnect(String ip, String username, Queue password) { Connection conn = new Connection(getURL(ip), 10); try {