internal void Refresh() { reason = PoolJoinRules.CanJoinPool(Connection, masterConnection, true, true, true); this.Description = PoolJoinRules.ReasonMessage(reason); this.Enabled = (reason == PoolJoinRules.Reason.Allowed); this.CheckedIfdisabled = (reason == PoolJoinRules.Reason.WillBeMaster); if (reason == PoolJoinRules.Reason.WillBeMaster) { this.State = CheckState.Checked; } }
protected override void ExecuteCore(SelectedItemCollection selection) { Dictionary <SelectedItem, string> reasons = new Dictionary <SelectedItem, string>(); foreach (Host host in _hosts) { PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(host.Connection, _pool.Connection, true, true, true); if (reason != PoolJoinRules.Reason.Allowed) { reasons[new SelectedItem(host)] = PoolJoinRules.ReasonMessage(reason); } } if (reasons.Count > 0) { string title = Messages.ERROR_DIALOG_ADD_TO_POOL_TITLE; string text = string.Format(Messages.ERROR_DIALOG_ADD_TO_POOL_TEXT, Helpers.GetName(_pool).Ellipsise(500)); new CommandErrorDialog(title, text, reasons).ShowDialog(Parent); return; } if (_confirm && !ShowConfirmationDialog()) { // Bail out if the user doesn't want to continue. return; } if (!Helpers.IsConnected(_pool)) { string message = _hosts.Count == 1 ? string.Format(Messages.ADD_HOST_TO_POOL_DISCONNECTED_POOL, Helpers.GetName(_hosts[0]).Ellipsise(500), Helpers.GetName(_pool).Ellipsise(500)) : string.Format(Messages.ADD_HOST_TO_POOL_DISCONNECTED_POOL_MULTIPLE, Helpers.GetName(_pool).Ellipsise(500)); new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, message, Messages.XENCENTER)).ShowDialog(Parent); return; } // Check supp packs and warn List <string> badSuppPacks = PoolJoinRules.HomogeneousSuppPacksDiffering(_hosts, _pool); if (!HelpersGUI.GetPermissionFor(badSuppPacks, sp => true, Messages.ADD_HOST_TO_POOL_SUPP_PACK, Messages.ADD_HOST_TO_POOL_SUPP_PACKS, false, "PoolJoinSuppPacks")) { return; } // Are there any hosts which are forbidden from masking their CPUs for licensing reasons? // If so, we need to show upsell. Host master = Helpers.GetMaster(_pool); if (null != _hosts.Find(host => !PoolJoinRules.CompatibleCPUs(host, master, false) && Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) && !PoolJoinRules.FreeHostPaidMaster(host, master, false))) // in this case we can upgrade the license and then mask the CPU { UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE, InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING); dlg.ShowDialog(Parent); return; } // Get permission for any fix-ups: 1) Licensing free hosts; 2) CPU masking 3) Ad configuration 4) CPU feature levelling (Dundee or higher only) // (We already know that these things are fixable because we have been through CanJoinPool() above). if (!HelpersGUI.GetPermissionFor(_hosts, host => PoolJoinRules.FreeHostPaidMaster(host, master, false), Messages.ADD_HOST_TO_POOL_LICENSE_MESSAGE, Messages.ADD_HOST_TO_POOL_LICENSE_MESSAGE_MULTIPLE, true, "PoolJoinRelicensing") || !HelpersGUI.GetPermissionFor(_hosts, host => !PoolJoinRules.CompatibleCPUs(host, master, false), Messages.ADD_HOST_TO_POOL_CPU_MASKING_MESSAGE, Messages.ADD_HOST_TO_POOL_CPU_MASKING_MESSAGE_MULTIPLE, true, "PoolJoinCpuMasking") || !HelpersGUI.GetPermissionFor(_hosts, host => !PoolJoinRules.CompatibleAdConfig(host, master, false), Messages.ADD_HOST_TO_POOL_AD_MESSAGE, Messages.ADD_HOST_TO_POOL_AD_MESSAGE_MULTIPLE, true, "PoolJoinAdConfiguring") || !HelpersGUI.GetPermissionForCpuFeatureLevelling(_hosts, _pool)) { return; } MainWindowCommandInterface.SelectObjectInTree(_pool); List <AsyncAction> actions = new List <AsyncAction>(); foreach (Host host in _hosts) { string opaque_ref = host.opaque_ref; AddHostToPoolAction action = new AddHostToPoolAction(_pool, host, GetAdPrompt, NtolDialog, ApplyLicenseEditionCommand.ShowLicensingFailureDialog); action.Completed += s => Program.ShowObject(opaque_ref); actions.Add(action); // hide connection. If the action fails, re-show it. Program.HideObject(opaque_ref); } RunMultipleActions(actions, string.Format(Messages.ADDING_SERVERS_TO_POOL, _pool.Name), Messages.POOLCREATE_ADDING, Messages.POOLCREATE_ADDED, true); }