use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmStaticDaoTest method initVmStaticsOrderedByMigrationSupport.
/**
* {@code initVmStaticsOrderedByAutoStartup(List)} is the first method in VMs order selection tests. The other init
* methods: <br>
* {@code initVmStaticsOrderedByPriority} and {@code initVmStaticsOrderedByAutoStartup} are relying on each other
* for creating an array of VM Static objects.<br>
* Each of the methods modifies the VM static array according to the column which is being tested, started from the
* least important column to the most.<br>
* That way prioritizing a preceded column should be reflected in the selection and therefore to validate the order
* is maintained.
*
* @return an array of VmStatics, in descending order according to: auto_startup, priority, MigrationSupport.<br>
* The MigrationSupport is the one being checked.<br>
*/
private VmStatic[] initVmStaticsOrderedByMigrationSupport(List<VmStatic> vmStatics) {
VmStatic[] vmStaticArray = new VmStatic[getEntitiesTotalCount()];
vmStaticArray = vmStatics.toArray(vmStaticArray);
// initialize the VMs with equal settings: non HA, priority 1 and MIGRATABLE
for (VmStatic element : vmStaticArray) {
element.setAutoStartup(false);
element.setPriority(1);
element.setMigrationSupport(MigrationSupport.MIGRATABLE);
}
// set higher migration support value for the first VM
vmStaticArray[0].setMigrationSupport(MigrationSupport.PINNED_TO_HOST);
vmStaticArray[1].setMigrationSupport(MigrationSupport.IMPLICITLY_NON_MIGRATABLE);
updateArrayOfVmStaticsInDb(vmStaticArray);
return vmStaticArray;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmDaoTest method createHostedEngineVm.
private void createHostedEngineVm(Guid id) {
VmStatic vmStatic = new VmStatic();
vmStatic.setId(id);
vmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI);
vmStatic.setName("HostedEngine");
vmStatic.setOrigin(OriginType.HOSTED_ENGINE);
vmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1);
getDbFacade().getVmStaticDao().save(vmStatic);
VmDynamic vmDynamic = new VmDynamic();
vmDynamic.setId(id);
getDbFacade().getVmDynamicDao().save(vmDynamic);
VmStatistics vmStatistics = new VmStatistics();
vmStatistics.setId(id);
getDbFacade().getVmStatisticsDao().save(vmStatistics);
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VdsDaoTest method setupHostedEngineTests.
private void setupHostedEngineTests(boolean isHostedEngineVm, int vmCount) {
// create the VmStatic instance
VmStatic vmStatic = new VmStatic();
vmStatic.setId(newVmId);
vmStatic.setOrigin(isHostedEngineVm ? OriginType.MANAGED_HOSTED_ENGINE : OriginType.RHEV);
dbFacade.getVmStaticDao().save(vmStatic);
// create the VmDynamic instance
VmDynamic vmDynamic = new VmDynamic();
vmDynamic.setId(newVmId);
vmDynamic.setStatus(VMStatus.Up);
vmDynamic.setRunOnVds(existingVds.getId());
dbFacade.getVmDynamicDao().save(vmDynamic);
// update the VDS instance
existingVds.setVmCount(vmCount);
dbFacade.getVdsDynamicDao().update(existingVds.getDynamicData());
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class DeactivateStorageDomainCommandTest method deactivateStorageDomainWithRunningVmWithLeaseFails.
@Test
public void deactivateStorageDomainWithRunningVmWithLeaseFails() {
VmStatic vm = new VmStatic();
vm.setName("myRunningVmWithLease");
mockDomain();
when(vmStaticDao.getAllRunningWithLeaseOnStorageDomain(domain.getId())).thenReturn(Collections.singletonList(vm));
ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.ERROR_CANNOT_DEACTIVATE_DOMAIN_WITH_RUNNING_VMS_WITH_LEASES);
assertTrue(cmd.getReturnValue().getValidationMessages().contains(String.format("$vmNames %s", vm.getName())));
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmMapper method map.
@Mapping(from = Vm.class, to = VmStatic.class)
public static VmStatic map(Vm vm, VmStatic template) {
VmStatic staticVm = template != null ? template : new VmStatic();
mapVmBaseModelToEntity(staticVm, vm);
if (!vm.isSetMemory() && staticVm.getMemSizeMb() == 0) {
// TODO: Get rid of this logic code when Backend supports default memory.
staticVm.setMemSizeMb(DEFAULT_MEMORY_SIZE);
}
if (vm.isSetTemplate()) {
if (vm.getTemplate().getId() != null) {
staticVm.setVmtGuid(GuidUtils.asGuid(vm.getTemplate().getId()));
}
// it will be handled by the backend.
if (vm.isSetUseLatestTemplateVersion()) {
staticVm.setUseLatestVersion(vm.isUseLatestTemplateVersion());
}
}
if (vm.isSetCpu()) {
if (vm.getCpu().isSetMode()) {
staticVm.setUseHostCpuFlags(vm.getCpu().getMode() == CpuMode.HOST_PASSTHROUGH);
}
if (vm.getCpu().isSetCpuTune()) {
staticVm.setCpuPinning(cpuTuneToString(vm.getCpu().getCpuTune()));
}
}
if (vm.isSetInitialization()) {
staticVm.setVmInit(InitializationMapper.map(vm.getInitialization(), staticVm.getVmInit()));
}
// if the Domain set via VmInit we ignore it
if (vm.isSetDomain() && vm.getDomain().isSetName()) {
if (staticVm.getVmInit() == null) {
staticVm.setVmInit(new VmInit());
}
// We don't want to override the domain if it set via the Initialization object
if (!vm.isSetInitialization() || !vm.getInitialization().isSetDomain()) {
staticVm.getVmInit().setDomain(vm.getDomain().getName());
}
}
if (vm.isSetNumaTuneMode()) {
staticVm.setNumaTuneMode(map(vm.getNumaTuneMode(), null));
}
if (vm.isSetExternalHostProvider()) {
String providerId = vm.getExternalHostProvider().getId();
staticVm.setProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
}
return staticVm;
}
Aggregations