CP-32431: Add version check to the drag and drop commands

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2019-11-13 13:20:45 +00:00 committed by Konstantina Chremmou
parent c1dc88a203
commit aca8be2939
2 changed files with 14 additions and 25 deletions

View File

@ -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<VM>())
{
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;

View File

@ -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;