mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4008: fix snapshot npe if its volume is deleted
This commit is contained in:
parent
3c05999354
commit
ebb30898c9
|
|
@ -22,6 +22,7 @@ import com.cloud.agent.api.to.DataObjectType;
|
|||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
|
||||
public class SnapshotObjectTO implements DataTO {
|
||||
private String path;
|
||||
|
|
@ -40,8 +41,12 @@ public class SnapshotObjectTO implements DataTO {
|
|||
public SnapshotObjectTO(SnapshotInfo snapshot) {
|
||||
this.path = snapshot.getPath();
|
||||
this.setId(snapshot.getId());
|
||||
this.volume = (VolumeObjectTO) snapshot.getBaseVolume().getTO();
|
||||
this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
|
||||
VolumeInfo vol = snapshot.getBaseVolume();
|
||||
if (vol != null) {
|
||||
this.volume = (VolumeObjectTO)vol.getTO();
|
||||
this.setVmName(vol.getAttachedVmName());
|
||||
}
|
||||
|
||||
SnapshotInfo parentSnapshot = snapshot.getParent();
|
||||
if (parentSnapshot != null) {
|
||||
this.parentSnapshotPath = parentSnapshot.getPath();
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory {
|
|||
@Override
|
||||
public VolumeInfo getVolume(long volumeId) {
|
||||
VolumeVO volumeVO = volumeDao.findById(volumeId);
|
||||
if (volumeVO == null) {
|
||||
return null;
|
||||
}
|
||||
VolumeObject vol = null;
|
||||
if (volumeVO.getPoolId() == null) {
|
||||
DataStore store = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue