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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations