Search in sources :

Example 11 with Network

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

the class OpenStackNetworkService method getVLANTransparency.

/**
 * @see com.att.cdp.zones.NetworkService#getVLANTransparency()
 */
@SuppressWarnings("nls")
@Override
public List<Network> getVLANTransparency() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    ArrayList<Network> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        VLANResource resource = client.vlans();
        for (com.woorea.openstack.quantum.model.Network net : resource.list().execute()) {
            list.add(new OpenStackNetwork(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) Network(com.att.cdp.zones.model.Network) AbstractNetwork(com.att.cdp.zones.spi.AbstractNetwork) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) ArrayList(java.util.ArrayList) VLANResource(com.woorea.openstack.quantum.api.VLANResource) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork)

Example 12 with Network

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

the class OpenStackNetworkService method getNetworksByName.

/**
 * @see com.att.cdp.zones.NetworkService#getNetworksByName(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<Network> getNetworksByName(String name) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.NETWORK, name);
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    List<Network> list = new ArrayList<>();
    try {
        Quantum client = quantumConnector.getClient();
        NetworksResource resource = client.networks();
        for (com.woorea.openstack.quantum.model.Network net : resource.list().execute()) {
            if (net.getName().equals(name)) {
                list.add(new OpenStackNetwork(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) Network(com.att.cdp.zones.model.Network) AbstractNetwork(com.att.cdp.zones.spi.AbstractNetwork) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) ArrayList(java.util.ArrayList) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) NetworksResource(com.woorea.openstack.quantum.api.NetworksResource)

Example 13 with Network

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

the class OpenStackNetworkService method createNetwork.

@SuppressWarnings("nls")
@Override
public Network createNetwork(Network network) throws ZoneException {
    checkArg(network, "network");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.NETWORK, network.getName());
    RequestState.put(RequestState.SERVICE, "Network");
    RequestState.put(RequestState.SERVICE_URL, quantumConnector.getEndpoint());
    try {
        Quantum client = quantumConnector.getClient();
        com.woorea.openstack.quantum.model.Network netcreate = new com.woorea.openstack.quantum.model.Network();
        netcreate.setName(network.getName());
        netcreate.setAdminStateUp(true);
        com.woorea.openstack.quantum.model.Network openstackNetwork = client.networks().create(netcreate).execute();
        return new OpenStackNetwork(context, openstackNetwork);
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return null;
}
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) Network(com.att.cdp.zones.model.Network) AbstractNetwork(com.att.cdp.zones.spi.AbstractNetwork) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork)

Example 14 with Network

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

the class TestComputeService method testGetServerLazy.

/**
 * @throws ZoneException
 *             If the connection fails or the server cant be found
 * @throws IllegalAccessException
 *             If the fields cant be accessed
 * @throws IllegalArgumentException
 *             If the fields cant be accessed
 */
@Ignore
@Test
public void testGetServerLazy() throws ZoneException, IllegalArgumentException, IllegalAccessException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    Server server = computeService.getServer(TEST_SERVER_UUID);
    /*
         * Make sure that we have not obtained any of the transitive dependencies yet
         */
    assertNotNull(server);
    AtomicBoolean ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, get the network and ensure that it is correct
         */
    List<Network> networks = server.getNetworks();
    assertNotNull(networks);
    assertFalse(networks.isEmpty());
    boolean found = false;
    for (Network network : networks) {
        if (network.getName().equals(TEST_NETWORK_NAME)) {
            found = true;
            break;
        }
    }
    assertTrue(found);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, determine the boot source and image, this will cause the images to be processed
         */
    ServerBootSource bs = server.getBootSource();
    assertNotNull(bs);
    assertTrue(bs.equals(ServerBootSource.IMAGE) || bs.equals(ServerBootSource.SNAPSHOT));
    String image = server.getImage();
    assertNotNull(image);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertFalse(ab.get());
    /*
         * Now, lets see if there are any volume attachments. This will load the volumes transitive relationship
         */
    Map<String, Volume> volumes = server.getVolumes();
    assertNotNull(volumes);
    ab = (AtomicBoolean) networksProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) imagesProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
    ab = (AtomicBoolean) volumeAttachmentsProcessedField.get(server);
    assertNotNull(ab);
    assertTrue(ab.get());
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) Volume(com.att.cdp.zones.model.Volume) Network(com.att.cdp.zones.model.Network) ServerBootSource(com.att.cdp.zones.model.ServerBootSource) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with Network

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

the class TestNetworkService method testCreateNetwork.

/**
 * Verifies that we can create a network on a provider.
 *
 * @throws ZoneException
 *             If the connection fails, user is not authorized, or the provider cannot perform the operation.
 */
@Test
@Ignore
public void testCreateNetwork() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    // test network creation
    try {
        Network testNetwork = new Network("CDP_Test_Network");
        service.createNetwork(testNetwork);
        List<Network> 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

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