Search in sources :

Example 1 with Image

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);
}
Also used : Context(com.att.cdp.zones.Context) Image(com.att.cdp.zones.model.Image)

Example 2 with Image

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;
}
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) Image(com.att.cdp.zones.model.Image) AbstractImage(com.att.cdp.zones.spi.AbstractImage) OpenStackImage(com.att.cdp.openstack.model.OpenStackImage)

Example 3 with 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;
}
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 4 with 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 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;
}
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 5 with Image

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

Image (com.att.cdp.zones.model.Image)10 Context (com.att.cdp.zones.Context)9 OpenStackContext (com.att.cdp.openstack.OpenStackContext)6 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)6 AbstractImage (com.att.cdp.zones.spi.AbstractImage)6 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)6 ArrayList (java.util.ArrayList)4 ImageService (com.att.cdp.zones.ImageService)3 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 ZoneException (com.att.cdp.exceptions.ZoneException)1 Images (com.woorea.openstack.nova.model.Images)1