Search in sources :

Example 76 with VirtualMachineTO

use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.

the class NotAValidCommand method testStartCommand.

@Test
public void testStartCommand() {
    final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class);
    final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
    final StartCommand startCommand = new StartCommand(vm, host, false);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(startCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) StartCommand(com.cloud.agent.api.StartCommand) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) Test(org.junit.Test)

Example 77 with VirtualMachineTO

use of com.cloud.agent.api.to.VirtualMachineTO in project cloudstack by apache.

the class VmwareStorageMotionStrategyTest method testMigrateWithinClusterFailure.

@Test
public void testMigrateWithinClusterFailure() 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(false);
    when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
    strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
    assertFalse("Migration within 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 78 with VirtualMachineTO

use of com.cloud.agent.api.to.VirtualMachineTO 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 79 with VirtualMachineTO

use of com.cloud.agent.api.to.VirtualMachineTO 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 80 with VirtualMachineTO

use of com.cloud.agent.api.to.VirtualMachineTO 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)

Aggregations

VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)84 NicTO (com.cloud.agent.api.to.NicTO)42 Test (org.junit.Test)33 Answer (com.cloud.agent.api.Answer)32 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)25 HashMap (java.util.HashMap)18 LibvirtException (org.libvirt.LibvirtException)18 StartAnswer (com.cloud.agent.api.StartAnswer)17 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)17 URISyntaxException (java.net.URISyntaxException)16 Connect (org.libvirt.Connect)16 InternalErrorException (com.cloud.exception.InternalErrorException)15 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)14 KVMStoragePoolManager (com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager)14 Connection (com.xensource.xenapi.Connection)14 ConfigurationException (javax.naming.ConfigurationException)14 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)13 LibvirtUtilitiesHelper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper)13 StartCommand (com.cloud.agent.api.StartCommand)12 ArrayList (java.util.ArrayList)11