Skip to content

Commit 41e75ab

Browse files
committed
bug 9107: don't allow move volume if there are snapshot policy or snapshot on this volume
status 9107: resolved fixed
1 parent 404b288 commit 41e75ab

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎server/src/com/cloud/storage/StorageManagerImpl.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
import com.cloud.storage.allocator.StoragePoolAllocator;
130130
import com.cloud.storage.dao.DiskOfferingDao;
131131
import com.cloud.storage.dao.SnapshotDao;
132+
import com.cloud.storage.dao.SnapshotPolicyDao;
132133
import com.cloud.storage.dao.StoragePoolDao;
133134
import com.cloud.storage.dao.StoragePoolHostDao;
134135
import com.cloud.storage.dao.StoragePoolWorkDao;
@@ -205,6 +206,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
205206
@Inject protected ConsoleProxyDao _consoleProxyDao;
206207
@Inject protected DetailsDao _detailsDao;
207208
@Inject protected SnapshotDao _snapshotDao;
209+
@Inject protected SnapshotPolicyDao _snapshotPolicyDao;
208210
@Inject protected StoragePoolHostDao _storagePoolHostDao;
209211
@Inject protected AlertManager _alertMgr;
210212
@Inject protected VMTemplateHostDao _vmTemplateHostDao = null;
@@ -1323,6 +1325,17 @@ public boolean addPoolToHost(long hostId, StoragePoolVO pool) {
13231325

13241326
@Override
13251327
public VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) {
1328+
1329+
List<SnapshotVO> snapshots = _snapshotDao.listByVolumeId(volume.getId());
1330+
if( snapshots != null && snapshots.size() > 0) {
1331+
throw new CloudRuntimeException("Unable to move volume " + volume.getId() + " due to there are snapshots for this volume");
1332+
}
1333+
1334+
List<SnapshotPolicyVO> snapshotPolicys = _snapshotPolicyDao.listByVolumeId(volume.getId());
1335+
if( snapshotPolicys != null && snapshotPolicys.size() > 0) {
1336+
throw new CloudRuntimeException("Unable to move volume " + volume.getId() + " due to there are snapshot policyes for this volume");
1337+
}
1338+
13261339
// Find a destination storage pool with the specified criteria
13271340
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
13281341
DiskProfile dskCh = new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(),

0 commit comments

Comments
 (0)