use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method getVmWithNuma.
protected VM getVmWithNuma() {
VM vm = new VM();
String vmName = getModel().getName().getEntity();
if (vmName == null || vmName.isEmpty()) {
// $NON-NLS-1$
vmName = "new_vm";
}
vm.setName(vmName);
Integer nodeCount = getModel().getNumaNodeCount().getEntity();
vm.setvNumaNodeList(new ArrayList<>());
for (int i = 0; i < nodeCount; i++) {
VmNumaNode vmNumaNode = new VmNumaNode();
vmNumaNode.setIndex(i);
vm.getvNumaNodeList().add(vmNumaNode);
}
return vm;
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmMonitorModel method refresh.
private void refresh() {
if (getEntity() == null) {
return;
}
VM vm = (VM) getEntity();
AsyncDataProvider.getInstance().getVmById(new AsyncQuery<>(vm1 -> {
setCpuUsage(vm1.getUsageCpuPercent() == null ? 0 : vm1.getUsageCpuPercent());
setMemoryUsage(vm1.getUsageMemPercent() == null ? 0 : vm1.getUsageMemPercent());
setNetworkUsage(vm1.getUsageNetworkPercent() == null ? 0 : vm1.getUsageNetworkPercent());
}), vm.getId());
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmSnapshotListModel method buildVmOnNewTemplate.
protected static VM buildVmOnNewTemplate(UnitVmModel model, VM vm) {
VM resultVm = new VM();
resultVm.setId(vm.getId());
BuilderExecutor.build(model, resultVm.getStaticData(), new CommonUnitToVmBaseBuilder());
BuilderExecutor.build(vm.getStaticData(), resultVm.getStaticData(), new VmBaseToVmBaseForTemplateCompositeBaseBuilder());
return resultVm;
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmSnapshotListModel method updateActionAvailability.
public void updateActionAvailability() {
if (getItems() == null) {
// no need to update action availability
return;
}
VM vm = getEntity();
Snapshot snapshot = getSelectedItem();
List<VM> vmList = vm != null ? Collections.singletonList(vm) : Collections.emptyList();
boolean isVmDown = vm != null && vm.getStatus() == VMStatus.Down;
boolean isVmImageLocked = vm != null && vm.getStatus() == VMStatus.ImageLocked;
boolean isVmQualifiedForSnapshotMerge = vm != null && vm.getStatus().isQualifiedForSnapshotMerge();
boolean isPreviewing = getItems().stream().anyMatch(s -> s.getStatus() == SnapshotStatus.IN_PREVIEW);
boolean isLocked = getItems().stream().anyMatch(s -> s.getStatus() == SnapshotStatus.LOCKED);
boolean isSelected = snapshot != null && snapshot.getType() != SnapshotType.ACTIVE;
boolean isStateless = getItems().stream().anyMatch(s -> s.getType() == SnapshotType.STATELESS);
boolean isVmConfigurationBroken = snapshot != null && snapshot.isVmConfigurationBroken();
getCanSelectSnapshot().setEntity(!isPreviewing && !isLocked && !isStateless && ActionUtils.canExecute(vmList, VM.class, ActionType.CreateSnapshotForVm));
getNewCommand().setIsExecutionAllowed(!isPreviewing && !isLocked && !isVmImageLocked && !isStateless);
getPreviewCommand().setIsExecutionAllowed(isSelected && !isLocked && !isPreviewing && isVmDown && !isStateless);
getCustomPreviewCommand().setIsExecutionAllowed(getPreviewCommand().getIsExecutionAllowed());
getCommitCommand().setIsExecutionAllowed(isPreviewing && isVmDown && !isStateless);
getUndoCommand().setIsExecutionAllowed(isPreviewing && isVmDown && !isStateless);
getRemoveCommand().setIsExecutionAllowed(isSelected && !isLocked && !isPreviewing && !isStateless && isVmQualifiedForSnapshotMerge);
getCloneVmCommand().setIsExecutionAllowed(isSelected && !isLocked && !isPreviewing && !isVmImageLocked && !isStateless && !isVmConfigurationBroken);
getCloneTemplateCommand().setIsExecutionAllowed(isSelected && !isLocked && !isPreviewing && !isVmImageLocked && !isStateless && !isVmConfigurationBroken);
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmSnapshotListModel method updateIsMemorySnapshotSupported.
private void updateIsMemorySnapshotSupported(Object entity) {
if (entity == null) {
return;
}
VM vm = (VM) entity;
setMemorySnapshotSupported(AsyncDataProvider.getInstance().isMemorySnapshotSupported(vm));
}
Aggregations