Search in sources :

Example 16 with Network

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

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

the class TestNetworkService method testDeleteNetwork.

/**
 * Test the ability to delete a network
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void testDeleteNetwork() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        // ensure test network exists
        verifyTestNetworkHelper();
        List<Network> networks = service.getNetworksByName("CDP_Test_Network");
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        // test network deletion
        for (Network network : networks) {
            if (network.getName().equalsIgnoreCase("CDP_Test_Network")) {
                service.deleteNetwork(network);
            }
        }
        networks = service.getNetworksByName("CDP_Test_Network");
        assertTrue(networks.isEmpty());
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail("Failed to delete 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with Network

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

the class TestNetworkService method listNetworks.

/**
 * Verifies that we can list the existing networks on a provider. This test requires that the provider actually has
 * networks installed.
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Ignore
@Test
public void listNetworks() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    try {
        List<Network> networks = service.getNetworks();
        assertNotNull(networks);
        assertFalse(networks.isEmpty());
        for (Network network : networks) {
            System.out.println(network.toString());
        // assertNotNull(service.getNetworksByName(network.getName()));
        // assertNotNull(service.getNetworkById(network.getId()));
        }
    } catch (ZoneException ze) {
        ze.printStackTrace();
        fail();
    }
}
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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with Network

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

the class OpenStackServer method loadNetworks.

/**
 * This method lazily loads the networks and ip addresses of the server
 *
 * @param context
 *            The context we are servicing
 */
@SuppressWarnings("nls")
private void loadNetworks(Context context) {
    if (networksProcessed.compareAndSet(false, true)) {
        try {
            NetworkService netService = context.getNetworkService();
            com.woorea.openstack.nova.model.Server.Addresses addresses = novaModel.getAddresses();
            if (addresses != null) {
                for (Map.Entry<String, List<com.woorea.openstack.nova.model.Server.Addresses.Address>> entry : addresses.getAddresses().entrySet()) {
                    String netName = entry.getKey();
                    try {
                        List<Network> nets = netService.getNetworksByName(netName);
                        if (!nets.isEmpty()) {
                            getNetworks().add(nets.get(0));
                        }
                        for (com.woorea.openstack.nova.model.Server.Addresses.Address osAddr : entry.getValue()) {
                            String type = osAddr.getType();
                            if (type != null) {
                                if (type.equalsIgnoreCase("fixed")) {
                                    getFixedAddresses().add(osAddr.getAddr());
                                } else {
                                    getFloatingAddresses().add(osAddr.getAddr());
                                }
                            }
                        }
                    } catch (ZoneException e) {
                        LOG.error(EELFResourceManager.format(e));
                    }
                }
            }
        } catch (Exception e) {
            LOG.error(String.format("Unexpected exception %s retrieving addresses for server %s", e.getClass().getSimpleName(), getId()));
            LOG.error(EELFResourceManager.format(e));
        }
    }
}
Also used : ConnectedServer(com.att.cdp.zones.spi.model.ConnectedServer) Server(com.att.cdp.zones.model.Server) ZoneException(com.att.cdp.exceptions.ZoneException) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with Network

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

the class ConnectedNetwork method refresh.

@Override
public void refresh() throws ZoneException {
    Context context = getContext();
    Network copy = context.getNetworkService().getNetworkById(getId());
    ObjectMapper.map(copy, this);
}
Also used : Context(com.att.cdp.zones.Context) Network(com.att.cdp.zones.model.Network)

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