From ec722df00ef2b3249fa00453467ef9038e6aa07c Mon Sep 17 00:00:00 2001 From: Sateesh Chodapuneedi Date: Thu, 27 Jun 2013 12:41:11 +0530 Subject: [PATCH] CLOUDSTACK-2943 [ZWPS][VMWARE]: NPE while creating volume from snapshot Snapshot of volume is now correctly marked with hypervisor type the volume belongs to. Earlier hypervisor_type of snapshot was NULL as cluster_id is null for zonewide storage pool. Signed-off-by: Sateesh Chodapuneedi --- .../com/cloud/storage/snapshot/SnapshotManagerImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index c720169b2d3..e9641ab894e 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd; import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy; @@ -1031,7 +1032,12 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, // Create the Snapshot object and save it so we can return it to the // user - HypervisorType hypervisorType = this._volsDao.getHypervisorType(volumeId); + HypervisorType hypervisorType = HypervisorType.None; + if (storagePoolVO.getScope() == ScopeType.ZONE) { + hypervisorType = storagePoolVO.getHypervisor(); + } else { + hypervisorType = this._volsDao.getHypervisorType(volumeId); + } SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), null, snapshotName, (short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType); SnapshotVO snapshot = _snapshotDao.persist(snapshotVO);