Search in sources :

Example 46 with CopyCommandResult

use of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult in project cloudstack by apache.

the class VmwareStorageMotionStrategyTest method testMigrateWithinClusterSuccess.

@Test
public void testMigrateWithinClusterSuccess() throws Exception {
    Host srcHost = mock(Host.class);
    Host destHost = mock(Host.class);
    when(srcHost.getClusterId()).thenReturn(1L);
    when(destHost.getClusterId()).thenReturn(1L);
    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 within cluster isn't successful.", result.isSuccess());
}
Also used : MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) MigrateWithStorageCommand(com.cloud.agent.api.MigrateWithStorageCommand) HashMap(java.util.HashMap) VMInstanceVO(com.cloud.vm.VMInstanceVO) Host(com.cloud.host.Host) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) CommandResult(org.apache.cloudstack.storage.command.CommandResult) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) Test(org.junit.Test)

Example 47 with CopyCommandResult

use of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult 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());
}
Also used : MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) MigrateWithStorageCommand(com.cloud.agent.api.MigrateWithStorageCommand) HashMap(java.util.HashMap) VMInstanceVO(com.cloud.vm.VMInstanceVO) Host(com.cloud.host.Host) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) CommandResult(org.apache.cloudstack.storage.command.CommandResult) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) Test(org.junit.Test)

Example 48 with CopyCommandResult

use of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult 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());
}
Also used : MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) MigrateWithStorageCommand(com.cloud.agent.api.MigrateWithStorageCommand) HashMap(java.util.HashMap) VMInstanceVO(com.cloud.vm.VMInstanceVO) Host(com.cloud.host.Host) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) CommandResult(org.apache.cloudstack.storage.command.CommandResult) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult) Test(org.junit.Test)

Example 49 with CopyCommandResult

use of org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult in project cloudstack by apache.

the class SimulatorDataMotionStrategy method copyAsync.

@Override
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
    CopyCommandResult result = new CopyCommandResult("something", null);
    callback.complete(result);
}
Also used : CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)

Aggregations

CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)49 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)32 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)16 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)15 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)15 AsyncCallFuture (org.apache.cloudstack.framework.async.AsyncCallFuture)13 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)11 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)9 HashMap (java.util.HashMap)8 ExecutionException (java.util.concurrent.ExecutionException)8 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)8 MigrateWithStorageAnswer (com.cloud.agent.api.MigrateWithStorageAnswer)7 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)7 VMInstanceVO (com.cloud.vm.VMInstanceVO)7 CommandResult (org.apache.cloudstack.storage.command.CommandResult)7 Answer (com.cloud.agent.api.Answer)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)6 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)6 CreateCmdResult (org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult)5 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)5