mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
c9edb7ecfe
commit
ff1c0647fc
@ -204,17 +204,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
List<HostVO> 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<HostVO> hosts;
|
||||
hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
|
||||
String masterIp = null;
|
||||
String username = null;
|
||||
String password = null;
|
||||
Queue<String> pass = new LinkedList<String>();
|
||||
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<Pool> 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");
|
||||
|
||||
@ -148,65 +148,6 @@ public class XenServerConnectionPool {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean joinPool(Connection conn, String hostIp, String masterIp, String username, Queue<String> 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<String> password) {
|
||||
Connection conn = new Connection(getURL(ip), 10);
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user