Search in sources :

Example 16 with VolumeTO

use of com.cloud.legacymodel.to.VolumeTO in project cosmic by MissionCriticalCloud.

the class XenServer610WrapperTest method testMigrateWithStorageSendCommandSRException.

@Test
public void testMigrateWithStorageSendCommandSRException() {
    final String vmName = "small";
    final Connection conn = Mockito.mock(Connection.class);
    final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
    final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
    final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
    final List<Pair<VolumeTO, Object>> volumeToSr = new ArrayList<>();
    volumeToSr.add(new Pair<>(volume1, new String("a")));
    volumeToSr.add(new Pair<>(volume2, new String("b")));
    final List<Pair<NicTO, Object>> nicToNetwork = new ArrayList<>();
    final Map<String, String> token = new HashMap<>();
    final MigrateWithStorageSendCommand migrateStorageCommand = new MigrateWithStorageSendCommand(vmSpec, volumeToSr, nicToNetwork, token);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(xenServer610Resource.getConnection()).thenReturn(conn);
    when(vmSpec.getName()).thenReturn(vmName);
    final Answer answer = wrapper.execute(migrateStorageCommand, xenServer610Resource);
    verify(xenServer610Resource, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : HashMap(java.util.HashMap) Connection(com.xensource.xenapi.Connection) ArrayList(java.util.ArrayList) VirtualMachineTO(com.cloud.legacymodel.to.VirtualMachineTO) Answer(com.cloud.legacymodel.communication.answer.Answer) VolumeTO(com.cloud.legacymodel.to.VolumeTO) MigrateWithStorageSendCommand(com.cloud.legacymodel.communication.command.MigrateWithStorageSendCommand) Pair(com.cloud.legacymodel.utils.Pair) Test(org.junit.Test)

Aggregations

VolumeTO (com.cloud.legacymodel.to.VolumeTO)16 Answer (com.cloud.legacymodel.communication.answer.Answer)10 Connection (com.xensource.xenapi.Connection)10 VirtualMachineTO (com.cloud.legacymodel.to.VirtualMachineTO)9 StorageFilerTO (com.cloud.legacymodel.to.StorageFilerTO)8 Pair (com.cloud.legacymodel.utils.Pair)8 SR (com.xensource.xenapi.SR)8 HashMap (java.util.HashMap)8 NicTO (com.cloud.legacymodel.to.NicTO)7 VDI (com.xensource.xenapi.VDI)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Network (com.xensource.xenapi.Network)6 XsLocalNetwork (com.cloud.hypervisor.xenserver.resource.XsLocalNetwork)5 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)5 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)4 KvmStoragePoolManager (com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)4 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)4 MigrateWithStorageSendCommand (com.cloud.legacymodel.communication.command.MigrateWithStorageSendCommand)3 StoragePool (com.cloud.legacymodel.storage.StoragePool)3