Search in sources :

Example 26 with VM

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;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 27 with 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());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) GridTimer(org.ovirt.engine.ui.uicommonweb.models.GridTimer) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 28 with VM

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;
}
Also used : VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) VM(org.ovirt.engine.core.common.businessentities.VM) CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder)

Example 29 with VM

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);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 30 with VM

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));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM)

Aggregations

VM (org.ovirt.engine.core.common.businessentities.VM)591 Test (org.junit.Test)178 Guid (org.ovirt.engine.core.compat.Guid)150 ArrayList (java.util.ArrayList)130 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)82 HashMap (java.util.HashMap)69 List (java.util.List)65 VDS (org.ovirt.engine.core.common.businessentities.VDS)63 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)56 Map (java.util.Map)53 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)53 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)41 QueryType (org.ovirt.engine.core.common.queries.QueryType)36 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)33 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)32 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)32 Collectors (java.util.stream.Collectors)31 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)31