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 <sateesh@apache.org>
This commit is contained in:
Sateesh Chodapuneedi 2013-06-27 12:41:11 +05:30
parent ff33a35835
commit ec722df00e
1 changed files with 7 additions and 1 deletions

View File

@ -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);