Search in sources :

Example 1 with StorageSubsystemCommandHandler

use of com.cloud.storage.resource.StorageSubsystemCommandHandler in project cloudstack by apache.

the class LibvirtComputingResourceTest method testStorageSubSystemCommand.

@Test
public void testStorageSubSystemCommand() {
    final DiskTO disk = Mockito.mock(DiskTO.class);
    final String vmName = "Test";
    final AttachCommand command = new AttachCommand(disk, vmName);
    final StorageSubsystemCommandHandler handler = Mockito.mock(StorageSubsystemCommandHandler.class);
    when(libvirtComputingResource.getStorageHandler()).thenReturn(handler);
    when(handler.handleStorageCommands(command)).thenReturn(new AttachAnswer(disk));
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) StorageSubsystemCommandHandler(com.cloud.storage.resource.StorageSubsystemCommandHandler) AttachCommand(org.apache.cloudstack.storage.command.AttachCommand) DiskTO(com.cloud.agent.api.to.DiskTO) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Test(org.junit.Test)

Example 2 with StorageSubsystemCommandHandler

use of com.cloud.storage.resource.StorageSubsystemCommandHandler in project cloudstack by apache.

the class NotAValidCommand method testStorageSubSystemCommand.

@Test
public void testStorageSubSystemCommand() {
    final DiskTO disk = Mockito.mock(DiskTO.class);
    final String vmName = "Test";
    final AttachCommand command = new AttachCommand(disk, vmName);
    final StorageSubsystemCommandHandler handler = Mockito.mock(StorageSubsystemCommandHandler.class);
    when(citrixResourceBase.getStorageHandler()).thenReturn(handler);
    when(handler.handleStorageCommands(command)).thenReturn(new AttachAnswer(disk));
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, citrixResourceBase);
    assertTrue(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) StorageSubsystemCommandHandler(com.cloud.storage.resource.StorageSubsystemCommandHandler) AttachCommand(org.apache.cloudstack.storage.command.AttachCommand) DiskTO(com.cloud.agent.api.to.DiskTO) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Test(org.junit.Test)

Aggregations

Answer (com.cloud.agent.api.Answer)2 DiskTO (com.cloud.agent.api.to.DiskTO)2 StorageSubsystemCommandHandler (com.cloud.storage.resource.StorageSubsystemCommandHandler)2 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)2 AttachCommand (org.apache.cloudstack.storage.command.AttachCommand)2 Test (org.junit.Test)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 RebootAnswer (com.cloud.agent.api.RebootAnswer)1 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)1 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)1