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);
        }
        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 += e => MainWindowCommandInterface.RequestRefreshTreeView();
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOSTS_SHUTTING_DOWN, Messages.ACTION_HOSTS_SHUTDOWN, true);
        }
Exemple #3
0
        private void WaitForReboot(object o)
        {
            while (true)
            {
                IXenConnection connection = (IXenConnection)o;
                Thread.Sleep(30 * 1000);           // wait 30s for server to shutdown
                int i   = 0;
                int max = 27;                      // giveup after 5 mins
                while (true)
                {
                    if (i > max)
                    {
                        MainWindowCommandInterface.Invoke(delegate
                        {
                            using (var dlg = new ThreeButtonDialog(
                                       new ThreeButtonDialog.Details(
                                           SystemIcons.Exclamation,
                                           string.Format(Messages.MESSAGEBOX_RECONNECT_FAIL, connection.Hostname),
                                           Messages.MESSAGEBOX_RECONNECT_FAIL_TITLE)))
                            {
                                dlg.ShowDialog(Parent);
                            }
                        });
                        return;
                    }

                    Socket socket = new Socket(System.Net.Sockets.AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    try
                    {
                        socket.Connect(connection.Hostname, connection.Port);
                    }
                    catch (Exception)
                    {
                    }

                    if (socket.Connected)
                    {
                        MainWindowCommandInterface.Invoke(delegate
                        {
                            XenConnectionUI.BeginConnect(connection, false, null, false);
                            MainWindowCommandInterface.RequestRefreshTreeView();
                        });
                        return;
                    }
                    i++;
                    Thread.Sleep(15 * 1000);
                }
            }
        }
        private void DoDisconnect(IXenConnection connection)
        {
            string msg = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname);

            log.Warn(msg);
            ActionBase notice = new ActionBase(msg, msg, false, true);

            notice.Pool = Helpers.GetPoolOfOne(connection);
            notice.Host = Helpers.GetMaster(connection);

            MainWindowCommandInterface.CloseActiveWizards(connection);
            XenDialogBase.CloseAll(connection);
            connection.EndConnect();
            MainWindowCommandInterface.SaveServerList();
            MainWindowCommandInterface.RequestRefreshTreeView();
        }
Exemple #5
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            foreach (SelectedItem item in selection)
            {
                if (item.Connection != null && !item.Connection.IsConnected)
                {
                    if (selection.Count == 1)
                    {
                        item.Connection.CachePopulated += Connection_CachePopulated;
                    }
                    XenConnectionUI.BeginConnect(item.Connection, true, null, false);
                }
            }

            MainWindowCommandInterface.RequestRefreshTreeView();
        }
Exemple #6
0
        private void ExitMaintenanceMode(Host host)
        {
            List <VM> vmsToUnEvacuate = new List <VM>();

            vmsToUnEvacuate.AddRange(host.GetHaltedEvacuatedVMs());
            vmsToUnEvacuate.AddRange(host.GetMigratedEvacuatedVMs());
            vmsToUnEvacuate.AddRange(host.GetSuspendedEvacuatedVMs());

            List <VM> to_remove = new List <VM>();

            foreach (VM vm in vmsToUnEvacuate)
            {
                if (vm.resident_on == host.opaque_ref)
                {
                    to_remove.Add(vm);
                }
            }
            foreach (VM vm in to_remove)
            {
                vmsToUnEvacuate.Remove(vm);
            }

            DialogResult result = DialogResult.No;

            if (vmsToUnEvacuate.Count > 0 && !MainWindowCommandInterface.RunInAutomatedTestMode)
            {
                result = new RestoreVMsDialog(vmsToUnEvacuate, host).ShowDialog();

                if (result == DialogResult.Cancel)
                {
                    return;
                }

                if (!host.Connection.IsConnected)
                {
                    MainWindow.ShowDisconnectedMessage(null);
                    return;
                }
            }

            MainWindowCommandInterface.CloseActiveWizards(host.Connection);
            var action = new EnableHostAction(host, result == DialogResult.Yes, AddHostToPoolCommand.EnableNtolDialog);

            action.Completed += delegate { MainWindowCommandInterface.RequestRefreshTreeView(); };
            action.RunAsync();
            MainWindowCommandInterface.RequestRefreshTreeView();
        }
        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(msg);
                new ActionBase(msg, msg, false, true);
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                host.Connection.EndConnect();
                MainWindowCommandInterface.RemoveConnection(host.Connection);
            }

            MainWindowCommandInterface.SaveServerList();
            MainWindowCommandInterface.RequestRefreshTreeView();
        }
Exemple #8
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            bool expand = MainWindowCommandInterface.GetXenConnectionsCopy().Count < 30;

            foreach (IXenConnection c in MainWindowCommandInterface.GetXenConnectionsCopy())
            {
                if (!c.IsConnected && !c.InProgress)
                {
                    MainWindowCommandInterface.Invoke(delegate
                    {
                        if (expand)
                        {
                            c.CachePopulated += c_CachePopulated;
                        }
                        XenConnectionUI.BeginConnect(c, false, null, false);
                        MainWindowCommandInterface.RequestRefreshTreeView();
                    });
                }
            }
        }