use locallogin to check xensever host

This commit is contained in:
anthony 2011-02-08 22:23:22 -08:00
parent 16366fb4e0
commit ebf196240a
2 changed files with 16 additions and 7 deletions

View File

@ -199,6 +199,7 @@ import com.xensource.xenapi.PBD;
import com.xensource.xenapi.PIF;
import com.xensource.xenapi.Pool;
import com.xensource.xenapi.SR;
import com.xensource.xenapi.Session;
import com.xensource.xenapi.Task;
import com.xensource.xenapi.Types;
import com.xensource.xenapi.Types.BadServerResponse;
@ -342,15 +343,23 @@ public abstract class CitrixResourceBase implements ServerResource {
}
protected boolean pingxenserver() {
XenServerConnection conn = (XenServerConnection) getConnection();
Session slaveSession = null;
Connection slaveConn = null;
try {
Host host = Host.getByUuid(conn, _host.uuid);
host.enable(conn);
URL slaveUrl = null;
slaveUrl = _connPool.getURL(_host.ip);
slaveConn = new Connection(slaveUrl);
slaveSession = Session.slaveLocalLoginWithPassword(slaveConn, _username, _password);
return true;
} catch (Exception e) {
String msg = "Catch Exception " + e.getClass().getName() + " : Enable " + _host + " in pool(" + _host.pool + ") failed due to "
+ e.toString();
s_logger.warn(msg);
} finally {
if( slaveSession != null ){
try{
Session.localLogout(slaveConn);
} catch (Exception e) {
}
slaveConn.dispose();
}
}
return false;
}

View File

@ -527,7 +527,7 @@ public class XenServerConnectionPool {
}
}
private URL getURL(String ip){
public URL getURL(String ip){
try {
return new URL("https://" + ip);
} catch (Exception e) {