Search in sources :

Example 11 with InstanceType

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

the class BackendInstanceTypeResourceTest method testGetConsoleAware.

public void testGetConsoleAware(boolean allContent) throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(1);
    setUpGetBallooningExpectations();
    if (allContent) {
        List<String> populates = new ArrayList<>();
        populates.add("true");
        when(httpHeaders.getRequestHeader(BackendResource.POPULATE)).thenReturn(populates);
        setUpGetConsoleExpectations(0);
        setUpGetVirtioScsiExpectations(0);
        setUpGetSoundcardExpectations(0);
        setUpGetRngDeviceExpectations(0);
    }
    setUpGetGraphicsExpectations(1);
    InstanceType response = resource.get();
    verifyModel(response, 0);
    List<String> populateHeader = httpHeaders.getRequestHeader(BackendResource.POPULATE);
    boolean populated = populateHeader != null ? populateHeader.contains("true") : false;
    assertTrue(populated ? response.isSetConsole() : !response.isSetConsole());
}
Also used : ArrayList(java.util.ArrayList) InstanceType(org.ovirt.engine.api.model.InstanceType)

Example 12 with InstanceType

use of org.ovirt.engine.api.model.InstanceType 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 13 with InstanceType

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

the class BackendInstanceTypeResource method get.

@Override
public InstanceType get() {
    InstanceType instanceType = performGet(QueryType.GetInstanceType, new GetVmTemplateParameters(guid));
    DisplayHelper.adjustDisplayData(this, instanceType);
    return instanceType;
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) InstanceType(org.ovirt.engine.api.model.InstanceType)

Example 14 with InstanceType

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

the class BackendInstanceTypeWatchdogResource method addParents.

@Override
public Watchdog addParents(Watchdog watchdog) {
    InstanceType instanceType = new InstanceType();
    instanceType.setId(instanceTypeId.toString());
    watchdog.setTemplate(instanceType);
    return watchdog;
}
Also used : InstanceType(org.ovirt.engine.api.model.InstanceType)

Example 15 with InstanceType

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

the class BackendInstanceTypeWatchdogsResource method addParents.

@Override
public Watchdog addParents(Watchdog watchdog) {
    InstanceType instanceType = new InstanceType();
    instanceType.setId(instanteTypeId.toString());
    watchdog.setInstanceType(instanceType);
    return watchdog;
}
Also used : InstanceType(org.ovirt.engine.api.model.InstanceType)

Aggregations

InstanceType (org.ovirt.engine.api.model.InstanceType)15 Template (org.ovirt.engine.api.model.Template)3 GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 Test (org.junit.Test)2 TimeZone (org.ovirt.engine.api.model.TimeZone)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 ArrayList (java.util.ArrayList)1 Response (javax.ws.rs.core.Response)1 Boot (org.ovirt.engine.api.model.Boot)1 CustomProperties (org.ovirt.engine.api.model.CustomProperties)1 Display (org.ovirt.engine.api.model.Display)1 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)1 GuestOperatingSystem (org.ovirt.engine.api.model.GuestOperatingSystem)1 HighAvailability (org.ovirt.engine.api.model.HighAvailability)1 Host (org.ovirt.engine.api.model.Host)1 InstanceTypes (org.ovirt.engine.api.model.InstanceTypes)1 Kernel (org.ovirt.engine.api.model.Kernel)1 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)1