Search in sources :

Example 6 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method testCreateAndDeletePort.

/**
 * Tests that we can create and delete a port
 *
 * @throws ZoneException
 *             If the test cannot connect to the provider
 */
@Test
@Ignore
public void testCreateAndDeletePort() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    List<Subnet> subnets = service.getSubnets();
    assertNotNull(subnets);
    assertFalse(subnets.isEmpty());
    Subnet subnet = subnets.get(0);
    Port port = service.createPort(subnet);
    assertNotNull(port);
    assertEquals(port.getSubnetId(), subnet.getId());
    assertNotNull(port.getMacAddr());
    assertNotNull(port.getId());
    assertNotNull(port.getNetwork());
    service.deletePort(port);
}
Also used : Context(com.att.cdp.zones.Context) Port(com.att.cdp.zones.model.Port) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method createSubnetWithDHCPDisabled.

/**
 * Verifies that we can create a subnet with DHCP disabled on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createSubnetWithDHCPDisabled() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        // verify test network exists
        verifyTestNetworkHelper();
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        Network testNetwork = networks.get(0);
        Subnet subnetWithGateway = new Subnet();
        subnetWithGateway.setName("CDP_Test_IPV4_Subnet_With_DHCP_Disabled");
        subnetWithGateway.setNetwork(testNetwork.getId());
        subnetWithGateway.setIpv4(true);
        subnetWithGateway.setRouting("10.10.30.0/24");
        subnetWithGateway.setGatewayIp("10.10.30.1");
        subnetWithGateway.setDhcp(false);
        service.createSubnet(subnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_DHCP_Disabled");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.30.0/24"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.30.1"));
            assertFalse(subnet.isDhcp());
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv4 test subnet with DHCP disabled");
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method verifyTestNetworkHelper.

/**
 * Helper function to create the base test network if it does not already exist. The base test network is needed for
 * all subnet tests This relies on createNetwork functioning properly
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
protected void verifyTestNetworkHelper() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        if (networks.isEmpty()) {
            Network testNetwork = new Network("CDP_Test_Network");
            service.createNetwork(testNetwork);
            networks = service.getNetworksByName("CDP_Test_Network");
        }
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the test network");
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService)

Example 9 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method testFloatingIpPools.

/**
 * Verifies that we can get floating IP Pools
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void testFloatingIpPools() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    List<String> floatingIpPools = service.getFloatingIpPools();
    assertNotNull(floatingIpPools);
    assertFalse(floatingIpPools.isEmpty());
}
Also used : Context(com.att.cdp.zones.Context) NetworkService(com.att.cdp.zones.NetworkService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method createSubnetWithHostRoutes.

/**
 * Verifies that we can create a subnet with a specified set of host routes on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createSubnetWithHostRoutes() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        // verify test network exists
        verifyTestNetworkHelper();
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        Network testNetwork = networks.get(0);
        Subnet subnetWithGateway = new Subnet();
        subnetWithGateway.setName("CDP_Test_IPV4_Subnet_With_Host_Routes");
        subnetWithGateway.setNetwork(testNetwork.getId());
        subnetWithGateway.setIpv4(true);
        subnetWithGateway.setRouting("10.10.40.0/24");
        subnetWithGateway.setGatewayIp("10.10.40.1");
        List<Route> hostRoutes = new ArrayList<Route>();
        Route newRoute1 = new Route();
        Route newRoute2 = new Route();
        newRoute1.setDestination("10.10.10.0/24");
        newRoute1.setNexthop("10.10.20.1");
        newRoute2.setDestination("10.10.30.0/24");
        newRoute2.setNexthop("10.10.40.1");
        hostRoutes.add(newRoute1);
        hostRoutes.add(newRoute2);
        subnetWithGateway.setHostRoutes(hostRoutes);
        service.createSubnet(subnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_Host_Routes");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.40.0/24"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.40.1"));
            assertFalse(subnet.getHostRoutes().isEmpty());
            assertTrue(subnet.getHostRoutes().contains(newRoute1));
            assertTrue(subnet.getHostRoutes().contains(newRoute2));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv4 test subnet with host routes");
    }
}
Also used : Context(com.att.cdp.zones.Context) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) ArrayList(java.util.ArrayList) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Route(com.att.cdp.zones.model.Route) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

NetworkService (com.att.cdp.zones.NetworkService)27 Context (com.att.cdp.zones.Context)24 Ignore (org.junit.Ignore)22 Test (org.junit.Test)21 ZoneException (com.att.cdp.exceptions.ZoneException)15 Network (com.att.cdp.zones.model.Network)13 Subnet (com.att.cdp.zones.model.Subnet)12 Port (com.att.cdp.zones.model.Port)8 ArrayList (java.util.ArrayList)5 Server (com.att.cdp.zones.model.Server)4 ComputeService (com.att.cdp.zones.ComputeService)3 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)3 HashMap (java.util.HashMap)3 List (java.util.List)3 OpenStackContext (com.att.cdp.openstack.OpenStackContext)2 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)2 OpenStackFault (com.att.cdp.openstack.model.OpenStackFault)2 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)2 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)2 ACL (com.att.cdp.zones.model.ACL)2