Search in sources :

Example 86 with VmTemplate

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

the class VnicProfileValidatorTest method vnicProfileInUseByTemplates.

@Test
public void vnicProfileInUseByTemplates() throws Exception {
    VmTemplate template = mock(VmTemplate.class);
    when(template.getName()).thenReturn(NAMEABLE_NAME);
    vnicProfileNotUsedByTemplatesTest(failsWithVnicProfileInUse(), Collections.singletonList(template));
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 87 with VmTemplate

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

the class OvfManagerTest method testTemplateOvfCreation.

@Test
public void testTemplateOvfCreation() throws Exception {
    VmTemplate template = createVmTemplate();
    String xml = manager.exportTemplate(new FullEntityOvfData(template), Version.v3_6);
    assertNotNull(xml);
    final VmTemplate newtemplate = new VmTemplate();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newtemplate);
    manager.importTemplate(xml, fullEntityOvfData);
    assertEquals("imported template is different than expected", newtemplate, template);
    assertEquals("imported db generation is different than expected", template.getDbGeneration(), newtemplate.getDbGeneration());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) Test(org.junit.Test)

Example 88 with VmTemplate

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

the class OvfManagerTest method createVmTemplate.

private static VmTemplate createVmTemplate() {
    VmTemplate template = new VmTemplate();
    template.setName("test-template");
    template.setOrigin(OriginType.OVIRT);
    template.setId(Guid.newGuid());
    template.setDescription("test-description");
    template.setDbGeneration(2L);
    template.setClusterArch(ArchitectureType.x86_64);
    template.setOsId(EXISTING_OS_ID);
    return template;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 89 with VmTemplate

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

the class BackendVmPoolsResource method add.

@Override
public Response add(VmPool pool) {
    validateParameters(pool, "name", "template.id|name", "cluster.id|name");
    Cluster cluster = getCluster(pool);
    pool.getCluster().setId(cluster.getId().toString());
    VmTemplate template = getVmTemplate(pool);
    if (namedTemplate(pool)) {
        pool.getTemplate().setId(template.getId().toString());
    }
    org.ovirt.engine.core.common.businessentities.VmPool entity = map(pool);
    VM vm = mapToVM(pool, template, cluster);
    int size = pool.isSetSize() ? pool.getSize() : 1;
    AddVmPoolParameters params = new AddVmPoolParameters(entity, vm, size);
    params.setConsoleEnabled(pool.isSetVm() && pool.getVm().isSetConsole() && pool.getVm().getConsole().isSetEnabled() ? pool.getVm().getConsole().isEnabled() : !getConsoleDevicesForEntity(template.getId()).isEmpty());
    params.setVirtioScsiEnabled(!VmHelper.getVirtioScsiControllersForEntity(this, template.getId()).isEmpty());
    params.setSoundDeviceEnabled(pool.isSetSoundcardEnabled() ? pool.isSoundcardEnabled() : !VmHelper.getSoundDevicesForEntity(this, template.getId()).isEmpty());
    params.setRngDevice(pool.isSetVm() && pool.getVm().isSetRngDevice() ? RngDeviceMapper.map(pool.getVm().getRngDevice(), null) : params.getRngDevice());
    boolean balloonEnabled = pool.isSetVm() && pool.getVm().isSetMemoryPolicy() && pool.getVm().getMemoryPolicy().isSetBallooning() && pool.getVm().getMemoryPolicy().isBallooning();
    params.setBalloonEnabled(balloonEnabled);
    params.getVmStaticData().setCustomProperties(pool.isSetVm() && pool.getVm().isSetCustomProperties() ? CustomPropertiesParser.parse(pool.getVm().getCustomProperties().getCustomProperties()) : params.getVmStaticData().getCustomProperties());
    return performCreate(ActionType.AddVmPool, params, new QueryIdResolver<Guid>(QueryType.GetVmPoolById, IdQueryParameters.class));
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) AddVmPoolParameters(org.ovirt.engine.core.common.action.AddVmPoolParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 90 with VmTemplate

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

the class BackendExportDomainDisksResourceTest method getVmTemplateEntity.

protected VmTemplate getVmTemplateEntity(int index) {
    VmTemplate vm = setUpEntityExpectations(mock(VmTemplate.class), index);
    when(vm.getDiskTemplateMap()).thenReturn(getDiskMap());
    return vm;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

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