use of com.att.cdp.zones.model.Image in project AJSC by att.
the class ConnectedImage method refreshAll.
/**
* @see com.att.cdp.zones.model.Image#refreshAll()
*/
@Override
public void refreshAll() throws ZoneException {
Context context = getContext();
Image copy = context.getImageService().getImage(getId());
ObjectMapper.map(copy, this);
}
use of com.att.cdp.zones.model.Image 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, "Image");
RequestState.put(RequestState.SERVICE_URL, glance.getEndpoint());
Image image = null;
try {
com.woorea.openstack.glance.ImagesResource.List openStackRequest = glance.getClient().images().list(false);
openStackRequest.queryParam("name", name);
com.woorea.openstack.glance.model.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;
}
use of com.att.cdp.zones.model.Image 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)
*/
@SuppressWarnings("nls")
@Override
public List<Image> listImages(String pattern) throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.IMAGE, pattern);
RequestState.put(RequestState.SERVICE, "Image");
RequestState.put(RequestState.SERVICE_URL, glance.getEndpoint());
ArrayList<Image> list = new ArrayList<>();
try {
/*
* Since a subset of the collection of images is returned, next link is provided to get the next set of
* images.
*/
String next = null;
do {
com.woorea.openstack.glance.ImagesResource.List openStackRequest = glance.getClient().images().list(false);
if (next != null) {
int index = next.indexOf("?");
openStackRequest.queryString(next.substring(++index));
}
com.woorea.openstack.glance.model.Images images = openStackRequest.execute();
for (com.woorea.openstack.glance.model.Image osImage : images) {
if (pattern != null) {
if (osImage.getName().matches(pattern)) {
list.add(new OpenStackImage(context, osImage));
}
} else {
list.add(new OpenStackImage(context, osImage));
}
}
next = images.getNext();
} while (next != null);
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.att.cdp.zones.model.Image 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()
*/
@SuppressWarnings("nls")
@Override
public List<Image> listImages() throws ZoneException {
connect();
Context context = getContext();
trackRequest();
RequestState.put(RequestState.SERVICE, "Image");
RequestState.put(RequestState.SERVICE_URL, glance.getEndpoint());
ArrayList<Image> list = new ArrayList<>();
try {
/*
* Since a subset of the collection of images is returned, next link is provided to get the next set of
* images.
*/
String next = null;
do {
com.woorea.openstack.glance.ImagesResource.List openStackRequest = glance.getClient().images().list(false);
if (next != null) {
int index = next.indexOf("?");
openStackRequest.queryString(next.substring(++index));
}
com.woorea.openstack.glance.model.Images images = openStackRequest.execute();
for (com.woorea.openstack.glance.model.Image osImage : images) {
list.add(new OpenStackImage(context, osImage));
}
next = images.getNext();
} while (next != null);
} catch (OpenStackBaseException ex) {
ExceptionMapper.mapException(ex);
}
return list;
}
use of com.att.cdp.zones.model.Image 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