From 33b763d703ef3186ea7e0d5ec6dfff50ea81416b Mon Sep 17 00:00:00 2001 From: anthony Date: Fri, 18 Feb 2011 14:52:15 -0800 Subject: [PATCH] bug 8582: allow create snapshot policy with unattached volume status 8582: resolved fixed --- .../cloud/storage/snapshot/SnapshotManagerImpl.java | 8 -------- .../cloud/storage/snapshot/SnapshotSchedulerImpl.java | 10 +++++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 2644d42c0b9..7875a1d3802 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -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 diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java index 1273ab167f6..d60528b3aad 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java @@ -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);