Search in sources :

Example 1 with ResourceNotFoundException

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

the class OpenStackVolumeService method getVolume.

/**
 * Returns information about the volume with the indicated id, if it exists.
 *
 * @param id
 *            The id of the volume that we want to find information about
 * @return The volume if it exists
 * @throws ZoneException
 *             - If the volume cannot be listed, or the volume does not exist
 * @see com.att.cdp.zones.VolumeService#getVolume(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Volume getVolume(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.VOLUME, id);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        com.woorea.openstack.nova.model.Volume volume = nova.getClient().volumes().show(id).execute();
        if (volume == null) {
            throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Volume", id, context.getProvider().getName()));
        }
        return new OpenStackVolume(context, volume);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    // for the compiler
    return null;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException)

Example 2 with ResourceNotFoundException

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

the class OpenStackVolumeService method getSnapshot.

/**
 * Returns information about the snapshot with the indicated id, if it exists.
 *
 * @param id
 *            The id of the snapshot that we want to find information about
 * @return The snapshot if it exists
 * @throws ZoneException
 *             - If the snapshot cannot be listed, or the snapshot does not exist
 * @see com.att.cdp.zones.VolumeService#getSnapshot(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Snapshot getSnapshot(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SNAPSHOT, id);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        com.woorea.openstack.nova.model.Snapshot snapshot = nova.getClient().snapshots().show(id).execute();
        if (snapshot == null) {
            throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Snapshot", id, context.getProvider().getName()));
        }
        return new OpenStackSnapshot(context, snapshot);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    // for the compiler
    return null;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException)

Example 3 with ResourceNotFoundException

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

the class OpenStackComputeService method getTemplate.

/**
 * Obtains the template specified by the provided id
 *
 * @see com.att.cdp.zones.ComputeService#getTemplate(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Template getTemplate(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.TEMPLATE, id);
    try {
        return new OpenStackTemplate(context, nova.getClient().flavors().show(id).execute());
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    } catch (Exception e) {
        throw new ResourceNotFoundException(e);
    }
    // for the compiler
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) InvalidRequestException(com.att.cdp.exceptions.InvalidRequestException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) ContextClosedException(com.att.cdp.exceptions.ContextClosedException) NotLoggedInException(com.att.cdp.exceptions.NotLoggedInException)

Example 4 with ResourceNotFoundException

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

the class OpenStackVolumeService method getSnapshot.

/**
 * Returns information about the snapshot with the indicated id, if it exists.
 *
 * @param id
 *            The id of the snapshot that we want to find information about
 * @return The snapshot if it exists
 * @throws ZoneException
 *             - If the snapshot cannot be listed, or the snapshot does not exist
 * @see com.att.cdp.zones.VolumeService#getSnapshot(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Snapshot getSnapshot(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SNAPSHOT, id);
    RequestState.put(RequestState.SERVICE, "Volume");
    RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
    try {
        com.woorea.openstack.cinder.model.Snapshot snapshot = cinder.getClient().snapshots().show(id).execute();
        if (snapshot == null) {
            throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Snapshot", id, context.getProvider().getName()));
        }
        return new OpenStackSnapshot(context, snapshot);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    // for the compiler
    return null;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException)

Example 5 with ResourceNotFoundException

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

the class OpenStackVolumeService method getVolume.

/**
 * Returns information about the volume with the indicated id, if it exists.
 *
 * @param id
 *            The id of the volume that we want to find information about
 * @return The volume if it exists
 * @throws ZoneException
 *             - If the volume cannot be listed, or the volume does not exist
 * @see com.att.cdp.zones.VolumeService#getVolume(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Volume getVolume(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.VOLUME, id);
    RequestState.put(RequestState.SERVICE, "Volume");
    RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
    try {
        com.woorea.openstack.cinder.model.Volume volume = cinder.getClient().volumes().show(id).execute();
        if (volume == null) {
            throw new ResourceNotFoundException(EELFResourceManager.format(OSMsg.PAL_OS_RESOURCE_NOT_FOUND, "Volume", id, context.getProvider().getName()));
        }
        return new OpenStackVolume(context, volume);
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    // for the compiler
    return null;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)9 OpenStackContext (com.att.cdp.openstack.OpenStackContext)9 Context (com.att.cdp.zones.Context)9 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)8 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)4 ZoneException (com.att.cdp.exceptions.ZoneException)3 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)3 ContextClosedException (com.att.cdp.exceptions.ContextClosedException)2 InvalidRequestException (com.att.cdp.exceptions.InvalidRequestException)2 NotLoggedInException (com.att.cdp.exceptions.NotLoggedInException)2 OpenStackTemplate (com.att.cdp.openstack.model.OpenStackTemplate)2 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)2 ContextConnectionException (com.att.cdp.exceptions.ContextConnectionException)1 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)1 Keystone (com.woorea.openstack.keystone.Keystone)1 Role (com.woorea.openstack.keystone.model.Role)1 Roles (com.woorea.openstack.keystone.model.Roles)1 ArrayList (java.util.ArrayList)1