Search in sources :

Example 6 with Configuration

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

the class BackendVmsResourceTest method testBadAddFromConfiguration.

private void testBadAddFromConfiguration(boolean valid, boolean success, String detail) throws Exception {
    Vm model = createModel(null);
    org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2);
    model.setInitialization(new Initialization());
    model.getInitialization().setConfiguration(new Configuration());
    model.getInitialization().getConfiguration().setData("asdasdasd");
    model.getInitialization().getConfiguration().setType(org.ovirt.engine.api.model.ConfigurationType.OVF);
    setUpGetEntityExpectations(QueryType.GetVmFromConfiguration, GetVmFromConfigurationQueryParameters.class, new String[] { "VmConfiguration", "ConfigurationType" }, new Object[] { model.getInitialization().getConfiguration().getData(), ConfigurationType.OVF }, returnedVM);
    setUriInfo(setUpActionExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "Vm", "ClusterId" }, new Object[] { returnedVM, Guid.createGuidFromString(model.getCluster().getId()) }, valid, success));
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : Initialization(org.ovirt.engine.api.model.Initialization) Configuration(org.ovirt.engine.api.model.Configuration) WebApplicationException(javax.ws.rs.WebApplicationException) Vm(org.ovirt.engine.api.model.Vm) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters)

Example 7 with Configuration

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

the class SnapshotMapper method map.

public static Snapshot map(String configuration, ConfigurationType type, Snapshot snapshot) {
    snapshot.setInitialization(new Initialization());
    snapshot.getInitialization().setConfiguration(new Configuration());
    snapshot.getInitialization().getConfiguration().setData(configuration);
    snapshot.getInitialization().getConfiguration().setType(type);
    return snapshot;
}
Also used : Initialization(org.ovirt.engine.api.model.Initialization) Configuration(org.ovirt.engine.api.model.Configuration)

Example 8 with Configuration

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

the class BackendVmsResource method importVmFromConfiguration.

public Response importVmFromConfiguration(Vm vm) {
    Initialization initialization = vm.getInitialization();
    Configuration config = initialization.getConfiguration();
    org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getEntity(org.ovirt.engine.core.common.businessentities.VM.class, QueryType.GetVmFromConfiguration, new GetVmFromConfigurationQueryParameters(VmMapper.map(config.getType(), null), config.getData().trim()), "");
    VmMapper.map(vm, vmConfiguration.getStaticData());
    Guid clusterId = namedCluster(vm) ? getCluster(vm).getId() : asGuid(vm.getCluster().getId());
    ImportVmFromConfParameters parameters = new ImportVmFromConfParameters();
    parameters.setVm(vmConfiguration);
    parameters.setClusterId(clusterId);
    if (initialization.isSetRegenerateIds()) {
        parameters.setImportAsNewEntity(initialization.isRegenerateIds());
    }
    return performCreate(ActionType.ImportVmFromConfiguration, parameters, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Also used : Initialization(org.ovirt.engine.api.model.Initialization) VM(org.ovirt.engine.core.common.businessentities.VM) GetVmFromConfigurationQueryParameters(org.ovirt.engine.core.common.queries.GetVmFromConfigurationQueryParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Configuration(org.ovirt.engine.api.model.Configuration) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

Configuration (org.ovirt.engine.api.model.Configuration)8 Initialization (org.ovirt.engine.api.model.Initialization)8 Vm (org.ovirt.engine.api.model.Vm)5 Test (org.junit.Test)4 Response (javax.ws.rs.core.Response)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 ImportVmFromConfParameters (org.ovirt.engine.core.common.action.ImportVmFromConfParameters)2 Guid (org.ovirt.engine.core.compat.Guid)2 VM (org.ovirt.engine.core.common.businessentities.VM)1 GetVmFromConfigurationQueryParameters (org.ovirt.engine.core.common.queries.GetVmFromConfigurationQueryParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1