CP-11292: Remove storage motion constraints: changes following code review

- added some null checks
- in the Cross pool migrate wizard, add Transfer network page for all cases except intra-pool move (which is performed via VMMoveAction)
- added comments to VMCrossPoolMigrateAction constructor to make it cleared what the copy parameter means

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2015-04-15 09:37:12 +01:00
parent 6d996c03a4
commit 830d8f6f60
2 changed files with 12 additions and 4 deletions

View File

@ -135,7 +135,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard
private bool IsIntraPoolMove(KeyValuePair<string, VmMapping> mapping)
{
VM vm = xenConnection.Resolve(new XenRef<VM>(mapping.Key));
return vm.CanBeMoved && IsIntraPoolMigration(mapping);
return vm != null && vm.CanBeMoved && IsIntraPoolMigration(mapping);
}
private bool IsCopyTemplate()
@ -146,7 +146,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard
private bool IsTemplate(KeyValuePair<string, VmMapping> mapping)
{
VM vm = xenConnection.Resolve(new XenRef<VM>(mapping.Key));
return vm.is_a_template;
return vm != null && vm.is_a_template;
}
@ -289,8 +289,8 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard
ConfigureRbacPage();
UpdateWindowTitle();
// add Transfer network page for all migration cases and for all other cross-pool operations (move, copy)
if (wizardMode == WizardMode.Migrate || !IsIntraPoolMove())
// add Transfer network page for all cases except intra-pool move (which is performed via VMMoveAction)
if (!IsIntraPoolMove())
AddAfterPage(m_pageStorage, m_pageTransferNetwork);
m_pageTransferNetwork.Connection = TargetConnection;

View File

@ -42,6 +42,14 @@ namespace XenAdmin.Actions.VMActions
private readonly XenAPI.Network transferNetwork;
private readonly bool copy;
/// <summary>
/// Cross pool migration action. Can also be used to copy a VM across pools, by setting the "copy" parameter to true
/// </summary>
/// <param name="vm">the VM to be migrated</param>
/// <param name="destinationHost">the destination host</param>
/// <param name="transferNetwork">the network used for the VM migration</param>
/// <param name="mapping">the storage and networking mappings</param>
/// <param name="copy">weather this should be a cross-pool copy (true) or migrate (false) operation</param>
public VMCrossPoolMigrateAction(VM vm, Host destinationHost, XenAPI.Network transferNetwork, VmMapping mapping, bool copy)
: base(vm.Connection, GetTitle(vm, destinationHost, copy))
{