@Override public boolean canOperateOnVolume(Volume volume) { List<SnapshotVO> snapshots = _snapshotDao.listByStatus(volume.getId(), Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp); if (snapshots.size() > 0) { return false; } return true; }
private boolean checkStatusOfVolumeSnapshots(long vmId, Volume.Type type) { List<VolumeVO> listVolumes = null; if (type == Volume.Type.ROOT) { listVolumes = _volsDao.findByInstanceAndType(vmId, type); } else if (type == Volume.Type.DATADISK) { listVolumes = _volsDao.findByInstanceAndType(vmId, type); } else { listVolumes = _volsDao.findByInstance(vmId); } s_logger.debug("Found "+listVolumes.size()+" no. of volumes of type "+type+" for vm with VM ID "+vmId); for (VolumeVO volume : listVolumes) { Long volumeId = volume.getId(); s_logger.debug("Checking status of snapshots for Volume with Volume Id: "+volumeId); List<SnapshotVO> ongoingSnapshots = _snapshotDao.listByStatus(volumeId, Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp); int ongoingSnapshotsCount = ongoingSnapshots.size(); s_logger.debug("The count of ongoing Snapshots for VM with ID "+vmId+" and disk type "+type+" is "+ongoingSnapshotsCount); if (ongoingSnapshotsCount > 0) { s_logger.debug("Found "+ongoingSnapshotsCount+" no. of snapshots, on volume of type "+type+", which snapshots are not yet backed up"); return true; } } return false; }
@Override public void syncVolumeSnapshotsToRegionStore(long volumeId, DataStore store) { if (dataStoreMgr.isRegionStore(store)) { // list all backed up snapshots for the given volume List<SnapshotVO> snapshots = _snapshotDao.listByStatus(volumeId, Snapshot.State.BackedUp); if (snapshots != null) { for (SnapshotVO snapshot : snapshots) { syncSnapshotToRegionStore(snapshot.getId(), store); } } } }
List<SnapshotVO> ongoingSnapshots = _snapshotDao.listByStatus(cmd.getId(), Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp); if (ongoingSnapshots.size() > 0) { throw new CloudRuntimeException("There is/are unbacked up snapshot(s) on this volume, resize volume is not permitted, please try again later.");