mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 8582: allow create snapshot policy with unattached volume
status 8582: resolved fixed
This commit is contained in:
parent
80f4ed404f
commit
33b763d703
@ -1000,14 +1000,6 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
// If an account was passed in, make sure that it matches the account of the volume
|
||||
checkAccountPermissions(volume.getAccountId(), volume.getDomainId(), "volume", volumeId);
|
||||
|
||||
StoragePoolVO storagePoolVO = _storagePoolDao.findById(volume.getPoolId());
|
||||
if (storagePoolVO == null) {
|
||||
throw new InvalidParameterValueException("volumeId: " + volumeId + " please attach this volume to a VM before create snapshot policy for it");
|
||||
}
|
||||
if (storagePoolVO.isLocal()) {
|
||||
throw new InvalidParameterValueException("Failed to create snapshot policy, cannot create a snapshot from a volume residing on a local storage pool, poolId: " + volume.getPoolId());
|
||||
}
|
||||
|
||||
Long instanceId = volume.getInstanceId();
|
||||
if (instanceId != null) {
|
||||
// It is not detached, but attached to a VM
|
||||
|
||||
@ -44,10 +44,12 @@ import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.SnapshotPolicyVO;
|
||||
import com.cloud.storage.SnapshotScheduleVO;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.SnapshotPolicyDao;
|
||||
import com.cloud.storage.dao.SnapshotScheduleDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.DateUtil;
|
||||
@ -74,7 +76,8 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
||||
@Inject protected SnapshotPolicyDao _snapshotPolicyDao;
|
||||
@Inject protected AsyncJobManager _asyncMgr;
|
||||
@Inject protected SnapshotManager _snapshotManager;
|
||||
@Inject protected StoragePoolHostDao _poolHostDao;
|
||||
@Inject protected StoragePoolHostDao _poolHostDao;
|
||||
@Inject protected VolumeDao _volsDao;
|
||||
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
|
||||
private int _snapshotPollInterval;
|
||||
@ -214,6 +217,11 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
||||
for (SnapshotScheduleVO snapshotToBeExecuted : snapshotsToBeExecuted) {
|
||||
long policyId = snapshotToBeExecuted.getPolicyId();
|
||||
long volumeId = snapshotToBeExecuted.getVolumeId();
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
if ( volume.getPoolId() == null) {
|
||||
// this volume is not attached
|
||||
continue;
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
Date scheduledTimestamp = snapshotToBeExecuted.getScheduledTimestamp();
|
||||
displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, scheduledTimestamp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user