Search in sources :

Example 71 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackVolumeService method getSnapshots.

/**
 * Retrieves the list of snapshots defined for this service.
 *
 * @return The list of snapshots for this tenant, if any. The list may be empty if there are no snapshots defined.
 * @see com.att.cdp.zones.VolumeService#getSnapshots()
 */
@Override
public List<Snapshot> getSnapshots() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Snapshot> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Snapshots snapshots = nova.getClient().snapshots().list(true).execute();
        for (com.woorea.openstack.nova.model.Snapshot snap : snapshots) {
            list.add(new OpenStackSnapshot(context, snap));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) Snapshot(com.att.cdp.zones.model.Snapshot) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 72 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackVolumeService method getSnapshots.

/**
 * Returns a list of snapshots that match the supplied name
 *
 * @param name
 *            The name pattern of the snapshots to be located. The name is a regular expression that is suitable for
 *            use in the Java String.matches() method.
 * @return A list (potentially empty) of all snapshots that match the specified name pattern
 * @throws ZoneException
 *             - If the snapshot service cannot be accessed.
 * @see java.lang.String#matches(String)
 * @see com.att.cdp.zones.VolumeService#getSnapshots(java.lang.String)
 */
@Override
public List<Snapshot> getSnapshots(String name) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SNAPSHOT, name);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Snapshot> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Snapshots snapshots = nova.getClient().snapshots().list(true).execute();
        for (com.woorea.openstack.nova.model.Snapshot snap : snapshots) {
            if (name != null) {
                if (snap.getName() != null && snap.getName().matches(name)) {
                    list.add(new OpenStackSnapshot(context, snap));
                }
            } else {
                list.add(new OpenStackSnapshot(context, snap));
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) Snapshot(com.att.cdp.zones.model.Snapshot) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 73 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method getExtensions.

/**
 * Returns the set of extensions loaded, if any
 *
 * @return The list of extensions installed, if any
 * @throws ZoneException
 *             If anything fails
 */
public List<String> getExtensions() throws ZoneException {
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<String> extensions = new ArrayList<>();
    try {
        for (Extension extension : nova.getClient().extensions().list(true).execute()) {
            extensions.add(extension.getName());
        }
    } catch (OpenStackBaseException ex) {
        if (ex instanceof OpenStackResponseException) {
            OpenStackResponseException osre = (OpenStackResponseException) ex;
            if (osre.getStatus() != 404) {
                ExceptionMapper.mapException(ex);
            }
        } else {
            ExceptionMapper.mapException(ex);
        }
    }
    return extensions;
}
Also used : Extension(com.woorea.openstack.nova.model.Extension) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 74 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method abortResize.

/**
 * @see com.att.cdp.zones.ComputeService#abortResize(com.att.cdp.zones.model.Server)
 */
@SuppressWarnings("nls")
@Override
public void abortResize(Server server) throws ZoneException {
    checkArg(server, "server");
    checkArg(server.getId(), "server id");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        OpenStackResponse request = nova.getClient().servers().revertResize(server.getId()).request();
        if (request != null && request.getStatus() != Status.ACCEPTED.getStatusCode()) {
            throw new ZoneException(request.getEntity(String.class));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackResponse(com.woorea.openstack.base.client.OpenStackResponse) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 75 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method rebuildServer.

/**
 * Rebuilds the server with the exact same image that it was currently built from.
 *
 * @see com.att.cdp.zones.ComputeService#rebuildServer(com.att.cdp.zones.model.Server)
 */
@SuppressWarnings("nls")
@Override
public void rebuildServer(Server server) throws ZoneException {
    checkArg(server, "server");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVER, server.getId());
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    Rebuild rebuild = new Rebuild();
    rebuild.setImageRef(server.getImage());
    try {
        nova.getClient().servers().rebuild(server.getId(), rebuild).execute();
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Rebuild(com.woorea.openstack.nova.model.ServerAction.Rebuild)

Aggregations

OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)151 OpenStackContext (com.att.cdp.openstack.OpenStackContext)140 Context (com.att.cdp.zones.Context)140 ArrayList (java.util.ArrayList)54 Quantum (com.woorea.openstack.quantum.Quantum)36 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 ZoneException (com.att.cdp.exceptions.ZoneException)15 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)14 Server (com.att.cdp.zones.model.Server)11 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)11 HashMap (java.util.HashMap)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10 Snapshot (com.att.cdp.zones.model.Snapshot)10 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)8 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)8 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)8 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)8 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)7 Network (com.att.cdp.zones.model.Network)7 Port (com.att.cdp.zones.model.Port)7