Skip to content

Commit b79f949

Browse files
author
Anthony Xu
committed
CLOUDSTACK-5923: CS doesn't do master switch for XS any more, CS will depend on XS HA to do master switch, XS HA needs to be enabled.
Conflicts: plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
1 parent ab627bc commit b79f949

3 files changed

Lines changed: 54 additions & 464 deletions

File tree

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ protected boolean xenserverHotFixEnabled() {
195195
String hostIp = ia.getHostAddress();
196196
Queue<String> pass = new LinkedList<String>();
197197
pass.add(password);
198-
String masterIp = _connPool.getMasterIp(hostIp, username, pass);
199-
conn = _connPool.masterConnect(masterIp, username, pass);
198+
conn = _connPool.getConnect(hostIp, username, pass);
200199
if (conn == null) {
201200
String msg = "Unable to get a connection to " + url;
202201
s_logger.debug(msg);
@@ -398,7 +397,7 @@ protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId)
398397
password = host.getDetail("password");
399398
pass.add(password);
400399
String address = host.getPrivateIpAddress();
401-
Connection hostConn = _connPool.slaveConnect(address, username, pass);
400+
Connection hostConn = _connPool.getConnect(address, username, pass);
402401
if (hostConn == null) {
403402
continue;
404403
}
@@ -411,9 +410,9 @@ protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId)
411410
} catch (Exception e) {
412411
s_logger.warn("Can not get master ip address from host " + address);
413412
} finally {
414-
try {
415-
Session.localLogout(hostConn);
416-
} catch (Exception e) {
413+
try{
414+
Session.logout(hostConn);
415+
} catch (Exception e ) {
417416
}
418417
hostConn.dispose();
419418
hostConn = null;

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

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -424,23 +424,12 @@ protected boolean pingdomr(Connection conn, String host, String port) {
424424
}
425425

426426
protected boolean pingXenServer() {
427-
Session slaveSession = null;
428-
Connection slaveConn = null;
427+
Connection conn = getConnection();
429428
try {
430-
URL slaveUrl = null;
431-
slaveUrl = ConnPool.getURL(_host.ip);
432-
slaveConn = new Connection(slaveUrl, 10);
433-
slaveSession = ConnPool.slaveLocalLoginWithPassword(slaveConn, _username, _password);
429+
callHostPlugin(conn, "echo", "main");
434430
return true;
435431
} catch (Exception e) {
436-
} finally {
437-
if (slaveSession != null) {
438-
try {
439-
Session.localLogout(slaveConn);
440-
} catch (Exception e) {
441-
}
442-
slaveConn.dispose();
443-
}
432+
s_logger.debug("cannot ping host " + _host.ip + " due to " + e.toString(), e);
444433
}
445434
return false;
446435
}
@@ -6020,9 +6009,9 @@ protected StorageSubsystemCommandHandler getStorageHandler() {
60206009
}
60216010

60226011
private void CheckXenHostInfo() throws ConfigurationException {
6023-
Connection conn = ConnPool.slaveConnect(_host.ip, _username, _password);
6024-
if (conn == null) {
6025-
throw new ConfigurationException("Can not create slave connection to " + _host.ip);
6012+
Connection conn = _connPool.getConnect(_host.ip, _username, _password);
6013+
if( conn == null ) {
6014+
throw new ConfigurationException("Can not create connection to " + _host.ip);
60266015
}
60276016
try {
60286017
Host.Record hostRec = null;
@@ -6042,7 +6031,7 @@ private void CheckXenHostInfo() throws ConfigurationException {
60426031
}
60436032
} finally {
60446033
try {
6045-
Session.localLogout(conn);
6034+
Session.logout(conn);
60466035
} catch (Exception e) {
60476036
}
60486037
}
@@ -7311,35 +7300,11 @@ protected Answer execute(PoolEjectCommand cmd) {
73117300

73127301
Host.Record hostr = poolr.master.getRecord(conn);
73137302
if (_host.uuid.equals(hostr.uuid)) {
7314-
boolean mastermigrated = false;
73157303
Map<Host, Host.Record> hostMap = Host.getAllRecords(conn);
7316-
if (hostMap.size() != 1) {
7317-
Host newMaster = null;
7318-
Host.Record newMasterRecord = null;
7319-
for (Map.Entry<Host, Host.Record> entry : hostMap.entrySet()) {
7320-
if (_host.uuid.equals(entry.getValue().uuid)) {
7321-
continue;
7322-
}
7323-
newMaster = entry.getKey();
7324-
newMasterRecord = entry.getValue();
7325-
s_logger.debug("New master for the XenPool is " + newMasterRecord.uuid + " : " + newMasterRecord.address);
7326-
try {
7327-
ConnPool.switchMaster(_host.ip, _host.pool, conn, newMaster, _username, _password, _wait);
7328-
mastermigrated = true;
7329-
break;
7330-
} catch (Exception e) {
7331-
s_logger.warn("Unable to switch the new master to " + newMasterRecord.uuid + ": " + newMasterRecord.address + " due to " + e.toString());
7332-
}
7333-
}
7334-
} else {
7335-
s_logger.debug("This is last host to eject, so don't need to eject: " + hostuuid);
7336-
return new Answer(cmd);
7337-
}
7338-
if (!mastermigrated) {
7339-
String msg = "this host is master, and cannot designate a new master";
7304+
if (hostMap.size() > 1) {
7305+
String msg = "This host is XS master, please designate a new XS master throught XenCenter before you delete this host from CS";
73407306
s_logger.debug(msg);
73417307
return new Answer(cmd, false, msg);
7342-
73437308
}
73447309
}
73457310

0 commit comments

Comments
 (0)