Merge pull request #910 from MihaelaStoica/CA-204212

CA-204212: XenCenter doesn't warn on creating a vif with duplicate ma…
This commit is contained in:
Gabor Apati-Nagy 2016-03-23 14:11:19 +00:00
commit d9f5733c78

View File

@ -40,6 +40,7 @@ using XenAdmin.Network;
using XenAPI;
using XenAdmin.Core;
using System.Collections;
using System.Linq;
namespace XenAdmin.Dialogs
@ -360,21 +361,25 @@ namespace XenAdmin.Dialogs
/// <summary>
/// Determine if the MAC is accetable. It may not be if
/// other VIFs on the same Network have the same MAC address as entered
/// other VIFs have the same MAC address as entered
/// </summary>
/// <returns>If the MAC address entered is acceptable</returns>
private bool MACAddressIsAcceptable()
{
foreach (VIF vif in connection.ResolveAll( SelectedNetwork.VIFs ) )
foreach (var xenConnection in ConnectionsManager.XenConnectionsCopy.Where(c => c.IsConnected))
{
if ( vif != ExistingVif && vif.MAC == SelectedMac )
foreach (VIF vif in xenConnection.Cache.VIFs)
{
var vm = xenConnection.Resolve(vif.VM);
if (vif != ExistingVif && vif.MAC == SelectedMac && vm != null && vm.is_a_real_vm)
{
DialogResult result = MacAddressDuplicationWarningDialog(
SelectedMac,
connection.Resolve(vif.VM).Name ).ShowDialog(Program.MainWindow);
vm.NameWithLocation).ShowDialog(Program.MainWindow);
return (result == DialogResult.Yes);
}
}
}
return true;
}