CA-265029: Disable "Move VM" on CBT enabled VM

Signed-off-by: Ji Jiang <ji.jiang@citrix.com>
This commit is contained in:
Ji Jiang 2017-09-12 16:49:02 +01:00
parent 48afa741b1
commit 23c903af09
5 changed files with 34 additions and 5 deletions

View File

@ -85,7 +85,7 @@ namespace XenAdmin.Commands
private bool CanBeMigrated(VDI vdi)
{
if (vdi == null || vdi.is_a_snapshot || vdi.Locked || vdi.IsHaType)
if (vdi == null || vdi.is_a_snapshot || vdi.Locked || vdi.IsHaType || vdi.cbt_enabled)
return false;
if(vdi.Connection.ResolveAll(vdi.VBDs).Count == 0)
@ -114,6 +114,8 @@ namespace XenAdmin.Commands
return Messages.CANNOT_MOVE_VDI_IN_USE;
if (vdi.IsHaType)
return Messages.CANNOT_MOVE_HA_VD;
if (vdi.cbt_enabled)
return Messages.CANNOT_MOVE_CBT_ENABLED_VDI;
if (vdi.IsMetadataForDR)
return Messages.CANNOT_MOVE_DR_VD;
if (vdi.GetVMs().Any(vm => !vm.IsRunning) && !Helpers.DundeeOrGreater(vdi.Connection))

View File

@ -80,9 +80,22 @@ namespace XenAdmin.Commands
protected override bool CanExecuteCore(SelectedItemCollection selection)
{
if (selection.AllItemsAre<VM>() && new CrossPoolMoveVMCommand(MainWindowCommandInterface, selection).CanExecute())
return true;
return selection.ContainsOneItemOfType<VM>() && selection.AtLeastOneXenObjectCan<VM>(CanExecute);
return selection.AllItemsAre<VM>(CBTDisabled) &&
(new CrossPoolMoveVMCommand(MainWindowCommandInterface, selection).CanExecute() ||
selection.ContainsOneItemOfType<VM>(CanExecute));
}
private bool CBTDisabled(VM vm)
{
if (vm == null)
return false;
foreach (var vbd in vm.Connection.ResolveAll(vm.VBDs))
{
var vdi = vm.Connection.Resolve(vbd.VDI);
if (vdi != null && vdi.cbt_enabled)
return false;
}
return true;
}
private static bool CanExecute(VM vm)

View File

@ -74,7 +74,7 @@ namespace XenAdmin.Commands
private bool CanBeMoved(VDI vdi)
{
if (vdi == null || vdi.is_a_snapshot || vdi.Locked || vdi.IsHaType)
if (vdi == null || vdi.is_a_snapshot || vdi.Locked || vdi.IsHaType || vdi.cbt_enabled)
return false;
if (vdi.VBDs.Count != 0)
return false;
@ -98,6 +98,8 @@ namespace XenAdmin.Commands
return Messages.CANNOT_MOVE_VDI_IN_USE;
if (vdi.IsHaType)
return Messages.CANNOT_MOVE_HA_VD;
if (vdi.cbt_enabled)
return Messages.CANNOT_MOVE_CBT_ENABLED_VDI;
if (vdi.IsMetadataForDR)
return Messages.CANNOT_MOVE_DR_VD;
if (vdi.VBDs.Count != 0)

View File

@ -6494,6 +6494,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to This virtual disk has CBT enabled. It cannot be moved to another storage repository..
/// </summary>
public static string CANNOT_MOVE_CBT_ENABLED_VDI {
get {
return ResourceManager.GetString("CANNOT_MOVE_CBT_ENABLED_VDI", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This virtual disk is used for DR. It cannot be moved to another storage repository..
/// </summary>

View File

@ -2363,6 +2363,9 @@ Deleting this bond will disrupt traffic through the secondary interface on the b
<data name="CANNOT_MIGRATE_VDI_NON_RUNNING_VM" xml:space="preserve">
<value>Cannot move this virtual disk because it is attached to a VM that is not running.</value>
</data>
<data name="CANNOT_MOVE_CBT_ENABLED_VDI" xml:space="preserve">
<value>This virtual disk has CBT enabled. It cannot be moved to another storage repository.</value>
</data>
<data name="CANNOT_MOVE_DR_VD" xml:space="preserve">
<value>This virtual disk is used for DR. It cannot be moved to another storage repository.</value>
</data>