Search in sources :

Example 1 with Snapshot

use of com.att.cdp.zones.model.Snapshot in project AJSC by att.

the class OpenStackVolumeService method getSnapshotsByVolume.

/**
 * @see com.att.cdp.zones.VolumeService#getSnapshotsByVolume(java.lang.String)
 */
@Override
public List<Snapshot> getSnapshotsByVolume(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.VOLUME, id);
    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 (id != null) {
                if (snap.getVolumeId() != null && snap.getVolumeId().matches(id)) {
                    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 2 with Snapshot

use of com.att.cdp.zones.model.Snapshot in project AJSC by att.

the class OpenStackSnapshotService 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.SnapshotService#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) AbstractSnapshot(com.att.cdp.zones.spi.AbstractSnapshot) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 3 with Snapshot

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

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

use of com.att.cdp.zones.model.Snapshot in project AJSC by att.

the class OpenStackSnapshotService 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.SnapshotService#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) AbstractSnapshot(com.att.cdp.zones.spi.AbstractSnapshot) OpenStackSnapshot(com.att.cdp.openstack.model.OpenStackSnapshot) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Aggregations

Snapshot (com.att.cdp.zones.model.Snapshot)15 Context (com.att.cdp.zones.Context)14 OpenStackContext (com.att.cdp.openstack.OpenStackContext)10 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)10 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)10 ArrayList (java.util.ArrayList)10 SnapshotService (com.att.cdp.zones.SnapshotService)4 AbstractSnapshot (com.att.cdp.zones.spi.AbstractSnapshot)4 Ignore (org.junit.Ignore)4 Test (org.junit.Test)4