Search in sources :

Example 56 with Template

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

the class BackendVmPoolsResourceTest method getModel.

private VmPool getModel(int index) {
    VmPool model = new VmPool();
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    model.setId(GUIDS[index].toString());
    model.setCluster(new Cluster());
    model.getCluster().setId(GUIDS[2].toString());
    model.setTemplate(new Template());
    model.getTemplate().setId(GUIDS[1].toString());
    return model;
}
Also used : VmPool(org.ovirt.engine.api.model.VmPool) Cluster(org.ovirt.engine.api.model.Cluster) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 57 with Template

use of org.ovirt.engine.api.model.Template 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)

Aggregations

Template (org.ovirt.engine.api.model.Template)57 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)32 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)16 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)12 Vm (org.ovirt.engine.api.model.Vm)11 WebApplicationException (javax.ws.rs.WebApplicationException)6 VmPool (org.ovirt.engine.api.model.VmPool)4 Cluster (org.ovirt.engine.api.model.Cluster)3 InstanceType (org.ovirt.engine.api.model.InstanceType)3 TimeZone (org.ovirt.engine.api.model.TimeZone)3 GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)3 ArrayList (java.util.ArrayList)2 Boot (org.ovirt.engine.api.model.Boot)2 Host (org.ovirt.engine.api.model.Host)2 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Tag (org.ovirt.engine.api.model.Tag)2 TemplateVersion (org.ovirt.engine.api.model.TemplateVersion)2 Templates (org.ovirt.engine.api.model.Templates)2