CLOUDSTACK-8164: Look for all host to avoid NPE

(cherry picked from commit d8def3dc0b)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java
This commit is contained in:
Abhinandan Prateek 2015-01-19 11:29:22 +05:30 committed by Rohit Yadav
parent 2c7cacd9df
commit 969bbb02a9
2 changed files with 5 additions and 3 deletions

View File

@ -79,9 +79,9 @@ public class VMSnapshotHelperImpl implements VMSnapshotHelper {
return vm.getHostId();
// check if lastHostId is available
if(vm.getLastHostId() != null){
HostVO lastHost = hostDao.findById(vm.getLastHostId());
if(lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
if (vm.getLastHostId() != null) {
HostVO lastHost = hostDao.findByIdIncludingRemoved(vm.getLastHostId());
if (lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
return lastHost.getId();
}

View File

@ -766,6 +766,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
if (jobResult != null) {
if (jobResult instanceof ConcurrentOperationException)
throw (ConcurrentOperationException)jobResult;
else if (jobResult instanceof InvalidParameterValueException)
throw (InvalidParameterValueException)jobResult;
else if (jobResult instanceof Throwable)
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
}