Exemplo n.º 1
0
        private void ButtonChangeRoles_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();
            if (Helpers.FeatureForbidden(_connection, Host.RestrictRBAC))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_TRIAL,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(this);
                return;
            }


            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonChangeRoles.Enabled)
            {
                return;
            }

            List <Subject> selectedSubjects = new List <Subject>();

            foreach (DataGridViewRow r in GridViewSubjectList.SelectedRows)
            {
                AdSubjectRow selectedRow = (AdSubjectRow)r;
                // Should not be here, you can't change the root man!
                if (selectedRow.IsLocalRootRow)
                {
                    continue;
                }
                selectedSubjects.Add(selectedRow.subject);
            }

            using (var dialog = new RoleSelectionDialog(_connection, selectedSubjects.ToArray()))
                dialog.ShowDialog(this);
        }
Exemplo n.º 2
0
        public static void ShowUpsellDialog(IWin32Window parent)
        {
            UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPM : Messages.UPSELL_BLURB_CPM + Messages.UPSELL_BLURB_CPM_MORE,
                                                InvisibleMessages.UPSELL_LEARNMOREURL_CPM);

            dlg.ShowDialog(parent);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_WLB))
                    dlg.ShowDialog(Parent);
                return;
            }

            try
            {
                WorkloadReports WlbReportWin = new WorkloadReports(_reportFile, _run)
                {
                    Pool  = selection[0].PoolAncestor,
                    Hosts = selection[0].Connection.Cache.Hosts
                };

                MainWindowCommandInterface.ShowPerConnectionWizard(selection[0].Connection, WlbReportWin);
            }
            catch (Failure exn)
            {
                log.Error(exn, exn);
            }
        }
Exemplo n.º 4
0
        private void Execute(IXenConnection connection)
        {
            if (connection == null)
            {
                return;
            }

            Pool pool = Helpers.GetPool(connection);

            if (pool == null)
            {
                return;
            }

            if (Helpers.FeatureForbidden(pool, Host.RestrictHA))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_HA_MORE,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_HA))
                    dlg.ShowDialog(Parent);
            }
            else if (pool.ha_enabled)
            {
                // Show VM restart priority editor
                MainWindowCommandInterface.ShowPerConnectionWizard(connection, new EditVmHaPrioritiesDialog(pool));
            }
            else
            {
                // Show wizard to enable HA
                MainWindowCommandInterface.ShowPerConnectionWizard(connection, new HAWizard(pool));
            }
        }
Exemplo n.º 5
0
        private void ShowUpsell()
        {
            UpsellDialog upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_PERFORMANCE_MORE,
                                                         InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE);

            upsellDialog.ShowDialog(this);
        }
Exemplo n.º 6
0
        private void ButtonChangeRoles_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();
            if (Helpers.FeatureForbidden(_connection, Host.RestrictRBAC))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_RBAC : Messages.UPSELL_BLURB_RBAC + Messages.UPSELL_BLURB_TRIAL,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(this);
                return;
            }

            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonChangeRoles.Enabled)
            {
                return;
            }

            var selectedSubjects = GridViewSubjectList.SelectedRows.Cast <AdSubjectRow>().Where(r => !r.IsLocalRootRow).Select(r => r.subject).ToList();

            using (var dialog = new RoleSelectionDialog(_connection, selectedSubjects))
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    foreach (Subject s in selectedSubjects)
                    {
                        new AddRemoveRolesAction(_connection, s, dialog.SelectedRoles).RunAsync();
                    }
                }
        }
Exemplo n.º 7
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_WLB : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_WLB_MORE,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_WLB))
                    dlg.ShowDialog(Parent);
                return;
            }

            try
            {
                Dialogs.Wlb.DisableWLBDialog disableDialog = new XenAdmin.Dialogs.Wlb.DisableWLBDialog(string.Empty);
                DialogResult dr = disableDialog.ShowDialog(MainWindow.ActiveForm);

                if (dr == DialogResult.OK)
                {
                    Actions.Wlb.DisableWLBAction action = new Actions.Wlb.DisableWLBAction(selection[0].PoolAncestor, true);
                    action.Completed += Program.MainWindow.action_Completed;
                    action.RunAsync();
                    Program.MainWindow.UpdateToolbars();
                }
            }
            catch (Failure exn)
            {
                log.Error(exn, exn);
            }
        }
Exemplo n.º 8
0
        private static void ShowUpsellDialog(IWin32Window parent)
        {
            // Show upsell dialog
            UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_DR, InvisibleMessages.UPSELL_LEARNMOREURL_DR);

            dlg.ShowDialog(parent);
        }
Exemplo n.º 9
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var con = selection.GetConnectionOfFirstItem();

            if (Helpers.FeatureForbidden(con, Host.RestrictConversion))
            {
                var msg = HiddenFeatures.LinkLabelHidden
                    ? Messages.UPSELL_BLURB_CONVERSION
                    : Messages.UPSELL_BLURB_CONVERSION + Messages.UPSELL_BLURB_TRIAL;

                using (var dlg = new UpsellDialog(msg, InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(Parent);
            }
            else if (!con.Session.IsLocalSuperuser && !Registry.DontSudo && con.Session.Roles.All(r => r.name_label != Role.MR_ROLE_POOL_ADMIN))
            {
                var currentRoles = con.Session.Roles;
                currentRoles.Sort();

                var msg = string.Format(Messages.CONVERSION_RBAC_RESTRICTION, currentRoles[0].FriendlyName(),
                                        Role.FriendlyName(Role.MR_ROLE_POOL_ADMIN));

                using (var dlg = new ErrorDialog(msg))
                    dlg.ShowDialog(Parent);
            }
            else if (selection.First is VM vm && vm.IsConversionVM())
            {
                MainWindowCommandInterface.ShowPerConnectionWizard(con, new ConversionDialog(con, vm));
            }
Exemplo n.º 10
0
 public static void ShowUpsellDialog(IWin32Window parent)
 {
     // Show upsell dialog
     using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_TRIAL,
                                       InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
         dlg.ShowDialog(parent);
 }
Exemplo n.º 11
0
        private static void ShowUpsellDialog(IWin32Window parent)
        {
            // Show upsell dialog
            UpsellDialog dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_DR : Messages.UPSELL_BLURB_DR + Messages.UPSELL_BLURB_DR_MORE,
                                                InvisibleMessages.UPSELL_LEARNMOREURL_DR);

            dlg.ShowDialog(parent);
        }
Exemplo n.º 12
0
        private void Execute(IXenConnection connection)
        {
            if (connection == null)
            {
                return;
            }

            Pool pool = Helpers.GetPool(connection);

            if (pool == null)
            {
                return;
            }

            if (Helpers.FeatureForbidden(pool, Host.RestrictHA))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_TRIAL,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(Parent);
            }
            else if (pool.ha_enabled)
            {
                if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null))//empty gives true, which is correct
                {
                    log.ErrorFormat("Cannot resolve HA statefile VDI (pool {0} has {1} statefiles).",
                                    pool.Name(), pool.ha_statefiles.Length);

                    using (var dlg = new ErrorDialog(string.Format(Messages.HA_CONFIGURE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)),
                                                     ThreeButtonDialog.ButtonOK)
                    {
                        WindowTitle = Messages.CONFIGURE_HA
                    })
                    {
                        dlg.ShowDialog(Program.MainWindow);
                    }
                }
                else if (!Role.CanPerform(HA_PERMISSION_CHECKS, pool.Connection))
                {
                    var msg = string.Format(Messages.RBAC_HA_CONFIGURE_WARNING,
                                            Role.FriendlyCSVRoleList(Role.ValidRoleList(HA_PERMISSION_CHECKS, pool.Connection)),
                                            Role.FriendlyCSVRoleList(pool.Connection.Session.Roles));

                    using (var dlg = new ErrorDialog(msg))
                        dlg.ShowDialog(Parent);
                }
                else
                {
                    MainWindowCommandInterface.ShowPerConnectionWizard(connection, new EditVmHaPrioritiesDialog(pool));
                }
            }
            else
            {
                MainWindowCommandInterface.ShowPerConnectionWizard(connection, new HAWizard(pool));
            }
        }
Exemplo n.º 13
0
        private void Execute(IXenConnection connection)
        {
            if (connection == null)
            {
                return;
            }

            Pool pool = Helpers.GetPool(connection);

            if (pool == null)
            {
                return;
            }

            if (Helpers.FeatureForbidden(pool, Host.RestrictHA))
            {
                // Show upsell dialog
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_HA : Messages.UPSELL_BLURB_HA + Messages.UPSELL_BLURB_TRIAL,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(Parent);
            }
            else if (pool.ha_enabled)
            {
                if (pool.ha_statefiles.Any(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) != null))
                {
                    // Show VM restart priority editor
                    MainWindowCommandInterface.ShowPerConnectionWizard(connection, new EditVmHaPrioritiesDialog(pool));
                }
                else
                {
                    log.ErrorFormat("Cannot resolve HA statefile VDI (pool {0} has {1} statefiles).",
                                    pool.Name(), pool.ha_statefiles.Length);

                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Error,
                                   string.Format(Messages.HA_CONFIGURE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)),
                                   Messages.CONFIGURE_HA),
                               "HADisable",
                               ThreeButtonDialog.ButtonOK))
                    {
                        dlg.ShowDialog(Program.MainWindow);
                    }
                }
            }
            else
            {
                // Show wizard to enable HA
                MainWindowCommandInterface.ShowPerConnectionWizard(connection, new HAWizard(pool));
            }
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <VDI> vdis = selection.AsXenObjects <VDI>();

            bool featureForbidden = vdis.TrueForAll(vdi => Helpers.FeatureForbidden(vdi.Connection, Host.RestrictCrossPoolMigrate));

            if (featureForbidden)
            {
                string theText = HiddenFeatures.LinkLabelHidden
                    ? Messages.MIGRATE_VDI_UPSELL_BLURB
                    : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.UPSELL_BLURB_TRIAL;

                using (var dlg = new UpsellDialog(theText, InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(Parent);
            }
            else
            {
                new MigrateVirtualDiskDialog(selection.FirstAsXenObject.Connection, vdis).Show(Program.MainWindow);
            }
        }
Exemplo n.º 15
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
            {
                using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden
                        ? Messages.UPSELL_BLURB_WLB
                        : Messages.UPSELL_BLURB_WLB + Messages.UPSELL_BLURB_TRIAL,
                                                  InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
                    dlg.ShowDialog(Parent);
                return;
            }

            using (var dialog = new WarningDialog(Messages.WLB_DISCONNECT_SERVER,
                                                  ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                if (dialog.ShowDialog(Program.MainWindow) == DialogResult.Yes)
                {
                    var action = new Actions.Wlb.DisableWLBAction(selection[0].PoolAncestor, true);
                    action.Completed += Program.MainWindow.action_Completed;
                    action.RunAsync();
                }
        }
Exemplo n.º 16
0
        private void ShowUpsell()
        {
            UpsellDialog upsellDialog = new UpsellDialog(Messages.UPSELL_BLURB_PERFORMANCE, InvisibleMessages.UPSELL_LEARNMOREURL_PERFORMANCE);

            upsellDialog.ShowDialog(this);
        }
        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);
        }
Exemplo n.º 18
0
 public static void ShowUpsellDialog(IWin32Window parent)
 {
     using (var dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE,
                                       InvisibleMessages.UPSELL_LEARNMOREURL_CPM))
         dlg.ShowDialog(parent);
 }
Exemplo n.º 19
0
        public static void ShowUpsellDialog(IWin32Window parent)
        {
            UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_CPM, InvisibleMessages.UPSELL_LEARNMOREURL_CPM);

            dlg.ShowDialog(parent);
        }
Exemplo n.º 20
0
 public static void ShowUpsellDialog(IWin32Window parent)
 {
     using (var dlg = new UpsellDialog(VMGroup <T> .UpsellBlurb, VMGroup <T> .UpsellLearnMoreUrl))
         dlg.ShowDialog(parent);
 }
Exemplo n.º 21
0
 private void ShowUpsell()
 {
     using (var upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_PERFORMANCE : Messages.UPSELL_BLURB_PERFORMANCE + Messages.UPSELL_BLURB_TRIAL,
                                                InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL))
         upsellDialog.ShowDialog(this);
 }