use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendStorageDomainTemplatesResource method list.
@Override
public Templates list() {
Templates templates = new Templates();
boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
if (unregistered) {
List<org.ovirt.engine.core.common.businessentities.VmTemplate> unregisteredTemplates = getBackendCollection(QueryType.GetUnregisteredVmTemplates, new IdQueryParameters(storageDomainId));
List<Template> collection = new ArrayList<>();
for (org.ovirt.engine.core.common.businessentities.VmTemplate entity : unregisteredTemplates) {
Template vmTemplate = map(entity);
collection.add(addLinks(populate(vmTemplate, entity)));
}
templates.getTemplates().addAll(collection);
} else {
templates.getTemplates().addAll(getCollection());
}
return templates;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplateDiskAttachmentResource method addParents.
@Override
protected DiskAttachment addParents(DiskAttachment attachment) {
Template template = new Template();
template.setId(templateId.toString());
attachment.setTemplate(template);
return attachment;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplateDiskAttachmentsResource method addParents.
@Override
protected DiskAttachment addParents(DiskAttachment attachment) {
Template template = new Template();
template.setId(templateId.toString());
attachment.setTemplate(template);
return attachment;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class V3TemplateInAdapter method adapt.
@Override
public Template adapt(V3Template from) {
Template to = new Template();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetBios()) {
to.setBios(adaptIn(from.getBios()));
}
if (from.isSetCluster()) {
to.setCluster(adaptIn(from.getCluster()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetConsole()) {
to.setConsole(adaptIn(from.getConsole()));
}
if (from.isSetCpu()) {
to.setCpu(adaptIn(from.getCpu()));
}
if (from.isSetCpuProfile()) {
to.setCpuProfile(adaptIn(from.getCpuProfile()));
}
if (from.isSetCpuShares()) {
to.setCpuShares(from.getCpuShares());
}
if (from.isSetCreationTime()) {
to.setCreationTime(from.getCreationTime());
}
if (from.isSetCustomCpuModel()) {
to.setCustomCpuModel(from.getCustomCpuModel());
}
if (from.isSetCustomEmulatedMachine()) {
to.setCustomEmulatedMachine(from.getCustomEmulatedMachine());
}
if (from.isSetCustomProperties()) {
to.setCustomProperties(new CustomProperties());
to.getCustomProperties().getCustomProperties().addAll(adaptIn(from.getCustomProperties().getCustomProperty()));
}
if (from.isSetDeleteProtected()) {
to.setDeleteProtected(from.isDeleteProtected());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetDisplay()) {
to.setDisplay(adaptIn(from.getDisplay()));
}
if (from.isSetDomain()) {
to.setDomain(adaptIn(from.getDomain()));
}
if (from.isSetHighAvailability()) {
to.setHighAvailability(adaptIn(from.getHighAvailability()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetIo()) {
to.setIo(adaptIn(from.getIo()));
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetLargeIcon()) {
to.setLargeIcon(adaptIn(from.getLargeIcon()));
}
if (from.isSetMemory()) {
to.setMemory(from.getMemory());
}
if (from.isSetMemoryPolicy()) {
to.setMemoryPolicy(adaptIn(from.getMemoryPolicy()));
}
if (from.isSetMigration()) {
to.setMigration(adaptIn(from.getMigration()));
}
if (from.isSetMigrationDowntime()) {
to.setMigrationDowntime(from.getMigrationDowntime());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetOrigin()) {
to.setOrigin(from.getOrigin());
}
if (from.isSetOs()) {
to.setOs(adaptIn(from.getOs()));
}
if (from.isSetRngDevice()) {
to.setRngDevice(adaptIn(from.getRngDevice()));
}
if (from.isSetSerialNumber()) {
to.setSerialNumber(adaptIn(from.getSerialNumber()));
}
if (from.isSetSmallIcon()) {
to.setSmallIcon(adaptIn(from.getSmallIcon()));
}
if (from.isSetSoundcardEnabled()) {
to.setSoundcardEnabled(from.isSoundcardEnabled());
}
if (from.isSetSso()) {
to.setSso(adaptIn(from.getSso()));
}
if (from.isSetStartPaused()) {
to.setStartPaused(from.isStartPaused());
}
if (from.isSetStateless()) {
to.setStateless(from.isStateless());
}
if (from.isSetStatus() && from.getStatus().isSetState()) {
to.setStatus(TemplateStatus.fromValue(from.getStatus().getState()));
}
if (from.isSetStorageDomain()) {
to.setStorageDomain(adaptIn(from.getStorageDomain()));
}
if (from.isSetTimeZone()) {
to.setTimeZone(adaptIn(from.getTimeZone()));
}
if (from.isSetTunnelMigration()) {
to.setTunnelMigration(from.isTunnelMigration());
}
if (from.isSetType()) {
to.setType(VmType.fromValue(from.getType()));
}
if (from.isSetUsb()) {
to.setUsb(adaptIn(from.getUsb()));
}
if (from.isSetVersion()) {
to.setVersion(adaptIn(from.getVersion()));
}
if (from.isSetVirtioScsi()) {
to.setVirtioScsi(adaptIn(from.getVirtioScsi()));
}
if (from.isSetVm()) {
to.setVm(adaptIn(from.getVm()));
}
// new structured "time_zone" element containing the name of the time zone and the UTC offset:
if (from.isSetTimezone() && !to.isSetTimeZone()) {
TimeZone timeZone = new TimeZone();
timeZone.setName(from.getTimezone());
to.setTimeZone(timeZone);
}
return to;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class V3TemplateOutAdapter method adapt.
@Override
public V3Template adapt(Template from) {
V3Template to = new V3Template();
// Remove the links for "rels" that are new in version 4 of the API:
if (from.isSetLinks()) {
List<Link> links = from.getLinks().stream().filter(link -> !RELS_TO_REMOVE.contains(link.getRel())).collect(toList());
to.getLinks().addAll(adaptOut(links));
}
if (from.isSetActions()) {
to.setActions(adaptOut(from.getActions()));
}
if (from.isSetBios()) {
to.setBios(adaptOut(from.getBios()));
}
if (from.isSetCluster()) {
to.setCluster(adaptOut(from.getCluster()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetConsole()) {
to.setConsole(adaptOut(from.getConsole()));
}
if (from.isSetCpu()) {
to.setCpu(adaptOut(from.getCpu()));
}
if (from.isSetCpuProfile()) {
to.setCpuProfile(adaptOut(from.getCpuProfile()));
}
if (from.isSetCpuShares()) {
to.setCpuShares(from.getCpuShares());
}
if (from.isSetCreationTime()) {
to.setCreationTime(from.getCreationTime());
}
if (from.isSetCustomCpuModel()) {
to.setCustomCpuModel(from.getCustomCpuModel());
}
if (from.isSetCustomEmulatedMachine()) {
to.setCustomEmulatedMachine(from.getCustomEmulatedMachine());
}
if (from.isSetCustomProperties()) {
to.setCustomProperties(new V3CustomProperties());
to.getCustomProperties().getCustomProperty().addAll(adaptOut(from.getCustomProperties().getCustomProperties()));
}
if (from.isSetDeleteProtected()) {
to.setDeleteProtected(from.isDeleteProtected());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetDisplay()) {
to.setDisplay(adaptOut(from.getDisplay()));
}
if (from.isSetDomain()) {
to.setDomain(adaptOut(from.getDomain()));
}
if (from.isSetHighAvailability()) {
to.setHighAvailability(adaptOut(from.getHighAvailability()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetIo()) {
to.setIo(adaptOut(from.getIo()));
}
if (from.isSetLargeIcon()) {
to.setLargeIcon(adaptOut(from.getLargeIcon()));
}
if (from.isSetMemory()) {
to.setMemory(from.getMemory());
}
if (from.isSetMemoryPolicy()) {
to.setMemoryPolicy(adaptOut(from.getMemoryPolicy()));
}
if (from.isSetMigration()) {
to.setMigration(adaptOut(from.getMigration()));
}
if (from.isSetMigrationDowntime()) {
to.setMigrationDowntime(from.getMigrationDowntime());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetOrigin()) {
to.setOrigin(from.getOrigin());
}
if (from.isSetOs()) {
to.setOs(adaptOut(from.getOs()));
}
if (from.isSetRngDevice()) {
to.setRngDevice(adaptOut(from.getRngDevice()));
}
if (from.isSetSerialNumber()) {
to.setSerialNumber(adaptOut(from.getSerialNumber()));
}
if (from.isSetSmallIcon()) {
to.setSmallIcon(adaptOut(from.getSmallIcon()));
}
if (from.isSetSoundcardEnabled()) {
to.setSoundcardEnabled(from.isSoundcardEnabled());
}
if (from.isSetSso()) {
to.setSso(adaptOut(from.getSso()));
}
if (from.isSetStartPaused()) {
to.setStartPaused(from.isStartPaused());
}
if (from.isSetStateless()) {
to.setStateless(from.isStateless());
}
if (from.isSetStatus()) {
V3Status status = new V3Status();
status.setState(from.getStatus().value());
to.setStatus(status);
}
if (from.isSetStorageDomain()) {
to.setStorageDomain(adaptOut(from.getStorageDomain()));
}
if (from.isSetTimeZone()) {
to.setTimeZone(adaptOut(from.getTimeZone()));
}
if (from.isSetTunnelMigration()) {
to.setTunnelMigration(from.isTunnelMigration());
}
if (from.isSetType()) {
to.setType(from.getType().value());
}
if (from.isSetUsb()) {
to.setUsb(adaptOut(from.getUsb()));
}
if (from.isSetVersion()) {
to.setVersion(adaptOut(from.getVersion()));
}
if (from.isSetVirtioScsi()) {
to.setVirtioScsi(adaptOut(from.getVirtioScsi()));
}
if (from.isSetVm()) {
to.setVm(adaptOut(from.getVm()));
}
// new structured "time_zone" element containing the name of the time zone and the UTC offset:
if (from.isSetTimeZone() && !to.isSetTimezone()) {
TimeZone timeZone = from.getTimeZone();
if (timeZone.isSetName()) {
to.setTimezone(timeZone.getName());
}
}
return to;
}
Aggregations