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