use of org.apache.cloudstack.storage.command.CommandResult in project cloudstack by apache.
the class NexentaPrimaryDataStoreDriver method deleteAsync.
@Override
public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallback<CommandResult> callback) {
String errorMessage = null;
if (data.getType() == DataObjectType.VOLUME) {
VolumeInfo volumeInfo = (VolumeInfo) data;
long storagePoolId = store.getId();
NexentaStorAppliance appliance = getNexentaStorAppliance(storagePoolId);
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
// _storagePoolDao.update(stoagePoolId);
} else {
errorMessage = String.format("Invalid DataObjectType(%s) passed to deleteAsync", data.getType());
}
CommandResult result = new CommandResult();
result.setResult(errorMessage);
callback.complete(result);
}
use of org.apache.cloudstack.storage.command.CommandResult in project cloudstack by apache.
the class SamplePrimaryDataStoreDriverImpl method deleteCallback.
public Void deleteCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback, AsyncRpcContext<CommandResult> context) {
CommandResult result = new CommandResult();
Answer answer = callback.getResult();
if (!answer.getResult()) {
result.setResult(answer.getDetails());
}
context.getParentCallback().complete(result);
return null;
}
use of org.apache.cloudstack.storage.command.CommandResult in project cloudstack by apache.
the class DateraPrimaryDataStoreDriver method revertSnapshot.
/**
* Revert snapshot for a volume
* @param snapshotInfo Information about volume snapshot
* @param snapshotOnPrimaryStore Not used
* @throws CloudRuntimeException
*/
@Override
public void revertSnapshot(SnapshotInfo snapshotInfo, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback) {
VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
VolumeVO volumeVO = _volumeDao.findById(volumeInfo.getId());
long storagePoolId = volumeVO.getPoolId();
long csSnapshotId = snapshotInfo.getId();
s_logger.info("Datera - restoreVolumeSnapshot from snapshotId " + String.valueOf(csSnapshotId) + " to volume" + volumeVO.getName());
DateraObject.AppInstance appInstance;
try {
if (volumeVO == null || volumeVO.getRemoved() != null) {
String errMsg = "The volume that the snapshot belongs to no longer exists.";
CommandResult commandResult = new CommandResult();
commandResult.setResult(errMsg);
callback.complete(commandResult);
return;
}
DateraObject.DateraConnection conn = DateraUtil.getDateraConnection(storagePoolId, _storagePoolDetailsDao);
SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, DateraUtil.SNAPSHOT_ID);
if (snapshotDetails != null && snapshotDetails.getValue() != null) {
// Native snapshot being used, restore snapshot from Datera AppInstance
String snapshotName = snapshotDetails.getValue();
s_logger.info("Datera - restoreVolumeSnapshot: " + snapshotName);
appInstance = DateraUtil.restoreVolumeSnapshot(conn, snapshotName);
Preconditions.checkNotNull(appInstance);
updateVolumeDetails(volumeInfo.getId(), appInstance.getSize());
}
CommandResult commandResult = new CommandResult();
callback.complete(commandResult);
} catch (Exception ex) {
s_logger.debug("Error in 'revertSnapshot()'. CloudStack snapshot ID: " + csSnapshotId, ex);
throw new CloudRuntimeException(ex.getMessage());
}
}
use of org.apache.cloudstack.storage.command.CommandResult in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateAcrossClusterSuccess.
@Test
public void testMigrateAcrossClusterSuccess() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(2L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(true);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertTrue("Migration across cluster isn't successful.", result.isSuccess());
}
use of org.apache.cloudstack.storage.command.CommandResult in project cloudstack by apache.
the class VmwareStorageMotionStrategyTest method testMigrateAcrossClusterFailure.
@Test
public void testMigrateAcrossClusterFailure() throws Exception {
Host srcHost = mock(Host.class);
Host destHost = mock(Host.class);
when(srcHost.getClusterId()).thenReturn(1L);
when(destHost.getClusterId()).thenReturn(2L);
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
VirtualMachineTO to = mock(VirtualMachineTO.class);
when(to.getId()).thenReturn(6L);
VMInstanceVO instance = mock(VMInstanceVO.class);
when(instanceDao.findById(6L)).thenReturn(instance);
MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
MigrateWithStorageAnswer migAnswerMock = mock(MigrateWithStorageAnswer.class);
when(migAnswerMock.getResult()).thenReturn(false);
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
assertFalse("Migration across cluster didn't fail.", result.isSuccess());
}
Aggregations