Search in sources :

Example 36 with VmTemplate

use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.

the class InstanceTypeMapper method map.

@Mapping(from = InstanceType.class, to = org.ovirt.engine.core.common.businessentities.InstanceType.class)
public static org.ovirt.engine.core.common.businessentities.InstanceType map(InstanceType model, org.ovirt.engine.core.common.businessentities.InstanceType incoming) {
    VmTemplate entity = incoming != null ? (VmTemplate) incoming : new VmTemplate();
    mapCommonModelToEntity(entity, model);
    return entity;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 37 with VmTemplate

use of org.ovirt.engine.core.common.businessentities.VmTemplate 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 38 with VmTemplate

use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.

the class AddGraphicsAndVideoDevicesCommand method setTemplateToNonHeadlessMode.

private void setTemplateToNonHeadlessMode() {
    VmTemplate vmTemplate = vmTemplateDao.get(getVmBaseId());
    if (vmTemplate == null) {
        return;
    }
    if (vmTemplate.getDefaultDisplayType() == DisplayType.none) {
        vmTemplate.setDefaultDisplayType(DisplayType.qxl);
        vmTemplateDao.update(vmTemplate);
    }
    vmDeviceUtils.addVideoDevicesOnlyIfNoVideoDeviceExists(vmTemplate);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 39 with VmTemplate

use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.

the class EntityDaoImplTest method testGetEntityNameByIdAndTypeForVmTemplate.

@Test
public void testGetEntityNameByIdAndTypeForVmTemplate() {
    VmTemplate vmTemplate = vmTemplateDao.get(VM_TEMPLATE_ID);
    assertNotNull(vmTemplate);
    String name = vmTemplate.getName();
    assertEquals(name, underTest.getEntityNameByIdAndType(VM_TEMPLATE_ID, VdcObjectType.VmTemplate));
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 40 with VmTemplate

use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.

the class AuditLogableBaseTest method getVmTemplateWithVm.

@Test
public void getVmTemplateWithVm() {
    b.setVmTemplate(null);
    b.setVmTemplateId(null);
    final VM vm = new VM();
    vm.setVmtGuid(GUID);
    b.setVm(vm);
    final VmTemplate t = b.getVmTemplate();
    assertNotNull(t);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Aggregations

VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)149 ArrayList (java.util.ArrayList)42 Guid (org.ovirt.engine.core.compat.Guid)40 Test (org.junit.Test)30 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)23 HashMap (java.util.HashMap)22 List (java.util.List)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)16 Map (java.util.Map)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)13 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)9 Collection (java.util.Collection)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)8