Search in sources :

Example 11 with PvlanSetupCommand

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

the class NotAValidCommand method testPvlanSetupCommandVmSuccess.

@Test
public void testPvlanSetupCommandVmSuccess() {
    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.createVmSetup("add", URI.create("http://127.0.0.1"), "tag", "0:0:0:0:0:0");
    final String primaryPvlan = lanSetup.getPrimary();
    final String isolatedPvlan = lanSetup.getIsolated();
    final String op = lanSetup.getOp();
    final String vmMac = lanSetup.getVmMac();
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(citrixResourceBase.getConnection()).thenReturn(conn);
    try {
        when(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(citrixResourceBase.callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-vm", "op", op, "nw-label", label, "primary-pvlan", primaryPvlan, "isolated-pvlan", isolatedPvlan, "vm-mac", vmMac)).thenReturn("true");
    final Answer answer = wrapper.execute(lanSetup, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    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) 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.agent.api.PvlanSetupCommand) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Example 12 with PvlanSetupCommand

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

the class LibvirtComputingResourceTest method testPvlanSetupCommandVm.

@Test
public void testPvlanSetupCommandVm() {
    final String op = "add";
    final URI uri = URI.create("http://localhost");
    final String networkTag = "/105";
    final String vmMac = "00:00:00:00";
    final PvlanSetupCommand command = PvlanSetupCommand.createVmSetup(op, uri, networkTag, vmMac);
    final String guestBridgeName = "br0";
    when(libvirtComputingResource.getGuestBridgeName()).thenReturn(guestBridgeName);
    when(libvirtComputingResource.getTimeout()).thenReturn(Duration.ZERO);
    final String ovsPvlanVmPath = "/pvlan";
    when(libvirtComputingResource.getOvsPvlanVmPath()).thenReturn(ovsPvlanVmPath);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(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) PvlanSetupCommand(com.cloud.agent.api.PvlanSetupCommand) URI(java.net.URI) Test(org.junit.Test)

Aggregations

PvlanSetupCommand (com.cloud.agent.api.PvlanSetupCommand)12 Answer (com.cloud.agent.api.Answer)11 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)8 Test (org.junit.Test)8 RebootAnswer (com.cloud.agent.api.RebootAnswer)5 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)4 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)4 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)2 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)2 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)2 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)2 CheckVirtualMachineCommand (com.cloud.agent.api.CheckVirtualMachineCommand)2 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)2 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)2 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)2 CreateVMSnapshotCommand (com.cloud.agent.api.CreateVMSnapshotCommand)2 CreateVolumeFromSnapshotCommand (com.cloud.agent.api.CreateVolumeFromSnapshotCommand)2 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)2 DeleteVMSnapshotCommand (com.cloud.agent.api.DeleteVMSnapshotCommand)2 GetHostStatsCommand (com.cloud.agent.api.GetHostStatsCommand)2