Search in sources :

Example 31 with VolumeTO

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

the class LibvirtComputingResourceTest method testDestroyCommand.

@Test
public void testDestroyCommand() {
    final StoragePool pool = Mockito.mock(StoragePool.class);
    final Volume volume = Mockito.mock(Volume.class);
    final String vmName = "Test";
    final DestroyCommand command = new DestroyCommand(pool, volume, vmName);
    final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class);
    final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class);
    final VolumeTO vol = command.getVolume();
    when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
    when(poolManager.getStoragePool(vol.getPoolType(), vol.getPoolUuid())).thenReturn(primary);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) KVMStoragePoolManager(com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager) VolumeTO(com.cloud.agent.api.to.VolumeTO) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) StoragePool(com.cloud.storage.StoragePool) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) Volume(com.cloud.storage.Volume) DestroyCommand(com.cloud.agent.api.storage.DestroyCommand) Test(org.junit.Test)

Aggregations

VolumeTO (com.cloud.agent.api.to.VolumeTO)31 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)15 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)15 Answer (com.cloud.agent.api.Answer)14 Pair (com.cloud.utils.Pair)13 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 NicTO (com.cloud.agent.api.to.NicTO)10 VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)10 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)9 Connection (com.xensource.xenapi.Connection)8 MigrateWithStorageAnswer (com.cloud.agent.api.MigrateWithStorageAnswer)7 DiskProfile (com.cloud.vm.DiskProfile)7 SR (com.xensource.xenapi.SR)6 VDI (com.xensource.xenapi.VDI)6 Test (org.junit.Test)6 MigrateWithStorageCommand (com.cloud.agent.api.MigrateWithStorageCommand)5 Network (com.xensource.xenapi.Network)5 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)4 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)4