use of com.cloud.storage.SnapshotVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method deleteSolidFireVolume.
private void deleteSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection, long csVolumeId, long sfVolumeId) {
List<SnapshotVO> lstSnapshots = getNonDestroyedSnapshots(csVolumeId);
boolean deleteVolume = true;
for (SnapshotVO snapshot : lstSnapshots) {
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(snapshot.getId(), SolidFireUtil.SNAPSHOT_ID);
if (snapshotDetails != null && snapshotDetails.getValue() != null) {
deleteVolume = false;
break;
}
}
if (deleteVolume) {
SolidFireUtil.deleteVolume(sfConnection, sfVolumeId);
}
}
use of com.cloud.storage.SnapshotVO in project cloudstack by apache.
the class SnapshotDaoImpl method updateState.
@Override
public boolean updateState(State currentState, Event event, State nextState, SnapshotVO snapshot, Object data) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SnapshotVO snapshotVO = snapshot;
snapshotVO.setState(nextState);
super.update(snapshotVO.getId(), snapshotVO);
txn.commit();
return true;
}
use of com.cloud.storage.SnapshotVO in project cloudstack by apache.
the class SnapshotDaoImpl method remove.
@Override
@DB
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SnapshotVO entry = findById(id);
if (entry != null) {
_tagsDao.removeByIdAndType(id, ResourceObjectType.Snapshot);
}
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.storage.SnapshotVO in project cloudstack by apache.
the class StorageSystemDataMotionStrategy method handleCreateManagedVolumeFromNonManagedSnapshot.
/**
* Creates a managed volume on the storage from a snapshot that resides on the secondary storage (archived snapshot).
* @param snapshotInfo snapshot on secondary
* @param volumeInfo volume to be created on the storage
* @param callback for async
*/
private void handleCreateManagedVolumeFromNonManagedSnapshot(SnapshotInfo snapshotInfo, VolumeInfo volumeInfo, AsyncCompletionCallback<CopyCommandResult> callback) {
String errMsg = null;
CopyCmdAnswer copyCmdAnswer = null;
try {
// at this point, the snapshotInfo and volumeInfo should have the same disk offering ID (so either one should be OK to get a DiskOfferingVO instance)
DiskOfferingVO diskOffering = _diskOfferingDao.findByIdIncludingRemoved(volumeInfo.getDiskOfferingId());
SnapshotVO snapshot = _snapshotDao.findById(snapshotInfo.getId());
// update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage)
_volumeService.updateHypervisorSnapshotReserveForVolume(diskOffering, volumeInfo.getId(), snapshot.getHypervisorType());
HostVO hostVO;
// create a volume on the storage
AsyncCallFuture<VolumeApiResult> future = _volumeService.createVolumeAsync(volumeInfo, volumeInfo.getDataStore());
VolumeApiResult result = future.get();
if (result.isFailed()) {
LOGGER.error("Failed to create a volume: " + result.getResult());
throw new CloudRuntimeException(result.getResult());
}
volumeInfo = _volumeDataFactory.getVolume(volumeInfo.getId(), volumeInfo.getDataStore());
volumeInfo.processEvent(Event.MigrationRequested);
volumeInfo = _volumeDataFactory.getVolume(volumeInfo.getId(), volumeInfo.getDataStore());
handleQualityOfServiceForVolumeMigration(volumeInfo, PrimaryDataStoreDriver.QualityOfServiceState.MIGRATION);
hostVO = getHost(snapshotInfo.getDataCenterId(), snapshotInfo.getHypervisorType(), false);
// copy the volume from secondary via the hypervisor
if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType())) {
copyCmdAnswer = performCopyOfVdi(volumeInfo, snapshotInfo, hostVO);
} else {
copyCmdAnswer = copyImageToVolume(snapshotInfo, volumeInfo, hostVO);
}
if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) {
if (copyCmdAnswer != null && StringUtils.isNotEmpty(copyCmdAnswer.getDetails())) {
throw new CloudRuntimeException(copyCmdAnswer.getDetails());
} else {
throw new CloudRuntimeException("Unable to create volume from snapshot");
}
}
} catch (Exception ex) {
errMsg = "Copy operation failed in 'StorageSystemDataMotionStrategy.handleCreateManagedVolumeFromNonManagedSnapshot': " + ex.getMessage();
throw new CloudRuntimeException(errMsg);
} finally {
handleQualityOfServiceForVolumeMigration(volumeInfo, PrimaryDataStoreDriver.QualityOfServiceState.NO_MIGRATION);
if (copyCmdAnswer == null) {
copyCmdAnswer = new CopyCmdAnswer(errMsg);
}
CopyCommandResult result = new CopyCommandResult(null, copyCmdAnswer);
result.setResult(errMsg);
callback.complete(result);
}
}
use of com.cloud.storage.SnapshotVO in project cloudstack by apache.
the class SnapshotServiceImpl method cleanupVolumeDuringSnapshotFailure.
@Override
public void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) {
SnapshotVO snaphsot = _snapshotDao.findById(snapshotId);
if (snaphsot != null) {
if (snaphsot.getState() != Snapshot.State.BackedUp) {
List<SnapshotDataStoreVO> snapshotDataStoreVOs = _snapshotStoreDao.findBySnapshotId(snapshotId);
for (SnapshotDataStoreVO snapshotDataStoreVO : snapshotDataStoreVOs) {
s_logger.debug("Remove snapshot " + snapshotId + ", status " + snapshotDataStoreVO.getState() + " on snapshot_store_ref table with id: " + snapshotDataStoreVO.getId());
_snapshotStoreDao.remove(snapshotDataStoreVO.getId());
}
s_logger.debug("Remove snapshot " + snapshotId + " status " + snaphsot.getState() + " from snapshot table");
_snapshotDao.remove(snapshotId);
}
}
}
Aggregations