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));
}
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());
}
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;
}
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));
}
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;
}
Aggregations