From aca8be2939457bbaeda13661d824ae6e2a9e9761 Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Wed, 13 Nov 2019 13:20:45 +0000 Subject: [PATCH] CP-32431: Add version check to the drag and drop commands Signed-off-by: Mihaela Stoica --- .../DragDropCrossPoolMoveHaltedVMCommand.cs | 21 +++++++------------ XenAdmin/Commands/DragDropMigrateVMCommand.cs | 18 +++++++--------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs b/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs index af868829c..e959d5641 100644 --- a/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs +++ b/XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs @@ -29,19 +29,13 @@ * SUCH DAMAGE. */ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using XenAdmin.Controls; using XenAPI; using XenAdmin.Core; -using System.Collections.ObjectModel; using System.Windows.Forms; -using XenAdmin.Actions; using XenAdmin.Dialogs; using System.Drawing; -using XenAdmin.Actions.VMActions; namespace XenAdmin.Commands @@ -66,7 +60,6 @@ namespace XenAdmin.Commands { foreach (VM draggedVM in GetDraggedItemsAsXenObjects()) { - Pool draggedVMPool = Helpers.GetPool(draggedVM.Connection); Host draggedVMHome = draggedVM.Home(); if(!LiveMigrateAllowedInVersion(targetHost, draggedVM)) @@ -81,12 +74,12 @@ namespace XenAdmin.Commands return Messages.MIGRATION_NOT_ALLOWED_NO_SHARED_STORAGE; } } + + if (Helpers.productVersionCompare(Helpers.HostProductVersion(targetHost), Helpers.HostProductVersion(draggedVMHome ?? Helpers.GetMaster(draggedVM.Connection))) < 0) + return Messages.OLDER_THAN_CURRENT_SERVER; if (targetHost != draggedVMHome && VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) - { - // target host does not offer some of the CPU features that the VM currently sees return Messages.MIGRATION_NOT_ALLOWED_CPU_FEATURES; - } } } } @@ -132,11 +125,11 @@ namespace XenAdmin.Commands if (draggedVM.allowed_operations == null || !draggedVM.allowed_operations.Contains(vm_operations.migrate_send)) return false; - if (VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) - { - // target host does not offer some of the CPU features that the VM currently sees + if (Helpers.productVersionCompare(Helpers.HostProductVersion(targetHost), Helpers.HostProductVersion(draggedVMHome ?? Helpers.GetMaster(draggedVM.Connection))) < 0) + return false; + + if (VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) return false; - } } return true; diff --git a/XenAdmin/Commands/DragDropMigrateVMCommand.cs b/XenAdmin/Commands/DragDropMigrateVMCommand.cs index e9ddb1a26..72a8c29cb 100644 --- a/XenAdmin/Commands/DragDropMigrateVMCommand.cs +++ b/XenAdmin/Commands/DragDropMigrateVMCommand.cs @@ -29,16 +29,12 @@ * SUCH DAMAGE. */ -using System; using System.Collections.Generic; using System.Linq; -using System.Text; using XenAdmin.Controls; using XenAPI; using XenAdmin.Core; -using System.Collections.ObjectModel; using System.Windows.Forms; -using XenAdmin.Actions; using XenAdmin.Dialogs; using System.Drawing; using XenAdmin.Actions.VMActions; @@ -91,11 +87,11 @@ namespace XenAdmin.Commands } } + if (Helpers.productVersionCompare(Helpers.HostProductVersion(targetHost), Helpers.HostProductVersion(draggedVMHome)) < 0) + return Messages.OLDER_THAN_CURRENT_SERVER; + if (targetHost != draggedVMHome && VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) - { - // target host does not offer some of the CPU features that the VM currently sees return Messages.MIGRATION_NOT_ALLOWED_CPU_FEATURES; - } } } } @@ -181,11 +177,11 @@ namespace XenAdmin.Commands return false; } - if (VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) - { - // target host does not offer some of the CPU features that the VM currently sees + if (Helpers.productVersionCompare(Helpers.HostProductVersion(targetHost), Helpers.HostProductVersion(draggedVMHome)) < 0) + return false; + + if (VMOperationHostCommand.VmCpuIncompatibleWithHost(targetHost, draggedVM)) return false; - } } return true;