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;
}
Aggregations