use of org.ovirt.engine.api.model.Configuration in project ovirt-engine by oVirt.
the class VmMapper method map.
public static Vm map(String data, ConfigurationType type, Vm vm) {
Initialization initialization = vm.getInitialization();
if (initialization == null) {
initialization = new Initialization();
vm.setInitialization(initialization);
}
Configuration configuration = initialization.getConfiguration();
if (configuration == null) {
configuration = new Configuration();
initialization.setConfiguration(configuration);
}
configuration.setData(data);
configuration.setType(type);
return vm;
}
use of org.ovirt.engine.api.model.Configuration in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method doTestBadAddFromConfigurationMissingParameters.
@Test
public void doTestBadAddFromConfigurationMissingParameters() throws Exception {
setUriInfo(setUpBasicUriExpectations());
Vm model = createModel(null);
model.setInitialization(new Initialization());
model.getInitialization().setConfiguration(new Configuration());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Vm", "add", "initialization.configuration.type", "initialization.configuration.data");
}
}
use of org.ovirt.engine.api.model.Configuration in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAddFromConfiguration.
@Test
public void testAddFromConfiguration() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetPayloadExpectations(1, 2);
setUpGetBallooningExpectations(1, 2);
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations(1, 2);
setUpGetConsoleExpectations(2);
setUpGetVmOvfExpectations(2);
setUpGetVirtioScsiExpectations(2);
setUpGetSoundcardExpectations(2);
setUpGetRngDeviceExpectations(2);
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);
setUpCreationExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "Vm", "ClusterId", "ImportAsNewEntity" }, new Object[] { returnedVM, Guid.createGuidFromString(model.getCluster().getId()), false }, true, true, GUIDS[2], QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, returnedVM);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
verifyModel((Vm) response.getEntity(), 2);
}
use of org.ovirt.engine.api.model.Configuration in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAddFromConfigurationWithRegenerateTrue.
@Test
public void testAddFromConfigurationWithRegenerateTrue() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetPayloadExpectations(1, 3);
setUpGetBallooningExpectations(1, 3);
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations(1, 3);
setUpGetConsoleExpectations(3);
setUpGetVmOvfExpectations(3);
setUpGetVirtioScsiExpectations(3);
setUpGetSoundcardExpectations(3);
setUpGetRngDeviceExpectations(3);
Vm model = createModel(null);
org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2);
model.setInitialization(new Initialization());
model.getInitialization().setRegenerateIds(Boolean.TRUE);
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);
Guid newId = GUIDS[3];
setUpCreationExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "Vm", "ClusterId", "ImportAsNewEntity" }, new Object[] { returnedVM, Guid.createGuidFromString(model.getCluster().getId()), true }, true, true, newId, QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { newId }, getEntityWithProvidedId(2, newId));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
Vm queriedVm = (Vm) response.getEntity();
assertEquals(newId.toString(), queriedVm.getId());
queriedVm.setId(GUIDS[2].toString());
verifyModel((Vm) response.getEntity(), 2);
}
use of org.ovirt.engine.api.model.Configuration in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAddFromConfigurationNamedCluster.
@Test
public void testAddFromConfigurationNamedCluster() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetPayloadExpectations(1, 2);
setUpGetBallooningExpectations(1, 2);
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations(1, 2);
setUpGetConsoleExpectations(2);
setUpGetVmOvfExpectations(2);
setUpGetVirtioScsiExpectations(2);
setUpGetSoundcardExpectations(2);
setUpGetRngDeviceExpectations(2);
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);
model.setCluster(new org.ovirt.engine.api.model.Cluster());
model.getCluster().setName(NAMES[1]);
setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[1] }, setUpCluster(GUIDS[1]));
setUpGetEntityExpectations(QueryType.GetVmFromConfiguration, GetVmFromConfigurationQueryParameters.class, new String[] { "VmConfiguration", "ConfigurationType" }, new Object[] { model.getInitialization().getConfiguration().getData(), ConfigurationType.OVF }, returnedVM);
setUpCreationExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "Vm", "ClusterId" }, new Object[] { returnedVM, GUIDS[1] }, true, true, GUIDS[2], QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, returnedVM);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
verifyModel((Vm) response.getEntity(), 2);
}
Aggregations