Search in sources :

Example 1 with OpenStackNetwork

use of com.att.cdp.openstack.model.OpenStackNetwork in project AJSC by att.

the class OpenStackNetworkService method getNetworks.

/**
 * @see com.att.cdp.zones.NetworkService#getNetworks()
 */
@SuppressWarnings("nls")
@Override
public List<Network> getNetworks() 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();
        NetworksResource resource = client.networks();
        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) OpenStackNetwork(com.att.cdp.openstack.model.OpenStackNetwork) NetworksResource(com.woorea.openstack.quantum.api.NetworksResource)

Example 2 with OpenStackNetwork

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

Example 3 with OpenStackNetwork

use of com.att.cdp.openstack.model.OpenStackNetwork 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 4 with OpenStackNetwork

use of com.att.cdp.openstack.model.OpenStackNetwork 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 5 with OpenStackNetwork

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

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)6 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)6 Context (com.att.cdp.zones.Context)6 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)6 Network (com.att.cdp.zones.model.Network)5 AbstractNetwork (com.att.cdp.zones.spi.AbstractNetwork)4 Quantum (com.woorea.openstack.quantum.Quantum)4 ArrayList (java.util.ArrayList)4 NetworksResource (com.woorea.openstack.quantum.api.NetworksResource)2 VLANResource (com.woorea.openstack.quantum.api.VLANResource)1