Example #1
0
        internal bool CanCreateBond()
        {
            List <PIF> pifs = BondedPIFs;

            bool will_disturb_primary    = NetworkingHelper.ContainsPrimaryManagement(pifs);
            bool will_disturb_secondary  = NetworkingHelper.ContainsSecondaryManagement(pifs);
            bool will_disturb_clustering = NetworkingHelper.ContainsClusteringPif(pifs);

            // It is not allowed to bond primary and secondary interfaces together.
            if (will_disturb_primary && will_disturb_secondary)
            {
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               Messages.BOND_CREATE_WILL_DISTURB_BOTH,
                               Messages.BOND_CREATE)))
                {
                    dlg.ShowDialog(this);
                }

                return(false);
            }

            // Only primary management interface.
            // In this case, clustering interface warning is hidden if it happens to be the management interface.
            if (will_disturb_primary)
            {
                Pool pool = Helpers.GetPool(Connection);
                if (pool != null && pool.ha_enabled)
                {
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Error,
                                   string.Format(Messages.BOND_CREATE_HA_ENABLED, pool.Name()),
                                   Messages.BOND_CREATE)))
                    {
                        dlg.ShowDialog(this);
                    }

                    return(false);
                }

                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.BOND_CREATE_WILL_DISTURB_PRIMARY, Messages.BOND_CREATE),
                           "BondConfigError",
                           new ThreeButtonDialog.TBDButton(Messages.BOND_CREATE_CONTINUE, DialogResult.OK),
                           ThreeButtonDialog.ButtonCancel))
                {
                    dialogResult = dlg.ShowDialog(this);
                }
                return(dialogResult == DialogResult.OK);
            }

            // Only secondary interface.
            // If there is clustering interface, shows clustering warning. Otherwise, shows secondary interface warning.
            if (will_disturb_secondary)
            {
                DialogResult dialogResult;
                if (will_disturb_clustering)
                {
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Warning,
                                   Messages.BOND_CREATE_WILL_DISTURB_CLUSTERING,
                                   Messages.BOND_CREATE),
                               ThreeButtonDialog.ButtonOK,
                               ThreeButtonDialog.ButtonCancel))
                    {
                        dialogResult = dlg.ShowDialog(this);
                    }
                }

                else
                {
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Warning,
                                   Messages.BOND_CREATE_WILL_DISTURB_SECONDARY,
                                   Messages.BOND_CREATE),
                               ThreeButtonDialog.ButtonOK,
                               ThreeButtonDialog.ButtonCancel))
                    {
                        dialogResult = dlg.ShowDialog(this);
                    }
                }

                return(dialogResult == DialogResult.OK);
            }

            return(true);
        }