Search in sources :

Example 6 with NotSupportedException

use of com.att.cdp.exceptions.NotSupportedException in project AJSC by att.

the class OpenStackNetworkService method getAvailableAddresses.

/**
 * This method allows the caller to obtain a list of the available IP addresses from the Floating IP address (DNS)
 * pool.
 *
 * @return The list of available IP Addresses that can be used to assign a floating IP address to a server.
 * @throws ZoneException
 *             If the service is not available or the pool cannot be obtained
 * @see com.att.cdp.zones.NetworkService#getAvailableAddresses(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<String> getAvailableAddresses(String pool) throws ZoneException {
    checkArg(pool, "pool");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.POOL, pool);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    ArrayList<String> addresses = new ArrayList<>();
    FloatingIpsExtension extension = novaConnector.getClient().floatingIps();
    if (extension == null) {
        throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_UNSUPPORTED_OPERATION, "getAvailableAddresses", context.getProvider().getName()));
    }
    try {
        FloatingIps ips = extension.list().execute();
        for (FloatingIp ip : ips) {
            if (ip.getPool().equalsIgnoreCase(pool)) {
                String ipAddress = ip.getIp();
                addresses.add(ipAddress);
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return addresses;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) FloatingIps(com.woorea.openstack.nova.model.FloatingIps) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension) ArrayList(java.util.ArrayList) NotSupportedException(com.att.cdp.exceptions.NotSupportedException) FloatingIp(com.woorea.openstack.nova.model.FloatingIp)

Example 7 with NotSupportedException

use of com.att.cdp.exceptions.NotSupportedException in project AJSC by att.

the class AbstractNetwork method createPort.

/**
 * This method is implemented here until it can be implemented for all providers. This allows the specific providers
 * to be updated incrementally to add this capability. TODO Add this capability to all providers. Currently only
 * implemented in OpenStack.
 *
 * @see com.att.cdp.zones.NetworkService#createPort(com.att.cdp.zones.model.Subnet, com.att.cdp.zones.model.Port)
 */
@Override
public Port createPort(Subnet subnet, Port model) throws ZoneException {
    Context context = getContext();
    Provider provider = context.getProvider();
    throw new NotSupportedException(String.format("Provider %s does not support createPort using a Port object as a model", provider.getName()));
}
Also used : Context(com.att.cdp.zones.Context) NotSupportedException(com.att.cdp.exceptions.NotSupportedException) Provider(com.att.cdp.zones.Provider)

Aggregations

NotSupportedException (com.att.cdp.exceptions.NotSupportedException)7 Context (com.att.cdp.zones.Context)7 OpenStackContext (com.att.cdp.openstack.OpenStackContext)4 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)4 Provider (com.att.cdp.zones.Provider)3 FloatingIpsExtension (com.woorea.openstack.nova.api.extensions.FloatingIpsExtension)3 FloatingIp (com.woorea.openstack.nova.model.FloatingIp)2 Nova (com.woorea.openstack.nova.Nova)1 FloatingIps (com.woorea.openstack.nova.model.FloatingIps)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1