Search in sources :

Example 1 with ComputeImageServerRestRep

use of com.emc.storageos.model.compute.ComputeImageServerRestRep in project coprhd-controller by CoprHD.

the class ComputeMapper method map.

/**
 * Utility mapper method to map fields of {@link ComputeImageServer} columnFamily to {@link ComputeImageServerRestRep} rest
 * representation.
 *
 * @param dbclient
 *            {@link DbClient} instance
 * @param from
 *            {@link ComputeImageServer} instance that has to be mapped.
 * @return {@link ComputeImageServerRestRep}
 */
public static ComputeImageServerRestRep map(DbClient dbclient, ComputeImageServer from) {
    if (from == null) {
        return null;
    }
    ComputeImageServerRestRep to = new ComputeImageServerRestRep();
    mapDataObjectFields(from, to);
    try {
        to.setLink(new RestLinkRep("self", RestLinkFactory.simpleServiceLink(ResourceTypeEnum.COMPUTE_IMAGESERVER, from.getId())));
    } catch (URISyntaxException e) {
        LOG.warn("Error while creating self link URI.", e);
    }
    to.setImageServerIp(from.getImageServerIp());
    to.setImageServerSecondIp(from.getImageServerSecondIp());
    to.setTftpBootDir(from.getTftpBootDir());
    to.setComputeImageServerStatus(from.getComputeImageServerStatus());
    to.setImageServerUser(from.getImageServerUser());
    to.setOsInstallTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getOsInstallTimeoutMs())).intValue());
    to.setSshTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getSshTimeoutMs())).intValue());
    to.setImageImportTimeout(new Long(TimeUnit.MILLISECONDS.toSeconds(from.getImageImportTimeoutMs())).intValue());
    to.setComputeImages(new ArrayList<NamedRelatedResourceRep>());
    to.setFailedImages(new ArrayList<NamedRelatedResourceRep>());
    if (from.getComputeImages() != null) {
        for (String computeimage : from.getComputeImages()) {
            ComputeImage image = dbclient.queryObject(ComputeImage.class, URIUtil.uri(computeimage));
            if (image == null) {
                LOG.warn("Could not find compute image in database with id '" + computeimage + "'");
                continue;
            }
            to.getComputeImages().add(DbObjectMapper.toNamedRelatedResource(ResourceTypeEnum.COMPUTE_IMAGE, image.getId(), image.getLabel()));
        }
    }
    if (from.getFailedComputeImages() != null) {
        for (String failedImageID : from.getFailedComputeImages()) {
            ComputeImage failedImage = dbclient.queryObject(ComputeImage.class, URIUtil.uri(failedImageID));
            if (failedImage == null) {
                LOG.warn("Could not find failed compute image in database with id '" + failedImageID + "'");
                continue;
            }
            to.getFailedImages().add(DbObjectMapper.toNamedRelatedResource(ResourceTypeEnum.COMPUTE_IMAGE, failedImage.getId(), failedImage.getLabel()));
        }
    }
    return to;
}
Also used : RestLinkRep(com.emc.storageos.model.RestLinkRep) URISyntaxException(java.net.URISyntaxException) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Example 2 with ComputeImageServerRestRep

use of com.emc.storageos.model.compute.ComputeImageServerRestRep in project coprhd-controller by CoprHD.

the class ComputeImageServers method itemDetails.

public static void itemDetails(String id) {
    ComputeImageServerRestRep computeImageServer = ComputeImageServerUtils.getComputeImageServer(id);
    if (computeImageServer == null) {
        error(MessagesUtils.get(UNKNOWN, id));
    }
    render(computeImageServer);
}
Also used : ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep)

Example 3 with ComputeImageServerRestRep

use of com.emc.storageos.model.compute.ComputeImageServerRestRep in project coprhd-controller by CoprHD.

the class ComputeSystems method computeImageServersJson.

public static void computeImageServersJson() {
    List<ComputeImageServerInfo> results = Lists.newArrayList();
    List<ComputeImageServerRestRep> computeImageServers = ComputeImageServerUtils.getComputeImageServers();
    for (ComputeImageServerRestRep computeImageServerRR : computeImageServers) {
        ComputeImageServerInfo computeImageServer = new ComputeImageServerInfo(computeImageServerRR);
        results.add(computeImageServer);
    }
    renderJSON(DataTablesSupport.createJSON(results, params));
}
Also used : ComputeImageServerInfo(models.datatable.ComputeImageServersDataTable.ComputeImageServerInfo) ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep)

Example 4 with ComputeImageServerRestRep

use of com.emc.storageos.model.compute.ComputeImageServerRestRep in project coprhd-controller by CoprHD.

the class ComputeImageServerUtils method getComputeImageServerByName.

public static ComputeImageServerRestRep getComputeImageServerByName(String name) {
    try {
        ComputeImageServerRestRep computeImageServer = null;
        List<ComputeImageServerRestRep> computeImageServersList = getComputeImageServers();
        for (ComputeImageServerRestRep cisrr : computeImageServersList) {
            if (cisrr.getName().equalsIgnoreCase(name)) {
                computeImageServer = cisrr;
            }
        }
        return computeImageServer;
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            return null;
        }
        throw e;
    }
}
Also used : ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 5 with ComputeImageServerRestRep

use of com.emc.storageos.model.compute.ComputeImageServerRestRep in project coprhd-controller by CoprHD.

the class ComputeImageServers method edit.

@FlashException("list")
public static void edit(String id) {
    addReferenceData();
    ComputeImageServerRestRep computeImageServer = ComputeImageServerUtils.getComputeImageServer(id);
    if (computeImageServer != null) {
        ComputeImageServerForm computeImageServers = new ComputeImageServerForm(computeImageServer);
        render("@edit", computeImageServers);
    } else {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        list();
    }
}
Also used : ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) FlashException(controllers.util.FlashException)

Aggregations

ComputeImageServerRestRep (com.emc.storageos.model.compute.ComputeImageServerRestRep)7 FlashException (controllers.util.FlashException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 StringOption (util.StringOption)2 ComputeImage (com.emc.storageos.db.client.model.ComputeImage)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 RestLinkRep (com.emc.storageos.model.RestLinkRep)1 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)1 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)1 Common.flashException (controllers.Common.flashException)1 ComputeImageServerInfo (models.datatable.ComputeImageServersDataTable.ComputeImageServerInfo)1