use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class VmAnalyzer method handOverVm.
private void handOverVm() {
Guid dstHostId = dbVm.getMigratingToVds();
// when the destination VDS is NonResponsive put the VM to Unknown like the rest of its VMs
VMStatus newVmStatus = isVdsNonResponsive(dstHostId) ? VMStatus.Unknown : VMStatus.MigratingTo;
dbVm.setRunOnVds(dstHostId);
logVmHandOver(dstHostId, newVmStatus);
resourceManager.internalSetVmStatus(dbVm, newVmStatus);
saveDynamic(dbVm);
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class RunVmCommand method createVm.
protected VMStatus createVm() {
updateCdPath();
if (!StringUtils.isEmpty(getParameters().getFloppyPath())) {
getVm().setFloppyPath(cdPathWindowsToLinux(getParameters().getFloppyPath()));
}
// Set path for initrd and kernel image.
if (!StringUtils.isEmpty(getVm().getInitrdUrl())) {
getVm().setInitrdUrl(getIsoPrefixFilePath(getVm().getInitrdUrl()));
}
if (!StringUtils.isEmpty(getVm().getKernelUrl())) {
getVm().setKernelUrl(getIsoPrefixFilePath(getVm().getKernelUrl()));
}
initParametersForExternalNetworks(getVds(), false);
VMStatus vmStatus = (VMStatus) getVdsBroker().runAsyncVdsCommand(VDSCommandType.Create, buildCreateVmParameters(), this).getReturnValue();
// Don't use the memory from the active snapshot anymore if there's a chance that disks were changed
memoryFromSnapshotUsed = vmStatus.isRunning() || vmStatus == VMStatus.RestoringState;
// After VM was create (or not), we can remove the quota vds group memory.
return vmStatus;
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class VmHandler method init.
/**
* Initialize list containers, for identity and permission check. The initialization should be executed
* before calling ObjectIdentityChecker.
*
* @see Backend#initHandlers
*/
@PostConstruct
public void init() {
Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VM.class, VmStatic.class, VmDynamic.class, VmManagementParametersBase.class };
updateVmsStatic = new ObjectIdentityChecker(VmHandler.class, Arrays.asList(inspectedClassNames));
for (Pair<EditableDeviceOnVmStatusField, Field> pair : BaseHandler.extractAnnotatedFields(EditableDeviceOnVmStatusField.class, inspectedClassNames)) {
updateVmsStatic.addField(Arrays.asList(pair.getFirst().statuses()), pair.getSecond().getName());
}
for (Pair<TransientField, Field> pair : BaseHandler.extractAnnotatedFields(TransientField.class, inspectedClassNames)) {
updateVmsStatic.addTransientFields(pair.getSecond().getName());
}
for (Pair<EditableVmField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmField.class, inspectedClassNames)) {
EditableVmField annotation = pair.getFirst();
List<VMStatus> statusList = Arrays.asList(annotation.onStatuses());
String fieldName = pair.getSecond().getName();
if (statusList.isEmpty()) {
updateVmsStatic.addPermittedFields(fieldName);
} else {
updateVmsStatic.addField(statusList, fieldName);
if (!annotation.hotSettableOnStatus().getStates().isEmpty()) {
updateVmsStatic.addHotsetField(fieldName, annotation.hotSettableOnStatus().getStates());
}
}
if (annotation.onHostedEngine()) {
updateVmsStatic.addHostedEngineFields(fieldName);
}
}
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class VmOperationCommandBase method getRunningOnVds.
/**
* This method checks if the virtual machine is running in some host. It also
* has the side effect of storing the reference to the host inside the command.
*
* @return <code>true</code> if the virtual machine is running in a any host,
* <code>false</code> otherwise
*/
protected boolean getRunningOnVds() {
// We will need the virtual machine and the status, so it is worth saving references:
final VM vm = getVm();
final VMStatus status = vm.getStatus();
// there is no need to find the id of the host:
if (!status.isRunningOrPaused() && status != VMStatus.NotResponding) {
return false;
}
// Find the id of the host where the machine is running:
Guid hostId = vm.getRunOnVds();
if (hostId == null) {
log.warn("Strange, according to the status '{}' virtual machine '{}' should be running in a host but it isn't.", status, vm.getId());
return false;
}
// Find the reference to the host using the id that we got before (setting
// the host to null is required in order to make sure that the host is
// reloaded from the database):
setVdsId(new Guid(hostId.toString()));
setVds(null);
if (getVds() == null) {
log.warn("Strange, virtual machine '{}' is is running in host '{}' but that host can't be found.", vm.getId(), hostId);
return false;
}
// a host:
return true;
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class VmTemplateHandler method init.
/**
* Initialize list containers, for identity and permission check. The initialization should be executed
* before calling ObjectIdentityChecker.
*
* @see Backend#initHandlers()
*/
@PostConstruct
public void init() {
final Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VmTemplate.class };
updateVmTemplate = new ObjectIdentityChecker(VmTemplateHandler.class);
for (Pair<EditableVmTemplateField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmTemplateField.class, inspectedClassNames)) {
String fieldName = pair.getSecond().getName();
updateVmTemplate.addPermittedFields(fieldName);
}
for (Pair<EditableVmField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmField.class, inspectedClassNames)) {
EditableVmField annotation = pair.getFirst();
List<VMStatus> statusList = Arrays.asList(annotation.onStatuses());
String fieldName = pair.getSecond().getName();
if (statusList.isEmpty()) {
updateVmTemplate.addPermittedFields(fieldName);
}
}
}
Aggregations