use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class HotUnplugMemoryCommand method updateCurrentConfiguration.
private void updateCurrentConfiguration(int memoryAfterHotUnplugMb, int minMemoryAfterHotUnplugMb) {
final VmStatic updatedVmStatic = new VmStatic(getVm().getStaticData());
updatedVmStatic.setMemSizeMb(memoryAfterHotUnplugMb);
updatedVmStatic.setMinAllocatedMem(minMemoryAfterHotUnplugMb);
getVmManager().update(updatedVmStatic);
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class IconLoader method updateVmStaticTable.
private void updateVmStaticTable() {
for (VmStatic vmStatic : vmStaticDao.getAllWithoutIcon()) {
setIconsByOs(vmStatic);
vmStaticDao.update(vmStatic);
}
for (VmTemplate vmTemplate : vmTemplateDao.getAllWithoutIcon()) {
setIconsByOs(vmTemplate);
vmTemplateDao.update(vmTemplate);
}
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class HostedEngineHelper method init.
@PostConstruct
private void init() {
List<VmStatic> byName = vmStaticDao.getAllByName(Config.getValue(ConfigValues.HostedEngineVmName));
if (byName != null && !byName.isEmpty()) {
VmStatic vmStatic = byName.get(0);
hostedEngineVm = vmDao.get(vmStatic.getId());
vmHandler.updateDisksFromDb(hostedEngineVm);
}
initHostedEngineStorageDomain();
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class SnapshotsManager method updateVmFromConfiguration.
/**
* Update the given VM with the (static) data that is contained in the configuration. The {@link VM#getImages()}
* will contain the images that were read from the configuration.
*
* @param vm
* The VM to update.
* @param configuration
* The configuration to update from.
* @return In case of a problem reading the configuration, <code>false</code>. Otherwise, <code>true</code>.
*/
public boolean updateVmFromConfiguration(VM vm, String configuration) {
try {
VmStatic oldVmStatic = vm.getStaticData();
VM tempVM = new VM();
if (vm.getDynamicData() != null) {
tempVM.setDynamicData(vm.getDynamicData());
}
FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(tempVM);
ovfManager.importVm(configuration, tempVM, fullEntityOvfData);
for (DiskImage diskImage : fullEntityOvfData.getDiskImages()) {
DiskImage dbImage = diskImageDao.getSnapshotById(diskImage.getImageId());
if (dbImage != null) {
diskImage.setStorageIds(dbImage.getStorageIds());
}
}
new VMStaticOvfLogHandler(tempVM.getStaticData()).resetDefaults(oldVmStatic);
vm.setStaticData(tempVM.getStaticData());
IconUtils.preserveIcons(vm.getStaticData(), oldVmStatic);
vm.setImages((ArrayList<DiskImage>) fullEntityOvfData.getDiskImages());
vm.setInterfaces(fullEntityOvfData.getInterfaces());
// These fields are not saved in the OVF, so get them from the current VM.
vm.setIsoPath(oldVmStatic.getIsoPath());
vm.setCpuProfileId(oldVmStatic.getCpuProfileId());
vm.setClusterId(oldVmStatic.getClusterId());
// The VM configuration does not hold the vds group Id.
// It is necessary to fetch the vm static from the Db, in order to get this information
VmStatic vmStaticFromDb = vmStaticDao.get(vm.getId());
if (vmStaticFromDb != null) {
Cluster cluster = clusterDao.get(vmStaticFromDb.getClusterId());
if (cluster != null) {
vm.setStoragePoolId(cluster.getStoragePoolId());
vm.setClusterCompatibilityVersion(cluster.getCompatibilityVersion());
vm.setClusterName(cluster.getName());
vm.setClusterCpuName(cluster.getCpuName());
}
}
// if the required dedicated host is invalid -> use current VM dedicated host
if (!vmHandler.validateDedicatedVdsExistOnSameCluster(vm.getStaticData()).isValid()) {
vm.setDedicatedVmForVdsList(oldVmStatic.getDedicatedVmForVdsList());
}
vmHandler.updateMaxMemorySize(vm.getStaticData(), vm.getCompatibilityVersion());
vmHandler.autoSelectResumeBehavior(vm.getStaticData(), vm.getCompatibilityVersion());
validateQuota(vm);
return true;
} catch (OvfReaderException e) {
log.error("Failed to update VM from the configuration '{}': {}", configuration, e.getMessage());
log.debug("Exception", e);
return false;
}
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmHandlerTest method testValidUpdateOfEditableFieldOnDownVm.
@Test
public void testValidUpdateOfEditableFieldOnDownVm() {
// Given
VmStatic src = new VmStatic();
src.setClusterId(Guid.newGuid());
VmStatic dest = new VmStatic();
dest.setClusterId(Guid.newGuid());
// When
boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Down, false);
// Then
assertTrue("Update should be valid for different cluster IDs in the down state", updateIsValid);
}
Aggregations