Skip to content

Commit 305d8ae

Browse files
Anthony Xuyadvr
authored andcommitted
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.
(cherry picked from commit b79f949) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> 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 6cd31d3 commit 305d8ae

3 files changed

Lines changed: 47 additions & 468 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
188188
String hostIp = ia.getHostAddress();
189189
Queue<String> pass=new LinkedList<String>();
190190
pass.add(password);
191-
String masterIp = _connPool.getMasterIp(hostIp, username, pass);
192-
conn = _connPool.masterConnect(masterIp, username, pass);
191+
conn = _connPool.getConnect(hostIp, username, pass);
193192
if (conn == null) {
194193
String msg = "Unable to get a connection to " + url;
195194
s_logger.debug(msg);
@@ -392,7 +391,7 @@ protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId)
392391
password = host.getDetail("password");
393392
pass.add(password);
394393
String address = host.getPrivateIpAddress();
395-
Connection hostConn = _connPool.slaveConnect(address, username, pass);
394+
Connection hostConn = _connPool.getConnect(address, username, pass);
396395
if (hostConn == null) {
397396
continue;
398397
}
@@ -406,7 +405,7 @@ protected boolean addHostsToPool(Connection conn, String hostIp, Long clusterId)
406405
s_logger.warn("Can not get master ip address from host " + address);
407406
} finally {
408407
try{
409-
Session.localLogout(hostConn);
408+
Session.logout(hostConn);
410409
} catch (Exception e ) {
411410
}
412411
hostConn.dispose();

‎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
@@ -427,23 +427,12 @@ protected boolean pingdomr(Connection conn, String host, String port) {
427427
}
428428

429429
protected boolean pingXenServer() {
430-
Session slaveSession = null;
431-
Connection slaveConn = null;
430+
Connection conn = getConnection();
432431
try {
433-
URL slaveUrl = null;
434-
slaveUrl = _connPool.getURL(_host.ip);
435-
slaveConn = new Connection(slaveUrl, 10);
436-
slaveSession = _connPool.slaveLocalLoginWithPassword(slaveConn, _username, _password);
432+
callHostPlugin(conn, "echo", "main");
437433
return true;
438434
} catch (Exception e) {
439-
} finally {
440-
if( slaveSession != null ){
441-
try{
442-
Session.localLogout(slaveConn);
443-
} catch (Exception e) {
444-
}
445-
slaveConn.dispose();
446-
}
435+
s_logger.debug("cannot ping host " + _host.ip + " due to " + e.toString(), e);
447436
}
448437
return false;
449438
}
@@ -6067,9 +6056,9 @@ protected StorageSubsystemCommandHandler getStorageHandler() {
60676056
}
60686057

60696058
private void CheckXenHostInfo() throws ConfigurationException {
6070-
Connection conn = _connPool.slaveConnect(_host.ip, _username, _password);
6059+
Connection conn = _connPool.getConnect(_host.ip, _username, _password);
60716060
if( conn == null ) {
6072-
throw new ConfigurationException("Can not create slave connection to " + _host.ip);
6061+
throw new ConfigurationException("Can not create connection to " + _host.ip);
60736062
}
60746063
try {
60756064
Host.Record hostRec = null;
@@ -6089,7 +6078,7 @@ private void CheckXenHostInfo() throws ConfigurationException {
60896078
}
60906079
} finally {
60916080
try {
6092-
Session.localLogout(conn);
6081+
Session.logout(conn);
60936082
} catch (Exception e) {
60946083
}
60956084
}
@@ -7385,35 +7374,11 @@ protected Answer execute(PoolEjectCommand cmd) {
73857374

73867375
Host.Record hostr = poolr.master.getRecord(conn);
73877376
if (_host.uuid.equals(hostr.uuid)) {
7388-
boolean mastermigrated = false;
73897377
Map<Host, Host.Record> hostMap = Host.getAllRecords(conn);
7390-
if (hostMap.size() != 1) {
7391-
Host newMaster = null;
7392-
Host.Record newMasterRecord = null;
7393-
for (Map.Entry<Host, Host.Record> entry : hostMap.entrySet()) {
7394-
if (_host.uuid.equals(entry.getValue().uuid)) {
7395-
continue;
7396-
}
7397-
newMaster = entry.getKey();
7398-
newMasterRecord = entry.getValue();
7399-
s_logger.debug("New master for the XenPool is " + newMasterRecord.uuid + " : " + newMasterRecord.address);
7400-
try {
7401-
_connPool.switchMaster(_host.ip, _host.pool, conn, newMaster, _username, _password, _wait);
7402-
mastermigrated = true;
7403-
break;
7404-
} catch (Exception e) {
7405-
s_logger.warn("Unable to switch the new master to " + newMasterRecord.uuid + ": " + newMasterRecord.address + " due to " + e.toString());
7406-
}
7407-
}
7408-
} else {
7409-
s_logger.debug("This is last host to eject, so don't need to eject: " + hostuuid);
7410-
return new Answer(cmd);
7411-
}
7412-
if ( !mastermigrated ) {
7413-
String msg = "this host is master, and cannot designate a new master";
7414-
s_logger.debug(msg);
7378+
if (hostMap.size() > 1) {
7379+
String msg = "This host is XS master, please designate a new XS master throught XenCenter before you delete this host from CS";
7380+
s_logger.debug(msg);
74157381
return new Answer(cmd, false, msg);
7416-
74177382
}
74187383
}
74197384

0 commit comments

Comments
 (0)