use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method deleteSolidFireSnapshot.
private void deleteSolidFireSnapshot(SolidFireUtil.SolidFireConnection sfConnection, long csSnapshotId, long sfSnapshotId) {
SolidFireUtil.deleteSnapshot(sfConnection, sfSnapshotId);
final long volumeId;
final VolumeVO volume;
SnapshotVO snapshot = snapshotDao.findById(csSnapshotId);
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.ORIG_CS_VOLUME_ID);
if (snapshotDetails != null && snapshotDetails.getValue() != null) {
volumeId = Long.valueOf(snapshotDetails.getValue());
} else {
volumeId = snapshot.getVolumeId();
}
volume = volumeDao.findById(volumeId);
if (volume == null) {
// if the CloudStack volume has been deleted
List<SnapshotVO> lstSnapshots = getNonDestroyedSnapshots(snapshot.getVolumeId());
List<SnapshotVO> lstSnapshots2 = new ArrayList<>();
for (SnapshotVO snapshotVo : lstSnapshots) {
// sure snapshotVo.getId() != csSnapshotId when determining if any volume snapshots remain for the given CloudStack volume.
if (snapshotVo.getId() != csSnapshotId) {
snapshotDetails = snapshotDetailsDao.findDetail(snapshotVo.getId(), SolidFireUtil.SNAPSHOT_ID);
// that make use of SolidFire volumes).
if (snapshotDetails != null && snapshotDetails.getValue() != null) {
lstSnapshots2.add(snapshotVo);
}
}
}
if (lstSnapshots2.isEmpty()) {
VolumeVO volumeToDelete = volumeDao.findByIdIncludingRemoved(volumeId);
SolidFireUtil.deleteVolume(sfConnection, Long.parseLong(volumeToDelete.getFolder()));
}
}
}
use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method createTempVolume.
private void createTempVolume(SnapshotInfo snapshotInfo, long storagePoolId) {
long csSnapshotId = snapshotInfo.getId();
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.SNAPSHOT_ID);
if (snapshotDetails == null || snapshotDetails.getValue() == null) {
throw new CloudRuntimeException("'createTempVolume(SnapshotInfo, long)' should not be invoked unless " + SolidFireUtil.SNAPSHOT_ID + " exists.");
}
SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao);
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, "tempVolume");
if (snapshotDetails != null && snapshotDetails.getValue() != null && snapshotDetails.getValue().equalsIgnoreCase("create")) {
long sfAccountId = getCreateSolidFireAccountId(sfConnection, snapshotInfo.getAccountId(), storagePoolId);
SolidFireUtil.SolidFireVolume sfVolume = createCloneFromSnapshot(sfConnection, csSnapshotId, sfAccountId);
addTempVolumeId(csSnapshotId, String.valueOf(sfVolume.getId()));
handleSnapshotDetails(csSnapshotId, DiskTO.IQN, sfVolume.getIqn());
handleSnapshotDetails(csSnapshotId, DiskTO.SCSI_NAA_DEVICE_ID, sfVolume.getScsiNaaDeviceId());
} else if (snapshotDetails != null && snapshotDetails.getValue() != null && snapshotDetails.getValue().equalsIgnoreCase("delete")) {
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
SolidFireUtil.deleteVolume(sfConnection, Long.parseLong(snapshotDetails.getValue()));
removeTempVolumeId(csSnapshotId);
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, DiskTO.IQN);
snapshotDetailsDao.remove(snapshotDetails.getId());
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, DiskTO.SCSI_NAA_DEVICE_ID);
snapshotDetailsDao.remove(snapshotDetails.getId());
} else {
throw new CloudRuntimeException("Invalid state in 'createTempVolume(SnapshotInfo, long)'");
}
}
use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method addTempVolumeId.
private void addTempVolumeId(long csSnapshotId, String tempVolumeId) {
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
if (snapshotDetails == null || snapshotDetails.getValue() == null) {
throw new CloudRuntimeException("'addTempVolumeId' should not be invoked unless " + SolidFireUtil.VOLUME_ID + " exists.");
}
String originalVolumeId = snapshotDetails.getValue();
handleSnapshotDetails(csSnapshotId, SolidFireUtil.TEMP_VOLUME_ID, originalVolumeId);
handleSnapshotDetails(csSnapshotId, SolidFireUtil.VOLUME_ID, tempVolumeId);
}
use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method handleSnapshotDetails.
private void handleSnapshotDetails(long csSnapshotId, String name, String value) {
snapshotDetailsDao.removeDetail(csSnapshotId, name);
SnapshotDetailsVO snapshotDetails = new SnapshotDetailsVO(csSnapshotId, name, value, false);
snapshotDetailsDao.persist(snapshotDetails);
}
use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method createCloneFromSnapshot.
private SolidFireUtil.SolidFireVolume createCloneFromSnapshot(SolidFireUtil.SolidFireConnection sfConnection, long csSnapshotId, long sfAccountId) {
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
long sfVolumeId = Long.parseLong(snapshotDetails.getValue());
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.SNAPSHOT_ID);
long sfSnapshotId = Long.parseLong(snapshotDetails.getValue());
SolidFireUtil.SolidFireSnapshot sfSnapshot = SolidFireUtil.getSnapshot(sfConnection, sfVolumeId, sfSnapshotId);
long newSfVolumeId = SolidFireUtil.createClone(sfConnection, sfVolumeId, sfSnapshotId, sfAccountId, SolidFireUtil.getSolidFireVolumeName(sfSnapshot.getName()), null);
snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.STORAGE_POOL_ID);
long storagePoolId = Long.parseLong(snapshotDetails.getValue());
final Iops iops = getIops(MIN_IOPS_FOR_TEMP_VOLUME, MAX_IOPS_FOR_TEMP_VOLUME, storagePoolId);
SolidFireUtil.modifyVolume(sfConnection, newSfVolumeId, null, null, iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
return SolidFireUtil.getVolume(sfConnection, newSfVolumeId);
}
Aggregations