bug 5242: adding a host does not return useful error

status 5242: closed fixed
This commit is contained in:
Abhinandan Prateek 2011-04-15 17:23:24 +05:30 committed by root
parent 8c5c58dc35
commit efa0417881
6 changed files with 33 additions and 7 deletions

View File

@ -0,0 +1,16 @@
package com.cloud.exception;
import com.cloud.utils.SerialVersionUID;
public class DiscoveredWithErrorException extends DiscoveryException {
private static final long serialVersionUID = SerialVersionUID.DiscoveredWithErrorException;
public DiscoveredWithErrorException(String msg) {
this(msg, null);
}
public DiscoveredWithErrorException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -298,7 +298,7 @@ public class XenServerConnectionPool {
}
public String getMasterIp(String ip, String username, String password) {
public String getMasterIp(String ip, String username, String password) throws XenAPIException {
Connection slaveConn = null;
try{
slaveConn = new Connection(getURL(ip), 10);
@ -312,6 +312,9 @@ public class XenServerConnectionPool {
Host master = pr.master;
masterIp = master.getAddress(slaveConn);
return masterIp;
}catch(Types.SessionAuthenticationFailed e){
s_logger.debug("Failed to slave local login to " + ip + " due to " + e.toString());
throw e;
}catch ( Exception e){
s_logger.debug("Failed to slave local login to " + ip + " due to " + e.toString());
} finally {

View File

@ -106,6 +106,7 @@ import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.event.dao.EventDao;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.DiscoveredWithErrorException;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.InvalidParameterValueException;
@ -970,7 +971,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
try {
resources = discoverer.find(dcId, podId, clusterId, uri,
username, password);
} catch (Exception e) {
} catch (DiscoveredWithErrorException e){
throw e;
}catch (Exception e) {
s_logger.info("Exception in host discovery process with discoverer: "
+ discoverer.getName()
+ ", skip to another discoverer if there is any");

View File

@ -40,6 +40,7 @@ import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.exception.DiscoveredWithErrorException;
import com.cloud.exception.DiscoveryException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
@ -157,7 +158,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
sshConnection.connect(null, 60000, 60000);
if (!sshConnection.authenticateWithPassword(username, password)) {
s_logger.debug("Failed to authenticate");
return null;
throw new DiscoveredWithErrorException("Authetication error");
}
if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "lsmod|grep kvm >& /dev/null", 3)) {
@ -198,7 +199,9 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
details.put("guid", guidWithTail);
return resources;
} catch (Exception e) {
} catch (DiscoveredWithErrorException e){
throw e;
}catch (Exception e) {
String msg = " can't setup agent, due to " + e.toString() + " - " + e.getMessage();
s_logger.warn(msg);
} finally {

View File

@ -46,6 +46,7 @@ import com.cloud.dc.ClusterVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.DiscoveredWithErrorException;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.HostEnvironment;
@ -290,9 +291,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
resource.start();
resources.put(resource, details);
}
} catch (SessionAuthenticationFailed e) {
s_logger.warn("Authentication error", e);
return null;
} catch (SessionAuthenticationFailed e) {
throw new DiscoveredWithErrorException("Authetication error");
} catch (XenAPIException e) {
s_logger.warn("XenAPI exception", e);
return null;

View File

@ -62,4 +62,5 @@ public interface SerialVersionUID {
public static final long sshException = Base | 0x22;
public static final long HttpCallException = Base | 0x23;
public static final long VirtualMachineMigrationException = Base | 0x24;
public static final long DiscoveredWithErrorException = Base | 0x25;
}