Search in sources :

Example 1 with RebootRouterCommand

use of com.cloud.legacymodel.communication.command.RebootRouterCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testExecuteRebootRouterCommand.

@Test
public void testExecuteRebootRouterCommand() {
    final RebootRouterCommand rebootRouterCommand = new RebootRouterCommand("Test", "127.0.0.1");
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(rebootRouterCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(2)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) RebootRouterCommand(com.cloud.legacymodel.communication.command.RebootRouterCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with RebootRouterCommand

use of com.cloud.legacymodel.communication.command.RebootRouterCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testRebootRouterCommand.

@Test
public void testRebootRouterCommand() {
    final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class);
    final Connect conn = Mockito.mock(Connect.class);
    final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
    final String vmName = "Test";
    final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1");
    when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource);
    when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
    try {
        when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    }
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
    verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
    try {
        verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    }
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect) RebootRouterCommand(com.cloud.legacymodel.communication.command.RebootRouterCommand) VirtualRoutingResource(com.cloud.common.virtualnetwork.VirtualRoutingResource) LibvirtUtilitiesHelper(com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper) Test(org.junit.Test)

Example 3 with RebootRouterCommand

use of com.cloud.legacymodel.communication.command.RebootRouterCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testRebootRouterCommandConnect.

@Test
public void testRebootRouterCommandConnect() {
    final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class);
    final Connect conn = Mockito.mock(Connect.class);
    final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
    final String vmName = "Test";
    final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1");
    when(this.libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource);
    when(this.libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
    when(routingResource.connect(command.getPrivateIpAddress())).thenReturn(true);
    try {
        when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    }
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getVirtRouterResource();
    verify(this.libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
    try {
        verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    }
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect) RebootRouterCommand(com.cloud.legacymodel.communication.command.RebootRouterCommand) VirtualRoutingResource(com.cloud.common.virtualnetwork.VirtualRoutingResource) LibvirtUtilitiesHelper(com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper) Test(org.junit.Test)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)3 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)3 RebootRouterCommand (com.cloud.legacymodel.communication.command.RebootRouterCommand)3 Test (org.junit.Test)3 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)2 LibvirtUtilitiesHelper (com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper)2 VirtualRoutingResource (com.cloud.common.virtualnetwork.VirtualRoutingResource)2 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)2 Connect (org.libvirt.Connect)2 LibvirtException (org.libvirt.LibvirtException)2 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1