Search in sources :

Example 36 with Template

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;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) Templates(org.ovirt.engine.api.model.Templates) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 37 with Template

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;
}
Also used : Template(org.ovirt.engine.api.model.Template)

Example 38 with Template

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;
}
Also used : Template(org.ovirt.engine.api.model.Template)

Example 39 with Template

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;
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) Template(org.ovirt.engine.api.model.Template) V3Template(org.ovirt.engine.api.v3.types.V3Template) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Example 40 with Template

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;
}
Also used : HashSet(java.util.HashSet) V3Status(org.ovirt.engine.api.v3.types.V3Status) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Link(org.ovirt.engine.api.model.Link) Template(org.ovirt.engine.api.model.Template) V3Adapter(org.ovirt.engine.api.v3.V3Adapter) Set(java.util.Set) TimeZone(org.ovirt.engine.api.model.TimeZone) V3Template(org.ovirt.engine.api.v3.types.V3Template) V3OutAdapters.adaptOut(org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) TimeZone(org.ovirt.engine.api.model.TimeZone) V3Template(org.ovirt.engine.api.v3.types.V3Template) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) V3Status(org.ovirt.engine.api.v3.types.V3Status) Link(org.ovirt.engine.api.model.Link)

Aggregations

Template (org.ovirt.engine.api.model.Template)57 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)32 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)16 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)12 Vm (org.ovirt.engine.api.model.Vm)11 WebApplicationException (javax.ws.rs.WebApplicationException)6 VmPool (org.ovirt.engine.api.model.VmPool)4 Cluster (org.ovirt.engine.api.model.Cluster)3 InstanceType (org.ovirt.engine.api.model.InstanceType)3 TimeZone (org.ovirt.engine.api.model.TimeZone)3 GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)3 ArrayList (java.util.ArrayList)2 Boot (org.ovirt.engine.api.model.Boot)2 Host (org.ovirt.engine.api.model.Host)2 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Tag (org.ovirt.engine.api.model.Tag)2 TemplateVersion (org.ovirt.engine.api.model.TemplateVersion)2 Templates (org.ovirt.engine.api.model.Templates)2