Search in sources :

Example 1 with Images

use of com.woorea.openstack.nova.model.Images in project AJSC by att.

the class OpenStackImageService method getImageByName.

/**
 * This method is used to get the image where the name of the image exactly matches the supplied name.
 *
 * @param name
 *            The name that is compared to the image name to select it for the returned image.
 * @return The image that match the specified name
 * @throws ZoneException
 *             If anything fails
 * @see com.att.cdp.zones.ImageService#getImageByName(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Image getImageByName(String name) throws ZoneException {
    checkArg(name, "name");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.IMAGE, name);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    Image image = null;
    try {
        com.woorea.openstack.nova.api.ImagesResource.List openStackRequest = nova.getClient().images().list(true);
        openStackRequest.queryParam("name", name);
        Images images = openStackRequest.execute();
        if (images.getList() != null && images.getList().size() == 1) {
            image = new OpenStackImage(context, images.getList().get(0));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return image;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Images(com.woorea.openstack.nova.model.Images) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage) 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)1 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)1 Context (com.att.cdp.zones.Context)1 Image (com.att.cdp.zones.model.Image)1 AbstractImage (com.att.cdp.zones.spi.AbstractImage)1 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 Images (com.woorea.openstack.nova.model.Images)1