Пример #1
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.AllItemsAre <GroupingTag>(IsValid) && selection.Count > 1);
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Command"/> class.
 /// </summary>
 /// <param name="mainWindow">The application main window.</param>
 /// <param name="selection">The selection context for the Command.</param>
 protected Command(IMainWindow mainWindow, IEnumerable <SelectedItem> selection)
     : this(mainWindow)
 {
     Util.ThrowIfParameterNull(selection, "selection");
     _selection = new SelectedItemCollection(selection);
 }
Пример #3
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     return(selection.AllItemsAre <Host>() && selection.AtLeastOneXenObjectCan <Host>(CanExecute));
 }
Пример #4
0
        protected sealed override void ExecuteCore(SelectedItemCollection selection)
        {
            //It only supports one item selected for now
            Trace.Assert(selection.Count == 1);

            XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject;
            List <PIF>     pifs    = network.Connection.ResolveAll(network.PIFs);

            if (pifs.Count == 0)
            {
                // Should never happen as long as the caller is enabling the button correctly, but
                // it's possible in a tiny window across disconnecting.
                log.Error("Network has no PIFs");
                return;
            }

            // We just want one, so that we can name it.
            PIF pif = pifs[0];

            string msg = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name);

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

            if (will_disturb_primary)
            {
                Pool pool = Helpers.GetPool(network.Connection);
                if (pool != null && pool.ha_enabled)
                {
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Error,
                                   string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name),
                                   Messages.DELETE_BOND)))
                    {
                        dlg.ShowDialog(Parent);
                    }
                    return;
                }

                string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg);

                DialogResult result;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND),
                           "NetworkingConfigWarning",
                           new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK),
                           ThreeButtonDialog.ButtonCancel))
                {
                    result = dlg.ShowDialog(Parent);
                }
                if (DialogResult.OK != result)
                {
                    return;
                }
            }
            else if (will_disturb_secondary)
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER),
                           ThreeButtonDialog.ButtonOK,
                           ThreeButtonDialog.ButtonCancel))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (DialogResult.OK != dialogResult)
                {
                    return;
                }
            }
            else
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER),
                           new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                           ThreeButtonDialog.ButtonCancel))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (DialogResult.OK != dialogResult)
                {
                    return;
                }
            }

            // The UI shouldn't offer deleting a bond in this case, but let's make sure we've
            // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436).
            Bond bond = pif.BondMasterOf;

            if (bond != null)
            {
                new Actions.DestroyBondAction(bond).RunAsync();
            }
        }
Пример #5
0
 /// <summary>
 /// Executes this Command.
 /// </summary>
 /// <param name="selection">The selection the Command should operate on.</param>
 protected virtual void ExecuteCore(SelectedItemCollection selection)
 {
 }
Пример #6
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     return(new ShutDownVMCommand(MainWindowCommandInterface, selection).CanExecute() || new ShutDownHostCommand(MainWindowCommandInterface, selection).CanExecute());
 }
Пример #7
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     MainWindowCommandInterface.ShowForm(typeof(RollingUpgradeWizard));
 }
Пример #8
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.Count > 1 && selection.AllItemsAre <SR>());
 }
Пример #9
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.Count == 1 && selection[0].XenObject is VDI);
 }
Пример #10
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new DisconnectHostsAndPoolsCommand(mainWindow, selection), true);
     items.AddIfEnabled(new ReconnectHostCommand(mainWindow, selection), true);
     items.AddIfEnabled(new EditTagsCommand(mainWindow, selection));
 }
Пример #11
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new DisconnectPoolCommand(mainWindow, selection), true);
     items.AddIfEnabled(new EditTagsCommand(mainWindow, selection));
     items.AddPluginItems(PluginContextMenu.pool, selection);
 }
Пример #12
0
 public abstract bool IsValid(SelectedItemCollection selection);
Пример #13
0
 public abstract void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items);
Пример #14
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.AllItemsAre <DockerContainer>());
 }
Пример #15
0
        protected sealed override void ExecuteCore(SelectedItemCollection selection)
        {
            //It only supports one item selected for now
            Trace.Assert(selection.Count == 1);

            XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject;
            List <PIF>     pifs    = network.Connection.ResolveAll(network.PIFs);

            if (pifs.Count == 0)
            {
                // Should never happen as long as the caller is enabling the button correctly, but
                // it's possible in a tiny window across disconnecting.
                log.Error("Network has no PIFs");
                return;
            }

            // We just want one, so that we can name it.
            PIF pif = pifs[0];

            string new_name;
            string msg;

            if (network != null && !Helpers.BostonOrGreater(network.Connection) && network.Connection.ResolveAll(network.VIFs).Count > 0)
            {
                // We have a live pre-Boston network.  Tell the user that we're going to rename it.
                new_name = Helpers.MakeUniqueName(Messages.RENAMED_BOND, GetAllNetworkNames(network.Connection));
                msg      = string.Format(Messages.DELETE_BOND_WITH_VIFS_MESSAGE, pif.Name, new_name);
            }
            else
            {
                // It's not in use -- delete the network as well as the bonds and PIFs.
                new_name = null;
                msg      = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name);
            }

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

            if (will_disturb_primary)
            {
                Pool pool = Helpers.GetPool(network.Connection);
                if (pool != null && pool.ha_enabled)
                {
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                            SystemIcons.Error,
                            string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name),
                            Messages.DELETE_BOND)).ShowDialog(Parent);
                    return;
                }

                string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg);
                if (DialogResult.OK !=
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND),
                        "NetworkingConfigWarning",
                        new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK),
                        ThreeButtonDialog.ButtonCancel).ShowDialog(Parent))
                {
                    return;
                }
            }
            else if (will_disturb_secondary)
            {
                if (DialogResult.OK !=
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER),
                        ThreeButtonDialog.ButtonOK,
                        ThreeButtonDialog.ButtonCancel).ShowDialog(Parent))
                {
                    return;
                }
            }
            else
            {
                if (DialogResult.OK !=
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER),
                        new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                        ThreeButtonDialog.ButtonCancel).ShowDialog(Program.MainWindow))
                {
                    return;
                }
            }

            // The UI shouldn't offer deleting a bond in this case, but let's make sure we've
            // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436).
            Bond bond = pif.BondMasterOf;

            if (bond != null)
            {
                Program.MainWindow.AllowHistorySwitch = true;
                new Actions.DestroyBondAction(bond, new_name).RunAsync();
            }
        }
Пример #16
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.Add(new PropertiesCommand(mainWindow, selection));
 }
Пример #17
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     Execute(selection.AsXenObjects <VM>());
 }
Пример #18
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new DeleteVMsAndTemplatesCommand(mainWindow, selection));
     items.AddIfEnabled(new EditTagsCommand(mainWindow, selection));
 }
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     new SrAction(SrActionKind.SetAsDefault, (SR)selection[0].XenObject).RunAsync();
 }
Пример #20
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new ShutDownHostCommand(mainWindow, selection));
     items.AddIfEnabled(new PowerOnHostCommand(mainWindow, selection));
     items.AddIfEnabled(new RestartToolstackCommand(mainWindow, selection));
 }
Пример #21
0
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     return(selection.ContainsOneItemOfType <Host>() && selection.AtLeastOneXenObjectCan <Host>(CanExecute));
 }
Пример #22
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new VappStartCommand(mainWindow, selection));
     items.AddIfEnabled(new VappShutDownCommand(mainWindow, selection));
 }
Пример #23
0
 /// <summary>
 /// Determines whether this instance can execute with the current selection context.
 /// </summary>
 /// <param name="selection">The selection context.</param>
 /// <returns>
 ///     <c>true</c> if this instance can execute with the specified selection; otherwise, <c>false</c>.
 /// </returns>
 protected virtual bool CanExecuteCore(SelectedItemCollection selection)
 {
     return(true);
 }
Пример #24
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.AllItemsAre <VM_appliance>());
 }
Пример #25
0
 /// <summary>
 /// Sets the selection context for the Command. This is hidden as it is only for use by the Command framework.
 /// </summary>
 void ICommand.SetSelection(IEnumerable <SelectedItem> selection)
 {
     Util.ThrowIfParameterNull(selection, "selection");
     _selection = new SelectedItemCollection(selection);
 }
Пример #26
0
 public override bool IsValid(SelectedItemCollection selection)
 {
     return(selection.ContainsOneItemOfType <Folder>());
 }
Пример #27
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM snapshot = (VM)selection[0].XenObject;

            new NewVMCommand(MainWindowCommandInterface, snapshot.Connection, null, snapshot).Execute();
        }
Пример #28
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var con = selection.GetConnectionOfFirstItem();

            MainWindowCommandInterface.ShowPerConnectionWizard(con, new ExportApplianceWizard(con, selection));
        }
 protected override bool CanExecuteCore(SelectedItemCollection selection)
 {
     return(selection.Count > 0 && selection.AllItemsAre <VM>() &&
            selection.GetConnectionOfAllItems() != null && selection.Any(CanExecute));
 }
Пример #30
0
 public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
 {
     items.AddIfEnabled(new DeleteTagCommand(mainWindow, selection));
 }