Search in sources :

Example 11 with Subnet

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

the class OpenStackNetworkService method getSubnetsByName.

/**
 * @see com.att.cdp.zones.NetworkService#getSubnetsByName(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<Subnet> getSubnetsByName(String name) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SUBNET, name);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    List<Subnet> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        SubnetsResource resource = client.subnets();
        for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
            if (net.getName().equals(name)) {
                list.add(new OpenStackSubnet(context, net));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SubnetsResource(com.woorea.openstack.quantum.api.SubnetsResource) ArrayList(java.util.ArrayList) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) Subnet(com.att.cdp.zones.model.Subnet)

Example 12 with Subnet

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

the class OpenStackNetworkService method getSubnets.

/**
 * @see com.att.cdp.zones.NetworkService#getSubnets()
 */
@SuppressWarnings("nls")
@Override
public List<Subnet> getSubnets() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<Subnet> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        SubnetsResource resource = client.subnets();
        for (com.woorea.openstack.quantum.model.Subnet net : resource.list().execute()) {
            list.add(new OpenStackSubnet(context, net));
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Quantum(com.woorea.openstack.quantum.Quantum) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) SubnetsResource(com.woorea.openstack.quantum.api.SubnetsResource) ArrayList(java.util.ArrayList) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) OpenStackSubnet(com.att.cdp.openstack.model.OpenStackSubnet) Subnet(com.att.cdp.zones.model.Subnet)

Example 13 with Subnet

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

the class TestNetworkService method testSubnets.

/**
 * 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 testSubnets() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    List<Subnet> subnets = service.getSubnets();
    assertNotNull(subnets);
    assertFalse(subnets.isEmpty());
    for (Subnet subnet : subnets) {
        assertNotNull(service.getSubnetById(subnet.getId()));
        assertNotNull(service.getSubnetsByName(subnet.getName()));
    }
}
Also used : Context(com.att.cdp.zones.Context) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with Subnet

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

the class TestNetworkService method createIPV4SubnetWithGateway.

/**
 * 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 createIPV4SubnetWithGateway() 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_Gateway");
        subnetWithGateway.setNetwork(testNetwork.getId());
        subnetWithGateway.setIpv4(true);
        subnetWithGateway.setRouting("10.10.10.0/24");
        subnetWithGateway.setGatewayIp("10.10.10.1");
        service.createSubnet(subnetWithGateway);
        List<Subnet> subnets = service.getSubnetsByName("CDP_Test_IPV4_Subnet_With_Gateway");
        assertFalse(subnets.isEmpty());
        for (Subnet subnet : subnets) {
            assertTrue(subnet.getRouting().equalsIgnoreCase("10.10.10.0/24"));
            assertTrue(subnet.getGatewayIp().equalsIgnoreCase("10.10.10.1"));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to create the ipv4 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 15 with Subnet

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

the class TestNetworkService method testCreateAndDeletePort.

@Test
@Ignore
public void testCreateAndDeletePort() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    String poolName = "TestNewPool";
    String tenantId = context.getTenant().getId();
    String networkId = "64e612b4-0a2a-4073-b408-66a3ef27aef7";
    String subnetId = "b124ab37-a285-4b8f-848b-e485c062594c";
    Subnet subnet = service.getSubnetById(subnetId);
    assertNotNull(subnet);
    Port port = service.createPort(subnet);
    assertNotNull(port);
    port.delete();
}
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)

Aggregations

Context (com.att.cdp.zones.Context)15 Subnet (com.att.cdp.zones.model.Subnet)15 NetworkService (com.att.cdp.zones.NetworkService)12 Ignore (org.junit.Ignore)10 Test (org.junit.Test)10 ZoneException (com.att.cdp.exceptions.ZoneException)8 Network (com.att.cdp.zones.model.Network)8 ArrayList (java.util.ArrayList)7 OpenStackContext (com.att.cdp.openstack.OpenStackContext)5 Port (com.att.cdp.zones.model.Port)5 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)5 OpenStackSubnet (com.att.cdp.openstack.model.OpenStackSubnet)3 Server (com.att.cdp.zones.model.Server)3 Quantum (com.woorea.openstack.quantum.Quantum)3 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 Route (com.att.cdp.zones.model.Route)2