Search in sources :

Example 1 with TemplateVersion

use of org.ovirt.engine.api.model.TemplateVersion in project ovirt-engine by oVirt.

the class TemplateMapper method map.

@Mapping(from = VmTemplate.class, to = Template.class)
public static Template map(VmTemplate entity, Template incoming) {
    Template model = incoming != null ? incoming : new Template();
    mapVmBaseEntityToModel(model, entity);
    if (entity.getVmInit() != null) {
        model.setInitialization(InitializationMapper.map(entity.getVmInit(), null));
    }
    if (entity.getStatus() != null) {
        model.setStatus(mapTemplateStatus(entity.getStatus()));
    }
    if (entity.getDefaultBootSequence() != null || entity.getKernelUrl() != null || entity.getInitrdUrl() != null || entity.getKernelParams() != null) {
        OperatingSystem os = new OperatingSystem();
        os.setType(SimpleDependencyInjector.getInstance().get(OsRepository.class).getUniqueOsNames().get(entity.getOsId()));
        if (entity.getDefaultBootSequence() != null) {
            Boot boot = VmMapper.map(entity.getDefaultBootSequence(), null);
            os.setBoot(boot);
        }
        os.setKernel(entity.getKernelUrl());
        os.setInitrd(entity.getInitrdUrl());
        os.setCmdline(entity.getKernelParams());
        model.setOs(os);
    }
    if (entity.getClusterArch() != null) {
        model.getCpu().setArchitecture(CPUMapper.map(entity.getClusterArch(), null));
    }
    model.setDisplay(DisplayMapper.map(entity, null));
    model.getDisplay().setDisconnectAction(map(entity.getConsoleDisconnectAction(), null).toString());
    TemplateVersion version = new TemplateVersion();
    version.setVersionName(entity.getTemplateVersionName());
    version.setVersionNumber(entity.getTemplateVersionNumber());
    Template baseTemplate = new Template();
    baseTemplate.setId(entity.getBaseTemplateId().toString());
    version.setBaseTemplate(baseTemplate);
    model.setVersion(version);
    return model;
}
Also used : OperatingSystem(org.ovirt.engine.api.model.OperatingSystem) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) TemplateVersion(org.ovirt.engine.api.model.TemplateVersion) Boot(org.ovirt.engine.api.model.Boot) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 2 with TemplateVersion

use of org.ovirt.engine.api.model.TemplateVersion in project ovirt-engine by oVirt.

the class BackendTemplatesResourceTest method populateVersion.

public static void populateVersion(Template t) {
    TemplateVersion templateVersion = new TemplateVersion();
    templateVersion.setVersionName(VERSION_NAME);
    templateVersion.setVersionNumber(2);
    Template base = new Template();
    base.setId(GUIDS[1].toString());
    templateVersion.setBaseTemplate(base);
    t.setVersion(templateVersion);
}
Also used : TemplateVersion(org.ovirt.engine.api.model.TemplateVersion) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Aggregations

Template (org.ovirt.engine.api.model.Template)2 TemplateVersion (org.ovirt.engine.api.model.TemplateVersion)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 Boot (org.ovirt.engine.api.model.Boot)1 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)1 OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)1