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