Search in sources :

Example 31 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testNetworkUsageCommandVpcCreate.

@Test
public void testNetworkUsageCommandVpcCreate() {
    final String privateIP = "127.0.0.1";
    final String domRName = "domR";
    final boolean forVpc = true;
    final String gatewayIP = "127.0.0.1";
    final String vpcCidr = "10.1.1.0/24";
    final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIP, vpcCidr);
    libvirtComputingResource.getNetworkStats(command.getPrivateIP());
    when(libvirtComputingResource.configureVpcNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR())).thenReturn("SUCCESS");
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(libvirtComputingResource, times(1)).configureVpcNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR());
}
Also used : Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test)

Example 32 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testNetworkUsageCommandVpcVpn.

@Test
public void testNetworkUsageCommandVpcVpn() {
    final String privateIP = "127.0.0.1";
    final String domRName = "domR";
    final boolean forVpc = true;
    final String gatewayIP = "127.0.0.1";
    final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, "vpn", forVpc, gatewayIP);
    libvirtComputingResource.getNetworkStats(command.getPrivateIP());
    when(libvirtComputingResource.getVpcNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption())).thenReturn(new long[] { 10l, 10l });
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(libvirtComputingResource, times(1)).getVpcNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption());
}
Also used : Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test)

Example 33 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cosmic by MissionCriticalCloud.

the class XcpServerWrapperTest method testNetworkUsageCommandExceptiopn.

@Test
public void testNetworkUsageCommandExceptiopn() {
    final Connection conn = Mockito.mock(Connection.class);
    final String privateIP = "192.168.0.10";
    final String domRName = "dom";
    final String option = null;
    final boolean forVpc = true;
    final NetworkUsageCommand usageCommand = new NetworkUsageCommand(privateIP, domRName, option, forVpc);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(XcpServerResource.getConnection()).thenReturn(conn);
    when(XcpServerResource.networkUsage(conn, usageCommand.getPrivateIP(), "create", null)).thenThrow(new CloudRuntimeException("FAILED"));
    final Answer answer = wrapper.execute(usageCommand, XcpServerResource);
    verify(XcpServerResource, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Connection(com.xensource.xenapi.Connection) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test)

Example 34 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cosmic by MissionCriticalCloud.

the class XcpServerWrapperTest method testNetworkUsageCommandGet.

@Test
public void testNetworkUsageCommandGet() {
    final Connection conn = Mockito.mock(Connection.class);
    final String privateIP = "192.168.0.10";
    final String domRName = "dom";
    final boolean forVpc = true;
    final String gatewayIp = "172.16.0.10";
    final NetworkUsageCommand usageCommand = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIp);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(XcpServerResource.getConnection()).thenReturn(conn);
    when(XcpServerResource.getNetworkStats(conn, usageCommand.getPrivateIP())).thenReturn(new long[] { 1l, 1l });
    final Answer answer = wrapper.execute(usageCommand, XcpServerResource);
    verify(XcpServerResource, times(1)).getConnection();
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) Connection(com.xensource.xenapi.Connection) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test)

Example 35 with NetworkUsageCommand

use of com.cloud.agent.api.NetworkUsageCommand in project cosmic by MissionCriticalCloud.

the class XcpServerWrapperTest method testNetworkUsageCommandCreate.

@Test
public void testNetworkUsageCommandCreate() {
    final Connection conn = Mockito.mock(Connection.class);
    final String privateIP = "192.168.0.10";
    final String domRName = "dom";
    final String option = "create";
    final boolean forVpc = true;
    final NetworkUsageCommand usageCommand = new NetworkUsageCommand(privateIP, domRName, option, forVpc);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(XcpServerResource.getConnection()).thenReturn(conn);
    when(XcpServerResource.networkUsage(conn, usageCommand.getPrivateIP(), "create", null)).thenReturn("success");
    final Answer answer = wrapper.execute(usageCommand, XcpServerResource);
    verify(XcpServerResource, times(1)).getConnection();
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) Connection(com.xensource.xenapi.Connection) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) Test(org.junit.Test)

Aggregations

NetworkUsageCommand (com.cloud.agent.api.NetworkUsageCommand)41 Answer (com.cloud.agent.api.Answer)33 Test (org.junit.Test)28 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)13 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)12 Connection (com.xensource.xenapi.Connection)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ConfigurationException (javax.naming.ConfigurationException)7 PlugNicCommand (com.cloud.agent.api.PlugNicCommand)5 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)5 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)4 PingTestCommand (com.cloud.agent.api.PingTestCommand)4 StartCommand (com.cloud.agent.api.StartCommand)4 CheckSshCommand (com.cloud.agent.api.check.CheckSshCommand)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)4 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 Network (com.cloud.network.Network)4 AttachAnswer (com.cloud.storage.command.AttachAnswer)4 UserStatisticsVO (com.cloud.user.UserStatisticsVO)4 HashMap (java.util.HashMap)4