Search in sources :

Example 6 with OpenStackImage

use of com.att.cdp.openstack.model.OpenStackImage in project AJSC by att.

the class OpenStackImageService method listImages.

/**
 * This method is used to list all of the images that are available within the context.
 *
 * @return The list of images or an empty list if there are none available.
 * @throws ZoneException
 *             If the service fails.
 * @see com.att.cdp.zones.ImageService#listImages()
 */
@Override
public List<Image> listImages() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Image> list = new ArrayList<>();
    try {
        for (com.woorea.openstack.nova.model.Image osImage : nova.getClient().images().list(true).execute()) {
            list.add(new OpenStackImage(context, osImage));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage) ArrayList(java.util.ArrayList) Image(com.att.cdp.zones.model.Image) AbstractImage(com.att.cdp.zones.spi.AbstractImage) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage)

Example 7 with OpenStackImage

use of com.att.cdp.openstack.model.OpenStackImage in project AJSC by att.

the class OpenStackImageService method getImage.

/**
 * @see com.att.cdp.zones.ImageService#getImage(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Image getImage(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.IMAGE, id);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        return new OpenStackImage(context, nova.getClient().images().show(id).execute());
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    // just for the compiler
    return null;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage)

Example 8 with OpenStackImage

use of com.att.cdp.openstack.model.OpenStackImage in project AJSC by att.

the class OpenStackImageService method listImages.

/**
 * This method is used to list all of the images where the name of the image matches the supplied pattern.
 *
 * @param pattern
 *            The pattern (regular expression) that is compared to the image name to select it for the returned
 *            list.
 * @return The list of images that match the specified name pattern
 * @throws ZoneException
 *             If anything fails
 * @see com.att.cdp.zones.ImageService#listImages(java.lang.String)
 */
@Override
public List<Image> listImages(String pattern) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.IMAGE, pattern);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Image> list = new ArrayList<>();
    try {
        for (com.woorea.openstack.nova.model.Image osImage : nova.getClient().images().list(true).execute()) {
            if (pattern != null) {
                if (osImage.getName().matches(pattern)) {
                    list.add(new OpenStackImage(context, osImage));
                }
            } else {
                list.add(new OpenStackImage(context, osImage));
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage) ArrayList(java.util.ArrayList) Image(com.att.cdp.zones.model.Image) AbstractImage(com.att.cdp.zones.spi.AbstractImage) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)8 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)8 Context (com.att.cdp.zones.Context)8 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)8 Image (com.att.cdp.zones.model.Image)6 AbstractImage (com.att.cdp.zones.spi.AbstractImage)6 ArrayList (java.util.ArrayList)4 Images (com.woorea.openstack.nova.model.Images)1