Merge pull request #128 from GaborApatiNagy/xs64bit-fixed-CA-137047

CA-137047: StorageXenMotion not offering all hosts in drop down menu
This commit is contained in:
Mihaela Stoica 2014-07-14 18:04:58 +01:00
commit 231898fab0
3 changed files with 77 additions and 6 deletions

View File

@ -168,14 +168,23 @@ namespace XenAdmin.Commands
{
SelectedItemCollection selection = Command.GetSelection();
IXenConnection connection = selection[0].Connection;
VMOperationCommand commandForFirstMenuItem = new VMOperationHomeServerCommand(Command.MainWindowCommandInterface, selection, _operation, session);
VMOperationCommand cmdHome = new VMOperationHomeServerCommand(Command.MainWindowCommandInterface, selection, _operation, session);
Host affinityHost = connection.Resolve(((VM)Command.GetSelection()[0].XenObject).affinity);
VMOperationCommand cpmCmdHome = new CrossPoolMigrateToHomeCommand(Command.MainWindowCommandInterface, selection, affinityHost);
Program.Invoke(Program.MainWindow, delegate
{
VMOperationToolStripMenuSubItem firstItem = (VMOperationToolStripMenuSubItem)base.DropDownItems[0];
firstItem.Command = commandForFirstMenuItem;
var firstItem = (VMOperationToolStripMenuSubItem)base.DropDownItems[0];
bool oldMigrateToHomeCmdCanRun = cmdHome.CanExecute();
if (affinityHost == null || !oldMigrateToHomeCmdCanRun && !cpmCmdHome.CanExecute())
firstItem.Command = cmdHome;
else
firstItem.Command = oldMigrateToHomeCmdCanRun ? cmdHome : cpmCmdHome;
});
List<VMOperationToolStripMenuSubItem> dropDownItems = DropDownItems.Cast<VMOperationToolStripMenuSubItem>().ToList();
foreach (VMOperationToolStripMenuSubItem item in dropDownItems)
@ -184,10 +193,12 @@ namespace XenAdmin.Commands
{
Host host = (Host)item.Tag;
VMOperationCommand cmd = new VMOperationHostCommand(Command.MainWindowCommandInterface, selection, delegate { return host; }, host.Name.EscapeAmpersands(), _operation, session);
string hostNameText = host.Name.EscapeAmpersands();
VMOperationCommand cmd = new VMOperationHostCommand(Command.MainWindowCommandInterface, selection, delegate { return host; }, hostNameText, _operation, session);
VMOperationCommand cpmCmd = new CrossPoolMigrateCommand(Command.MainWindowCommandInterface, selection, host)
{
MenuText = host.Name.EscapeAmpersands()
MenuText = hostNameText
};
VMOperationToolStripMenuSubItem tempItem = item;

View File

@ -0,0 +1,59 @@
/* Copyright (c) Citrix Systems Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
using System.Collections.Generic;
using System.Drawing;
using XenAdmin.Properties;
using XenAPI;
namespace XenAdmin.Commands
{
/// <summary>
/// The command for the 'Home Server' subitem which is shown when WLB isn't enabled in the submenu for start-on, resume-on or migrate.
/// </summary>
internal class CrossPoolMigrateToHomeCommand : CrossPoolMigrateCommand
{
public CrossPoolMigrateToHomeCommand(IMainWindow mainWindow, IEnumerable<SelectedItem> selection, Host preSelectedHost)
: base(mainWindow, selection, preSelectedHost)
{
MenuText = Messages.HOME_SERVER_MENU_ITEM;
}
public override Image MenuImage
{
get
{
return Resources._000_ServerHome_h32bit_16;
}
}
}
}

View File

@ -123,6 +123,7 @@
<Compile Include="Commands\Controls\EditPropertiesToolStripMenuItem.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Commands\CrossPoolMigrateToHomeCommand.cs" />
<Compile Include="Commands\TrimSRCommand.cs" />
<Compile Include="Controls\AffinityPicker.cs">
<SubType>UserControl</SubType>