Search in sources :

Example 11 with DestroyCommand

use of com.cloud.agent.api.storage.DestroyCommand in project cloudstack by apache.

the class HypervDirectConnectResourceTest method testDestroyCommand.

@Test
public final void testDestroyCommand() {
    // TODO: how does the command vary when we are only deleting a vm versus
    // deleting a volume?
    // String sample2 = "{\"volume\":" + getSampleVolumeObjectTO() + "}";
    String sample2 = "{\"volume\":{\"name\":\"" + s_testSampleVolumeWorkingUUIDNoExt + "\",\"storagePoolType\":\"Filesystem\"," + "\"mountPoint\":" + s_testLocalStorePathJSON + ",\"path\":" + s_testSampleVolumeTempURIJSON + ",\"storagePoolUuid\":\"" + s_testLocalStoreUUID + "\"," + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
    DestroyCommand cmd = s_gson.fromJson(sample2, DestroyCommand.class);
    Answer ans = s_hypervresource.executeRequest(cmd);
    Assert.assertTrue(ans.getDetails(), ans.getResult());
}
Also used : StopAnswer(com.cloud.agent.api.StopAnswer) Answer(com.cloud.agent.api.Answer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) DestroyCommand(com.cloud.agent.api.storage.DestroyCommand) Test(org.junit.Test)

Example 12 with DestroyCommand

use of com.cloud.agent.api.storage.DestroyCommand 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 : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) 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) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.agent.api.Answer)12 DestroyCommand (com.cloud.agent.api.storage.DestroyCommand)12 Test (org.junit.Test)7 StoragePool (com.cloud.storage.StoragePool)5 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)4 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)3 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)3 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)3 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)3 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)3 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)3 CreateVolumeFromSnapshotCommand (com.cloud.agent.api.CreateVolumeFromSnapshotCommand)3 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)3 GetHostStatsCommand (com.cloud.agent.api.GetHostStatsCommand)3 GetStorageStatsCommand (com.cloud.agent.api.GetStorageStatsCommand)3 GetVmStatsCommand (com.cloud.agent.api.GetVmStatsCommand)3 GetVncPortCommand (com.cloud.agent.api.GetVncPortCommand)3 MaintainCommand (com.cloud.agent.api.MaintainCommand)3 ManageSnapshotCommand (com.cloud.agent.api.ManageSnapshotCommand)3 MigrateCommand (com.cloud.agent.api.MigrateCommand)3