Exemple #1
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            AssertOperationAllowsExecution();

            string title            = Messages.ACTION_VMS_RESUMING_ON_TITLE;
            string startDescription = Messages.ACTION_VM_RESUMING;
            string endDescription   = Messages.ACTION_VM_RESUMED;

            List <AsyncAction> actions = new List <AsyncAction>();

            if (_operation == vm_operations.pool_migrate)
            {
                title            = Messages.ACTION_VMS_MIGRATING_TITLE;
                startDescription = Messages.ACTION_VM_MIGRATING;
                endDescription   = Messages.ACTION_VM_MIGRATED;
                foreach (VM vm in selection.AsXenObjects <VM>(CanExecute))
                {
                    this.MainWindowCommandInterface.CloseActiveWizards(vm);
                    Host host = GetHost(vm);
                    actions.Add(new VMMigrateAction(vm, host));
                }
            }
            else if (_operation == vm_operations.start_on)
            {
                title            = Messages.ACTION_VMS_STARTING_ON_TITLE;
                startDescription = Messages.ACTION_VM_STARTING;
                endDescription   = Messages.ACTION_VM_STARTED;
                foreach (VM vm in selection.AsXenObjects <VM>(CanExecute))
                {
                    Host host = GetHost(vm);
                    actions.Add(new VMStartOnAction(vm, host, WarningDialogHAInvalidConfig, StartDiagnosisForm));
                }
            }
            else if (_operation == vm_operations.resume_on)
            {
                title            = Messages.ACTION_VMS_RESUMING_ON_TITLE;
                startDescription = Messages.ACTION_VM_RESUMING;
                endDescription   = Messages.ACTION_VM_RESUMED;
                foreach (VM vm in selection.AsXenObjects <VM>(CanExecute))
                {
                    Host host = GetHost(vm);
                    actions.Add(new VMResumeOnAction(vm, host, WarningDialogHAInvalidConfig, StartDiagnosisForm));
                }
            }

            RunMultipleActions(actions, title, startDescription, endDescription, true);
        }
Exemple #2
0
        protected sealed override void ExecuteCore(SelectedItemCollection selection)
        {
            List <VM> vms = selection.AsXenObjects <VM>(CanExecute);

            // sort so actions execute in correct order.
            vms.Sort();
            Execute(vms);
        }
Exemple #3
0
        protected override bool CanExecuteCore(SelectedItemCollection selection)
        {
            if (!selection.AllItemsAre <Host>() || selection.Count > 1)
            {
                return(false);
            }

            return(CanExecute(selection.AsXenObjects <Host>().FirstOrDefault()));
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();
            _isDropDownClosed = false;

            // Work around bug in tool kit where disabled menu items show their dropdown menus
            if (!Enabled)
            {
                ToolStripMenuItem emptyMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY);
                emptyMenuItem.Font    = Program.DefaultFont;
                emptyMenuItem.Enabled = false;
                base.DropDownItems.Add(emptyMenuItem);
                return;
            }

            VisualMenuItemAlignData.ParentStrip = this;
            IXenConnection connection = Command.GetSelection()[0].Connection;
            bool           wlb        = Helpers.WlbEnabled(connection);

            if (wlb)
            {
                base.DropDownItems.Add(new VMOperationToolStripMenuSubItem(Messages.WLB_OPT_MENU_OPTIMAL_SERVER, Images.StaticImages._000_ServerWlb_h32bit_16));
            }
            else
            {
                base.DropDownItems.Add(new VMOperationToolStripMenuSubItem(Messages.HOME_SERVER_MENU_ITEM, Images.StaticImages._000_ServerHome_h32bit_16));
            }

            List <Host> hosts = new List <Host>(connection.Cache.Hosts);

            hosts.Sort();
            foreach (Host host in hosts)
            {
                VMOperationToolStripMenuSubItem item = new VMOperationToolStripMenuSubItem(String.Format(Messages.MAINWINDOW_CONTEXT_UPDATING, host.name_label.EscapeAmpersands()), Images.StaticImages._000_ServerDisconnected_h32bit_16);
                item.Tag = host;
                base.DropDownItems.Add(item);
            }

            // start a new thread to evaluate which hosts can be used.
            ThreadPool.QueueUserWorkItem(delegate
            {
                SelectedItemCollection selection = Command.GetSelection();
                Session session = selection[0].Connection.DuplicateSession();
                WlbRecommendations recommendations = new WlbRecommendations(selection.AsXenObjects <VM>(), session);
                recommendations.Initialize();

                if (recommendations.IsError)
                {
                    EnableAppropriateHostsNoWlb(session);
                }
                else
                {
                    EnableAppropriateHostsWlb(session, recommendations);
                }
            });
        }
Exemple #5
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>())
            {
                string opaque_ref = host.opaque_ref;
                Pool   pool       = Helpers.GetPool(host.Connection);

                if (selection.Count == 1 && pool.master == host.opaque_ref)
                {
                    // Trying to remove the master from a pool.
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Error,
                                   Messages.MESSAGEBOX_POOL_MASTER_REMOVE,
                                   Messages.XENCENTER)))
                    {
                        dlg.ShowDialog(MainWindowCommandInterface.Form);
                    }
                    return;
                }

                // Optimistically, add the ejected host as a standalone host (but don't connect to it yet)
                IXenConnection connection = new XenConnection();
                connection.Hostname     = host.address;
                connection.Username     = host.Connection.Username;
                connection.Password     = host.Connection.Password;
                connection.FriendlyName = host.Name();

                lock (ConnectionsManager.ConnectionsLock)
                {
                    ConnectionsManager.XenConnections.Add(connection);
                }

                Program.HideObject(opaque_ref);

                var action = new EjectHostFromPoolAction(pool, host);
                action.Completed += delegate
                {
                    if (action.Succeeded)
                    {
                        ThreadPool.QueueUserWorkItem(WaitForReboot, connection);
                    }
                    else
                    {
                        Program.ShowObject(opaque_ref);
                        MainWindowCommandInterface.RemoveConnection(connection);
                    }
                };

                actions.Add(action);
            }

            RunMultipleActions(actions, Messages.REMOVING_SERVERS_FROM_POOL, Messages.POOLCREATE_REMOVING, Messages.POOLCREATE_REMOVED, true);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (VM vm in selection.AsXenObjects <VM>())
            {
                actions.Add(new VMSnapshotDeleteAction(vm));
            }
            RunMultipleActions(actions, Messages.ACTION_VM_DELETE_SNAPSHOTS_TITLE, Messages.SNAPSHOT_DELETING, Messages.SNAPSHOTS_DELETED, true);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
            {
                actions.Add(new SrAction(SrActionKind.UpgradeLVM, sr));
            }
            RunMultipleActions(actions, Messages.ACTION_SRS_UPGRADE, Messages.ACTION_SRS_UPGRADING, Messages.ACTION_SRS_UPGRADED, true);
        }
Exemple #8
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var actions = new List <AsyncAction>();

            foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
            {
                actions.Add(new SrTrimAction(sr.Connection, sr));
            }
            RunMultipleActions(actions, null, Messages.ACTION_SR_TRIM_DESCRIPTION, Messages.ACTION_SR_TRIM_DONE, true);
        }
Exemple #9
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
     {
         SrShareAction        action = new SrShareAction(sr.Connection, sr);
         ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
         dialog.ShowCancel = true;
         dialog.ShowDialog(Parent);
     }
 }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
            {
                actions.Add(new SrAction(SrActionKind.Detach, sr));
            }
            RunMultipleActions(actions, Messages.ACTION_SRS_DETACHING, Messages.ACTION_SRS_DETACHING, Messages.ACTION_SRS_DETACH_SUCCESSFUL, true);
        }
Exemple #11
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
            {
                actions.Add(new SrAction(SrActionKind.Forget, sr));
            }
            RunMultipleActions(actions, Messages.ACTION_SRS_FORGETTING, Messages.FORGETTING_SRS, Messages.SRS_FORGOTTEN, true);
        }
Exemple #12
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (SR sr in selection.AsXenObjects <SR>(CanExecute))
            {
                actions.Add(new SrAction(SrActionKind.Destroy, sr));
            }
            RunMultipleActions(actions, Messages.ACTION_SRS_DESTROYING, string.Empty, string.Empty, true);
        }
Exemple #13
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var connections = new List <StorageLinkConnection>();

            foreach (IStorageLinkObject s in selection.AsXenObjects <IStorageLinkObject>())
            {
                if (!connections.Contains(s.StorageLinkConnection))
                {
                    connections.Add(s.StorageLinkConnection);
                }
            }

            foreach (StorageLinkConnection c in connections)
            {
                string title    = string.Format(Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_TITLE, c.Host);
                string startDes = Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_START;
                string endDes   = Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_END;

                var action = new DelegatedAsyncAction(null, title, startDes, endDes, s =>
                {
                    c.Refresh();

                    // wait for refresh to finish so the user can see that
                    // the refresh is still in progress in the logs tab.
                    for (int i = 0; i < 60 && c.RefreshInProgress; i++)
                    {
                        Thread.Sleep(500);
                    }
                });


                foreach (IStorageLinkObject s in selection.AsXenObjects <IStorageLinkObject>())
                {
                    if (s.StorageLinkConnection == c)
                    {
                        action.AppliesTo.Add(s.opaque_ref);
                    }
                }

                action.RunAsync();
            }
        }
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (selection != null && selection.AllItemsAre <IXenObject>(x => x is Host || x is Pool))
     {
         MainWindowCommandInterface.ShowForm(typeof(BugToolWizard), selection.AsXenObjects <IXenObject>().ToArray());
     }
     else
     {
         MainWindowCommandInterface.ShowForm(typeof(BugToolWizard));
     }
 }
Exemple #15
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                this.MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                EjectHostAction action = new EjectHostAction(host);
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOSTS_EJECTING, Messages.ACTION_HOSTS_EJECT, true);
        }
Exemple #16
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                var action = new HostPowerOnAction(host);
                action.Completed += Program.MainWindow.action_Completed;
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOST_STARTING, Messages.ACTION_HOST_STARTED, true);
        }
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (newPoolDialog == null || newPoolDialog.IsDisposed)
     {
         newPoolDialog = new NewPoolDialog(selection.AsXenObjects <Host>());
         newPoolDialog.Show(Program.MainWindow);
     }
     else
     {
         HelpersGUI.BringFormToFront(newPoolDialog);
     }
 }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                var action = new HostPowerOnAction(host);
                action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView();
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOST_STARTING, Messages.ACTION_HOST_STARTED, true);
        }
Exemple #19
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                this.MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                ShutdownHostAction action = new ShutdownHostAction(host, AddHostToPoolCommand.NtolDialog);
                action.Completed += Program.MainWindow.action_Completed;
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOSTS_SHUTTING_DOWN, Messages.ACTION_HOSTS_SHUTDOWN, true);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <VM> vms = selection.AsXenObjects <VM>(CanExecute);

            if (vms.Count == 1)
            {
                InstallToolsOnOneVm(vms[0]);
            }
            else
            {
                InstallToolsOnManyVms(vms);
            }
        }
Exemple #21
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <VM> vms = selection.AsXenObjects <VM>(CanExecute);

            if (vms.Count == 1)
            {
                SingleVMExecute(vms[0]);
            }
            else
            {
                MultipleVMExecute(vms);
            }
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var actions   = new List <AsyncAction>();
            var liveHosts = selection.AsXenObjects <Host>().Where(h => h.IsLive());

            foreach (Host host in liveHosts)
            {
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                var action = new RestartToolstackAction(host);
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_TOOLSTACK_RESTARTING, Messages.ACTION_TOOLSTACK_RESTARTED, true);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                RebootHostAction action = new RebootHostAction(host, AddHostToPoolCommand.NtolDialog);
                action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView();
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOSTS_REBOOTING, Messages.ACTION_HOSTS_REBOOTED, true);
        }
Exemple #24
0
        protected override bool CanExecuteCore(SelectedItemCollection selection)
        {
            // Can execute criteria: A selection of VMs in the same pool, where at least one doesn't have PVS read caching enabled
            if (selection.Any() && selection.AllItemsAre <VM>() && selection.GetConnectionOfAllItems() != null)
            {
                var vms = selection.AsXenObjects <VM>();
                if (vms.Any(vm => vm.PvsProxy != null))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #25
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>())
            {
                Pool pool   = Helpers.GetPool(host.Connection);
                var  action = new DestroyHostAction(pool, host);
                actions.Add(action);
            }

            RunMultipleActions(actions, Messages.DESTROYING_HOSTS_TITLE, Messages.DESTROYING_HOSTS_START_DESC,
                               Messages.DESTROYING_HOSTS_END_DESC, true);
        }
Exemple #26
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <SR> srList = selection.AsXenObjects <SR>(CanExecute);

            if (srList.Find(s => !s.MultipathAOK) != null)
            {
                new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(
                        SystemIcons.Warning,
                        Messages.MULTIPATH_FAILED,
                        Messages.MULTIPATHING)).ShowDialog(Parent);
            }

            new RepairSRDialog(srList).Show(Parent);
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <SR> srList = selection.AsXenObjects <SR>(CanExecute);

            if (srList.Find(s => !s.MultipathAOK()) != null)
            {
                using (var dlg = new WarningDialog(Messages.MULTIPATH_FAILED)
                {
                    WindowTitle = Messages.MULTIPATHING
                })
                    dlg.ShowDialog(Parent);
            }

            new RepairSRDialog(srList).Show(Parent);
        }
        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)
            {
                ShowUpsellDialog(Parent);
            }
            else
            {
                new VDIMigrateDialog(selection.FirstAsXenObject.Connection, vdis).Show(Program.MainWindow);
            }
        }
Exemple #29
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            MainWindowCommandInterface.SelectObjectInTree(null);

            foreach (Host host in selection.AsXenObjects <Host>())
            {
                string msg = string.Format(Messages.MAINWINDOW_LOG_REMOVECONNECTION, host.Connection.Hostname);
                log.Info($"Removed connection to {host.Connection.Hostname}");
                new ActionBase(msg, msg, false, true);
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                host.Connection.EndConnect();
                MainWindowCommandInterface.RemoveConnection(host.Connection);
            }

            MainWindowCommandInterface.SaveServerList();
        }
Exemple #30
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var dockerContainers = new List <DockerContainer>();

            if (selection.AllItemsAre <DockerContainer>())
            {
                dockerContainers = (from IXenObject obj in selection.AsXenObjects()
                                    let container = (DockerContainer)obj
                                                    where CanExecute(container)
                                                    select container).ToList();
            }

            foreach (var container in dockerContainers)
            {
                (new StopDockerContainerAction(container)).RunAsync();
            }
        }