mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Merge branch '4.16'
This commit is contained in:
commit
e3132af64e
@ -118,4 +118,6 @@ public interface SnapshotApiService {
|
||||
Snapshot backupSnapshotFromVmSnapshot(Long snapshotId, Long vmId, Long volumeId, Long vmSnapshotId);
|
||||
|
||||
SnapshotPolicy updateSnapshotPolicy(UpdateSnapshotPolicyCmd updateSnapshotPolicyCmd);
|
||||
|
||||
void markVolumeSnapshotsAsDestroyed(Volume volume);
|
||||
}
|
||||
|
||||
@ -122,6 +122,7 @@ import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeDetailsDao;
|
||||
import com.cloud.storage.snapshot.SnapshotApiService;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.storage.template.TemplateProp;
|
||||
import com.cloud.user.AccountManager;
|
||||
@ -194,6 +195,8 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
private StorageManager _storageMgr;
|
||||
@Inject
|
||||
private AnnotationDao annotationDao;
|
||||
@Inject
|
||||
private SnapshotApiService snapshotApiService;
|
||||
|
||||
private final static String SNAPSHOT_ID = "SNAPSHOT_ID";
|
||||
|
||||
@ -448,9 +451,9 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
volDao.remove(vo.getId());
|
||||
}
|
||||
|
||||
SnapshotDataStoreVO snapStoreVo = _snapshotStoreDao.findByVolume(vo.getId(), DataStoreRole.Primary);
|
||||
List<SnapshotDataStoreVO> snapStoreVOs = _snapshotStoreDao.listAllByVolumeAndDataStore(vo.getId(), DataStoreRole.Primary);
|
||||
|
||||
if (snapStoreVo != null) {
|
||||
for (SnapshotDataStoreVO snapStoreVo : snapStoreVOs) {
|
||||
long storagePoolId = snapStoreVo.getDataStoreId();
|
||||
StoragePoolVO storagePoolVO = storagePoolDao.findById(storagePoolId);
|
||||
|
||||
@ -468,6 +471,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
_snapshotStoreDao.remove(snapStoreVo.getId());
|
||||
}
|
||||
}
|
||||
snapshotApiService.markVolumeSnapshotsAsDestroyed(vo);
|
||||
} else {
|
||||
vo.processEvent(Event.OperationFailed);
|
||||
apiResult.setResult(result.getResult());
|
||||
|
||||
@ -60,6 +60,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -1543,4 +1544,16 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
|
||||
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, new Long(volume.getSize()));
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markVolumeSnapshotsAsDestroyed(Volume volume) {
|
||||
List<SnapshotVO> snapshots = _snapshotDao.listByVolumeId(volume.getId());
|
||||
for (SnapshotVO snapshot: snapshots) {
|
||||
List<SnapshotDataStoreVO> snapshotDataStoreVOs = _snapshotStoreDao.findBySnapshotId(snapshot.getId());
|
||||
if (CollectionUtils.isEmpty(snapshotDataStoreVOs)) {
|
||||
snapshot.setState(Snapshot.State.Destroyed);
|
||||
_snapshotDao.update(snapshot.getId(), snapshot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user