Skip to content

Commit 15d798d

Browse files
author
Anthony Xu
committed
in XS, joining a host to a XS pool may not work as expected, especially when there are multiple nics, binding devices.
admin needs to check if the right nics are binded togather, if network are propagated to the new host correctly before adding this host to CS.
1 parent ee72450 commit 15d798d

2 files changed

Lines changed: 4 additions & 118 deletions

File tree

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java‎

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,10 @@ protected boolean xenserverHotFixEnabled() {
204204
List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId);
205205
if (clusterHosts != null && clusterHosts.size() > 0) {
206206
if (!clu.getGuid().equals(poolUuid)) {
207-
if (hosts.size() == 1) {
208-
if (!addHostsToPool(conn, hostIp, clusterId)) {
209-
String msg = "Unable to add host(" + hostIp + ") to cluster " + clusterId;
210-
s_logger.warn(msg);
211-
throw new DiscoveryException(msg);
212-
}
213-
} else {
214-
String msg = "Host (" + hostIp + ") is already in pool(" + poolUuid + "), can to join pool(" + clu.getGuid() + ")";
215-
s_logger.warn(msg);
216-
throw new DiscoveryException(msg);
217-
}
207+
String msg = "Please join the host " + hostIp + " to XS pool "
208+
+ clu.getGuid() + " through XC/XS before adding it through CS UI";
209+
s_logger.warn(msg);
210+
throw new DiscoveryException(msg);
218211
}
219212
} else {
220213
setClusterGuid(clu, poolUuid);
@@ -370,54 +363,6 @@ protected void addSamePool(Connection conn, Map<CitrixResourceBase, Map<String,
370363
}
371364
}
372365

373-
protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId) throws XenAPIException, XmlRpcException, DiscoveryException {
374-
375-
List<HostVO> hosts;
376-
hosts = _resourceMgr.listAllHostsInCluster(clusterId);
377-
378-
String masterIp = null;
379-
String username = null;
380-
String password = null;
381-
Queue<String> pass = new LinkedList<String>();
382-
for (HostVO host : hosts) {
383-
_hostDao.loadDetails(host);
384-
username = host.getDetail("username");
385-
password = host.getDetail("password");
386-
pass.add(password);
387-
String address = host.getPrivateIpAddress();
388-
Connection hostConn = _connPool.getConnect(address, username, pass);
389-
if (hostConn == null) {
390-
continue;
391-
}
392-
try {
393-
Set<Pool> pools = Pool.getAll(hostConn);
394-
Pool pool = pools.iterator().next();
395-
masterIp = pool.getMaster(hostConn).getAddress(hostConn);
396-
break;
397-
398-
} catch (Exception e) {
399-
s_logger.warn("Can not get master ip address from host " + address);
400-
} finally {
401-
try{
402-
Session.logout(hostConn);
403-
} catch (Exception e ) {
404-
}
405-
hostConn.dispose();
406-
hostConn = null;
407-
}
408-
}
409-
410-
if (masterIp == null) {
411-
s_logger.warn("Unable to reach the pool master of the existing cluster");
412-
throw new CloudRuntimeException("Unable to reach the pool master of the existing cluster");
413-
}
414-
415-
if (!_connPool.joinPool(conn, hostIp, masterIp, username, pass)) {
416-
s_logger.warn("Unable to join the pool");
417-
throw new DiscoveryException("Unable to join the pool");
418-
}
419-
return true;
420-
}
421366

422367
protected CitrixResourceBase createServerResource(long dcId, Long podId, Host.Record record) {
423368
String prodBrand = record.softwareVersion.get("product_brand");

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java‎

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -148,65 +148,6 @@ static void forceSleep(long sec) {
148148
}
149149
}
150150

151-
public boolean joinPool(Connection conn, String hostIp, String masterIp, String username, Queue<String> password) {
152-
try {
153-
join(conn, masterIp, username, password);
154-
if (s_logger.isDebugEnabled()) {
155-
s_logger.debug("Host(" + hostIp + ") Join the pool at " + masterIp);
156-
}
157-
try {
158-
// slave will restart xapi in 10 sec
159-
Thread.sleep(10000);
160-
} catch (InterruptedException e) {
161-
}
162-
for (int i = 0; i < 15; i++) {
163-
Connection slaveConn = null;
164-
Session slaveSession = null;
165-
try {
166-
if (s_logger.isDebugEnabled()) {
167-
s_logger.debug("Logging on as the slave to " + hostIp);
168-
}
169-
slaveConn = new Connection(getURL(hostIp), 10);
170-
slaveSession = slaveLocalLoginWithPassword(slaveConn, username, password);
171-
if (s_logger.isDebugEnabled()) {
172-
s_logger.debug("Slave logon successful. session= " + slaveSession);
173-
}
174-
Pool.Record pr = getPoolRecord(slaveConn);
175-
Host master = pr.master;
176-
String ma = master.getAddress(slaveConn);
177-
if (ma.trim().equals(masterIp.trim())) {
178-
if (s_logger.isDebugEnabled()) {
179-
s_logger.debug("Host(" + hostIp + ") Joined the pool at " + masterIp);
180-
}
181-
return true;
182-
}
183-
} catch (Exception e) {
184-
} finally {
185-
if (slaveSession != null) {
186-
try {
187-
Session.logout(slaveConn);
188-
} catch (Exception e) {
189-
}
190-
slaveConn.dispose();
191-
}
192-
}
193-
try {
194-
Thread.sleep(3000);
195-
} catch (InterruptedException e) {
196-
}
197-
}
198-
199-
} catch (Exception e) {
200-
String msg = "Catch " + e.getClass().getName() + " Unable to allow host " + hostIp + " to join pool " + masterIp + " due to " + e.toString();
201-
s_logger.warn(msg, e);
202-
}
203-
if (s_logger.isDebugEnabled()) {
204-
s_logger.debug("Host(" + hostIp + ") unable to Join the pool at " + masterIp);
205-
}
206-
return false;
207-
}
208-
209-
210151
public Connection getConnect(String ip, String username, Queue<String> password) {
211152
Connection conn = new Connection(getURL(ip), 10);
212153
try {

0 commit comments

Comments
 (0)