Search in sources :

Example 6 with Network

use of com.att.cdp.zones.model.Network 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)

Example 7 with Network

use of com.att.cdp.zones.model.Network in project AJSC by att.

the class TestNetworkService method createSubnetWithoutGateway.

/**
 * Verifies that we can create a subnet with no gateway IP address on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createSubnetWithoutGateway() 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);
        // create the subnet
        Subnet subnetWithoutGateway = new Subnet();
        subnetWithoutGateway.setName("CDP_Test_IPV4_Subnet_Without_Gateway");
        subnetWithoutGateway.setNetwork(testNetwork.getId());
        subnetWithoutGateway.setIpv4(true);
        subnetWithoutGateway.setRouting("10.10.20.0/24");
        subnetWithoutGateway.setGatewayIp(null);
        service.createSubnet(subnetWithoutGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_Without_Gateway");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.20.0/24"));
            assertTrue(subnet.getGatewayIp() == null);
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the test subnet without gateway IP");
    }
}
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 Network

use of com.att.cdp.zones.model.Network in project AJSC by att.

the class TestNetworkService method createSubnetWithDNSNameServers.

/**
 * Verifies that we can create a subnet with a specified set of DNS name servers on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createSubnetWithDNSNameServers() 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_DNS_Name_Servers");
        subnetWithGateway.setNetwork(testNetwork.getId());
        subnetWithGateway.setIpv4(true);
        subnetWithGateway.setRouting("10.10.50.0/24");
        subnetWithGateway.setGatewayIp("10.10.50.1");
        ArrayList<String> dnsNames = new ArrayList<String>();
        dnsNames.add("0.0.0.5");
        dnsNames.add("0.0.0.7");
        subnetWithGateway.setDns(dnsNames);
        service.createSubnet(subnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_DNS_Name_Servers");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.50.0/24"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.50.1"));
            assertTrue(subnet.getDns().contains("0.0.0.5"));
            assertTrue(subnet.getDns().contains("0.0.0.7"));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv4 test subnet with DNS name servers");
    }
}
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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Network

use of com.att.cdp.zones.model.Network in project AJSC by att.

the class TestNetworkService method createIPV6SubnetWithGateway.

/**
 * Verifies that we can create a subnet with a specified gateway IP address on a provider
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void createIPV6SubnetWithGateway() 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 ipv6SubnetWithGateway = new Subnet();
        ipv6SubnetWithGateway.setName("CDP_Test_IPV6_Subnet_With_Gateway");
        ipv6SubnetWithGateway.setNetwork(testNetwork.getId());
        ipv6SubnetWithGateway.setIpv4(false);
        ipv6SubnetWithGateway.setRouting("2001:db8:1234::/48");
        ipv6SubnetWithGateway.setGatewayIp("2001:db8:1234::1");
        service.createSubnet(ipv6SubnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV6_Subnet_With_Gateway");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("2001:db8:1234::/48"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("2001:db8:1234::1"));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv6 test subnet with gateway IP");
    }
}
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 10 with Network

use of com.att.cdp.zones.model.Network in project AJSC by att.

the class OpenStackComputeService method getExtendedNetworks.

/**
 * This method returns a list of OS extended network attributes for the supplied tenant.
 * <p>
 * This lists networks that are available to the tenant. The information in the network list includes extended
 * network attributes.
 * </p>
 *
 * @return A list of networks and their extended attributes
 * @throws ZoneException
 *             If the networks and extended attributes cannot be listed
 * @see com.att.cdp.zones.ComputeService#getExtendedNetworks()
 */
@Override
public List<Network> getExtendedNetworks() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    List<Network> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Networks extendedNetworks = nova.getClient().networks().listExtended().execute();
        for (com.woorea.openstack.nova.model.Network en : extendedNetworks.getList()) {
            Network network = new OpenStackNetwork(context, en);
            list.add(network);
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Network(com.att.cdp.zones.model.Network) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) ArrayList(java.util.ArrayList) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork)

Aggregations

Network (com.att.cdp.zones.model.Network)20 Context (com.att.cdp.zones.Context)19 ZoneException (com.att.cdp.exceptions.ZoneException)13 NetworkService (com.att.cdp.zones.NetworkService)13 Ignore (org.junit.Ignore)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 OpenStackContext (com.att.cdp.openstack.OpenStackContext)8 Subnet (com.att.cdp.zones.model.Subnet)8 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)7 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)6 Server (com.att.cdp.zones.model.Server)4 AbstractNetwork (com.att.cdp.zones.spi.AbstractNetwork)4 Quantum (com.woorea.openstack.quantum.Quantum)4 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)3 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)3 HashMap (java.util.HashMap)3 List (java.util.List)3 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)2 OpenStackFault (com.att.cdp.openstack.model.OpenStackFault)2