Search in sources :

Example 96 with Answer

use of com.cloud.legacymodel.communication.answer.Answer in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testCheckOnHostCommand.

@Test
public void testCheckOnHostCommand() {
    final com.cloud.legacymodel.dc.Host host = Mockito.mock(com.cloud.legacymodel.dc.Host.class);
    final CheckOnHostCommand onHostCommand = new CheckOnHostCommand(host);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(onHostCommand, this.citrixResourceBase);
    assertFalse(answer.getResult());
}
Also used : CheckOnHostCommand(com.cloud.legacymodel.communication.command.CheckOnHostCommand) 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) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 97 with Answer

use of com.cloud.legacymodel.communication.answer.Answer in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testPvlanSetupCommandDhcpFailure.

@Test
public void testPvlanSetupCommandDhcpFailure() {
    final String label = "net";
    final Connection conn = Mockito.mock(Connection.class);
    final XsLocalNetwork network = Mockito.mock(XsLocalNetwork.class);
    final Network network2 = Mockito.mock(Network.class);
    final PvlanSetupCommand lanSetup = PvlanSetupCommand.createDhcpSetup("add", URI.create("http://127.0.0.1"), "tag", "dhcp", "0:0:0:0:0:0", "127.0.0.1");
    final String primaryPvlan = lanSetup.getPrimary();
    final String isolatedPvlan = lanSetup.getIsolated();
    final String op = lanSetup.getOp();
    final String dhcpName = lanSetup.getDhcpName();
    final String dhcpMac = lanSetup.getDhcpMac();
    final String dhcpIp = lanSetup.getDhcpIp();
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(this.citrixResourceBase.getConnection()).thenReturn(conn);
    try {
        when(this.citrixResourceBase.getNativeNetworkForTraffic(conn, TrafficType.Guest, "tag")).thenReturn(network);
        when(network.getNetwork()).thenReturn(network2);
        when(network2.getNameLabel(conn)).thenReturn(label);
    } catch (final XenAPIException e) {
        fail(e.getMessage());
    } catch (final XmlRpcException e) {
        fail(e.getMessage());
    }
    when(this.citrixResourceBase.callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-dhcp", "op", op, "nw-label", label, "primary-pvlan", primaryPvlan, "isolated-pvlan", isolatedPvlan, "dhcp-name", dhcpName, "dhcp-ip", dhcpIp, "dhcp-mac", dhcpMac)).thenReturn("false");
    final Answer answer = wrapper.execute(lanSetup, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).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) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) Network(com.xensource.xenapi.Network) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) PvlanSetupCommand(com.cloud.legacymodel.communication.command.PvlanSetupCommand) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 98 with Answer

use of com.cloud.legacymodel.communication.answer.Answer in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testPrimaryStorageDownloadCommand.

@Test
public void testPrimaryStorageDownloadCommand() {
    final XsHost xsHost = Mockito.mock(XsHost.class);
    final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
    final PrimaryStorageDownloadCommand storageDownloadCommand = new PrimaryStorageDownloadCommand("Test", "http://127.0.0.1", ImageFormat.VHD, 1l, poolVO, 200);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(this.citrixResourceBase.getHost()).thenReturn(xsHost);
    final Answer answer = wrapper.execute(storageDownloadCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).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) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) PrimaryStorageDownloadCommand(com.cloud.legacymodel.communication.command.PrimaryStorageDownloadCommand) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 99 with Answer

use of com.cloud.legacymodel.communication.answer.Answer in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testMigrateCommand.

@Test
public void testMigrateCommand() {
    final VirtualMachineTO machineTO = Mockito.mock(VirtualMachineTO.class);
    final MigrateCommand migrateCommand = new MigrateCommand("Test", "127.0.0.1", false, machineTO, false);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(migrateCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).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) VirtualMachineTO(com.cloud.legacymodel.to.VirtualMachineTO) MigrateCommand(com.cloud.legacymodel.communication.command.MigrateCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 100 with Answer

use of com.cloud.legacymodel.communication.answer.Answer in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testPingTestCommandRouterPvtIps.

@Test
public void testPingTestCommandRouterPvtIps() {
    final PingTestCommand pingTestCommand = new PingTestCommand("127.0.0.1", "127.0.0.1");
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(pingTestCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).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) PingTestCommand(com.cloud.legacymodel.communication.command.PingTestCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)342 Test (org.junit.Test)201 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)173 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)116 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)110 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)63 LibvirtUtilitiesHelper (com.cloud.agent.resource.kvm.wrapper.LibvirtUtilitiesHelper)61 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)58 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)54 LibvirtException (org.libvirt.LibvirtException)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)53 KvmStoragePoolManager (com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)48 Connection (com.xensource.xenapi.Connection)48 ArrayList (java.util.ArrayList)45 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)39 StoragePool (com.cloud.legacymodel.storage.StoragePool)38 Connect (org.libvirt.Connect)38 NfsStoragePool (com.cloud.agent.resource.kvm.ha.KvmHaBase.NfsStoragePool)29 CopyCmdAnswer (com.cloud.legacymodel.communication.answer.CopyCmdAnswer)29 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)27