@@ -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