Search in sources :

Example 86 with VmStatic

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

the class BackendInstanceTypesResource method add.

@Override
public Response add(InstanceType instanceType) {
    validateParameters(instanceType, "name");
    VmStatic vmStatic = getMapper(InstanceType.class, VmStatic.class).map(instanceType, new VmStatic());
    VM vm = new VM();
    vm.setStaticData(vmStatic);
    String name = instanceType.getName();
    String description = "";
    if (instanceType.isSetDescription()) {
        description = instanceType.getDescription();
    }
    vm.setVmDescription(description);
    updateMaxMemoryIfUnspecified(instanceType, vm);
    AddVmTemplateParameters addInstanceTypeParameters = new AddVmTemplateParameters(vm, name, description);
    addInstanceTypeParameters.setTemplateType(VmEntityType.INSTANCE_TYPE);
    addInstanceTypeParameters.setVmTemplateId(null);
    addInstanceTypeParameters.setPublicUse(true);
    addInstanceTypeParameters.setConsoleEnabled(instanceType.getConsole() != null && instanceType.getConsole().isSetEnabled() ? instanceType.getConsole().isEnabled() : false);
    addInstanceTypeParameters.setVirtioScsiEnabled(instanceType.isSetVirtioScsi() && instanceType.getVirtioScsi().isSetEnabled() ? instanceType.getVirtioScsi().isEnabled() : null);
    if (instanceType.isSetSoundcardEnabled()) {
        addInstanceTypeParameters.setSoundDeviceEnabled(instanceType.isSoundcardEnabled());
    }
    DisplayHelper.setGraphicsToParams(instanceType.getDisplay(), addInstanceTypeParameters);
    Response response = performCreate(ActionType.AddVmTemplate, addInstanceTypeParameters, new QueryIdResolver<Guid>(QueryType.GetInstanceType, GetVmTemplateParameters.class));
    Template result = (Template) response.getEntity();
    if (result != null) {
        DisplayHelper.adjustDisplayData(this, result);
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) VM(org.ovirt.engine.core.common.businessentities.VM) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid) InstanceType(org.ovirt.engine.api.model.InstanceType) Template(org.ovirt.engine.api.model.Template)

Example 87 with VmStatic

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

the class VmMapperTest method testUpdateHostPinningPolicy.

@Test
public void testUpdateHostPinningPolicy() {
    final VmStatic vmTemplate = new VmStatic();
    vmTemplate.setDedicatedVmForVdsList(Guid.newGuid());
    final Vm vm = new Vm();
    vm.setPlacementPolicy(createPlacementPolicy(Guid.newGuid(), Guid.newGuid()));
    final VmStatic mappedVm = VmMapper.map(vm, vmTemplate);
    final List<Guid> hosts = new ArrayList<>();
    for (Host host : vm.getPlacementPolicy().getHosts().getHosts()) {
        hosts.add(Guid.createGuidFromString(host.getId()));
    }
    assertEquals(new HashSet(hosts), new HashSet(mappedVm.getDedicatedVmForVdsList()));
}
Also used : Vm(org.ovirt.engine.api.model.Vm) ArrayList(java.util.ArrayList) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Host(org.ovirt.engine.api.model.Host) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)87 Test (org.junit.Test)26 Guid (org.ovirt.engine.core.compat.Guid)15 VM (org.ovirt.engine.core.common.businessentities.VM)11 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)8 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)8 Label (org.ovirt.engine.core.common.businessentities.Label)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)4 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 Before (org.junit.Before)3