Search in sources :

Example 1 with NotSupportedException

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

the class AbstractVolume method getVolumes.

/**
 * This is a default implementation that is correct for all providers other than VMware. The VMware provider
 * overrides this method. Any other providers that want to implement this method may also override it if needed.
 *
 *    getVolumes methods gives a list of volumes for a particular model
 */
@Override
public List<Volume> getVolumes(Server server) throws ZoneException {
    Context context = getContext();
    Provider provider = context.getProvider();
    throw new NotSupportedException(String.format("Provider %s does not support getVolumebyServer Id using  a model", provider.getName()));
}
Also used : Context(com.att.cdp.zones.Context) NotSupportedException(com.att.cdp.exceptions.NotSupportedException) Provider(com.att.cdp.zones.Provider)

Example 2 with NotSupportedException

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

the class AbstractVolume method updateVolume.

/**
 * This is a default implementation that is correct for all providers other than VMware. The VMware provider
 * overrides this method. Any other providers that want to implement this method may also override it if needed.
 *
 *    updateVolume method is used to update the size of the volume (only increase)
 */
@Override
public Volume updateVolume(Volume template, Server server) throws ZoneException {
    Context context = getContext();
    Provider provider = context.getProvider();
    throw new NotSupportedException(String.format("Provider %s does not support updateVolume using a volume 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)

Example 3 with NotSupportedException

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

the class OpenStackNetworkService method assignIpAddressFromPool.

/**
 * @see com.att.cdp.zones.NetworkService#assignIpAddressFromPool(java.lang.String, java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public String assignIpAddressFromPool(String serverId, String pool) throws ZoneException {
    checkArg(serverId, "serverId");
    checkArg(pool, "pool");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, serverId);
    RequestState.put(RequestState.POOL, pool);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    Nova client = novaConnector.getClient();
    FloatingIpsExtension extension = client.floatingIps();
    if (extension == null) {
        throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_UNSUPPORTED_OPERATION, "getAvailableAddresses", context.getProvider().getName()));
    }
    try {
        String ip = reserveFreeFloatingIPAddress(pool);
        if (ip != null) {
            assignIpAddress(serverId, ip);
            return ip;
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_UNAVAILABLE, "Floating IP Address", context.getProvider().getName()));
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension) Nova(com.woorea.openstack.nova.Nova) NotSupportedException(com.att.cdp.exceptions.NotSupportedException)

Example 4 with NotSupportedException

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

the class OpenStackNetworkService method getFloatingIpPools.

/**
 * @see com.att.cdp.zones.NetworkService#getFloatingIpPools()
 */
@SuppressWarnings("nls")
@Override
public List<String> getFloatingIpPools() throws ZoneException {
    HashSet<String> pools = new HashSet<>();
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    FloatingIpsExtension extension = novaConnector.getClient().floatingIps();
    if (extension == null) {
        throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_UNSUPPORTED_OPERATION, "getAvailableAddresses", context.getProvider().getName()));
    }
    try {
        for (FloatingIp ip : extension.list().execute()) {
            if (!pools.contains(ip.getPool())) {
                pools.add(ip.getPool());
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return Collections.list(Collections.enumeration(pools));
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) FloatingIpsExtension(com.woorea.openstack.nova.api.extensions.FloatingIpsExtension) NotSupportedException(com.att.cdp.exceptions.NotSupportedException) FloatingIp(com.woorea.openstack.nova.model.FloatingIp) HashSet(java.util.HashSet)

Example 5 with NotSupportedException

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

the class OpenStackNetworkService method assignIpAddressFromPool.

/**
 * @see com.att.cdp.zones.NetworkService#assignIpAddressFromPool(com.att.cdp.zones.model.Server)
 */
@SuppressWarnings("nls")
@Override
public String assignIpAddressFromPool(Server server) throws ZoneException {
    checkArg(server, "server");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, server.getName());
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    String ip;
    try {
        ip = reserveFreeFloatingIPAddress(null);
        if (ip != null) {
            assignIpAddress(server, ip);
            return ip;
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    throw new NotSupportedException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_UNAVAILABLE, "Floating IP Address", context.getProvider().getName()));
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) NotSupportedException(com.att.cdp.exceptions.NotSupportedException)

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