bug 12040: fixed the problem where if the connection is not retrievable, we cause a classcastexception

Reviewed-by: Anthony
This commit is contained in:
Alex Huang 2011-11-15 12:02:05 -08:00
parent c6dc4f8435
commit 110b37a937
3 changed files with 13 additions and 1 deletions

View File

@ -45,6 +45,10 @@ public class RebootAnswer extends Answer {
bytesReceived = null;
}
public RebootAnswer(RebootCommand cmd, Exception e) {
super(cmd, e);
}
public void setBytesReceived(Long bytesReceived) {
this.bytesReceived = bytesReceived;
}

View File

@ -34,6 +34,11 @@ public class StopAnswer extends RebootAnswer {
}
public StopAnswer(StopCommand cmd, Exception e) {
super(cmd, e);
}
@Override
public Integer getVncPort() {
return vncPort;
}

View File

@ -3072,9 +3072,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
@Override
public StopAnswer execute(StopCommand cmd) {
Connection conn = getConnection();
String vmName = cmd.getVmName();
try {
Connection conn = getConnection();
Set<VM> vms = VM.getByNameLabel(conn, vmName);
// stop vm which is running on this host or is in halted state
Iterator<VM> iter = vms.iterator();
@ -3190,6 +3190,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
String msg = "Stop Vm " + vmName + " fail due to " + e.getMessage();
s_logger.warn(msg, e);
return new StopAnswer(cmd, msg);
} catch (Exception e) {
s_logger.warn("Unable to stop " + vmName + " due to ", e);
return new StopAnswer(cmd, e);
}
return new StopAnswer(cmd, "Stop VM failed");
}