コード例 #1
0
ファイル: RebootHostCommand.cs プロジェクト: huizh/xenadmin
 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);
 }
コード例 #2
0
        /// <summary>
        /// Mask the CPUs of any slaves that need masking to join the pool
        /// </summary>
        /// <returns>Whether any CPUs were masked</returns>
        protected static bool FixCpus(Pool pool, List <Host> hostsToCpuMask, Func <HostAbstractAction, Pool, long, long, bool> acceptNTolChanges)
        {
            if (hostsToCpuMask.Count == 0)
            {
                return(false);
            }

            Host poolMaster = Helpers.GetMaster(pool);
            List <RebootHostAction> rebootActions = new List <RebootHostAction>();

            // Mask the CPUs, and reboot the hosts (simultaneously, as they must all be on separate connections)
            foreach (Host host in hostsToCpuMask)
            {
                // No CPU masking is needed for Dundee or greater hosts
                if (Helpers.DundeeOrGreater(host))
                {
                    System.Diagnostics.Trace.Assert(false, "No CPU masking should be done for Dundee or greater hosts");
                    continue;
                }

                Host.set_cpu_features(host.Connection.Session, host.opaque_ref, poolMaster.cpu_info["features"]);
                RebootHostAction action = new RebootHostAction(host, acceptNTolChanges);
                rebootActions.Add(action);
                action.RunAsync();
            }

            // Wait for all the actions to finish, checking every ten seconds
            while (true)
            {
                bool done = true;
                foreach (RebootHostAction action in rebootActions)
                {
                    if (!action.IsCompleted)
                    {
                        done = false;
                    }
                }
                if (done)
                {
                    break;
                }
                System.Threading.Thread.Sleep(10000);
            }

            return(true);
        }
コード例 #3
0
ファイル: PoolAction.cs プロジェクト: robhoes/xenadmin
        /// <summary>
        /// Mask the CPUs of any slaves that need masking to join the pool
        /// </summary>
        /// <returns>Whether any CPUs were masked</returns>
        protected static bool FixCpus(Pool pool, List<Host> hostsToCpuMask, Func<HostAbstractAction, Pool, long, long, bool> acceptNTolChanges)
        {
            if (hostsToCpuMask.Count == 0)
                return false;

            Host poolMaster = Helpers.GetMaster(pool);
            List<RebootHostAction> rebootActions = new List<RebootHostAction>();

            // Mask the CPUs, and reboot the hosts (simultaneously, as they must all be on separate connections)
            foreach (Host host in hostsToCpuMask)
            {
                // No CPU masking is needed for Dundee or greater hosts
                if (Helpers.DundeeOrGreater(host))
                {
                    System.Diagnostics.Trace.Assert(false, "No CPU masking should be done for Dundee or greater hosts");
                    continue;
                }

                Host.set_cpu_features(host.Connection.Session, host.opaque_ref, poolMaster.cpu_info["features"]);
                RebootHostAction action = new RebootHostAction(host, acceptNTolChanges);
                rebootActions.Add(action);
                action.RunAsync();
            }

            // Wait for all the actions to finish, checking every ten seconds
            while (true)
            {
                bool done = true;
                foreach (RebootHostAction action in rebootActions)
                {
                    if (!action.IsCompleted)
                        done = false;
                }
                if (done)
                    break;
                System.Threading.Thread.Sleep(10000);
            }

            return true;
        }