Exemple #1
0
        protected override void Run()
        {
            // If either of the static memories has changed, we need to shut down the VM
            // before and reboot afterwards. The user has already been warned about this.
            bool reboot = needReboot;

            XenAPI.Host vmHost = null;
            if (reboot)
            {
                vmHost = VM.Home();
                AsyncAction action = null;
                if (VM.allowed_operations.Contains(XenAPI.vm_operations.clean_shutdown))
                {
                    action = new VMCleanShutdown(VM);
                }
                else
                {
                    action = new VMHardShutdown(VM);
                }
                action.RunExternal(Session);
            }

            // Now save the memory settings. We can't use VM.SaveChanges() for this,
            // because we have to do the operations simultaneously or we will
            // violate the memory ordering constraints.
            try
            {
                if (staticChanged)
                {
                    XenAPI.VM.set_memory_limits(Session, VM.opaque_ref, static_min, static_max, dynamic_min, dynamic_max);
                }
                else
                {
                    XenAPI.VM.set_memory_dynamic_range(Session, VM.opaque_ref, dynamic_min, dynamic_max);
                }
            }

            // Reboot the VM, even if we failed to change the memory settings
            finally
            {
                if (reboot)
                {
                    var action = new VMStartOnAction(VM, vmHost, _warningDialogHAInvalidConfig, _startDiagnosticForm);
                    action.RunExternal(Session);
                }
            }

            Description = string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS_DONE, VM.Name);
        }
Exemple #2
0
            public AsyncAction Solve()
            {
                AsyncAction a = null;

                switch (solution)
                {
                case Solution.EjectCD:
                    a = new ChangeVMISOAction(vm.Connection, vm, null, vm.FindVMCDROM());
                    dialog.SetSession(a);
                    dialog.DoAction(a);
                    break;

                case Solution.Suspend:
                    a = new VMSuspendAction(vm);
                    dialog.SetSession(a);
                    dialog.DoAction(a);
                    break;

                case Solution.Shutdown:
                    a = new VMHardShutdown(vm);
                    dialog.SetSession(a);
                    dialog.DoAction(a);
                    break;

                case Solution.InstallPVDrivers:
                    var cmd = new InstallToolsCommand(Program.MainWindow, vm, DataGridView);
                    cmd.InstallTools += action => a = action;
                    cmd.Execute();

                    // The install pv tools action is marked as complete after they have taken the user to the console and loaded the disc
                    // Rescanning when the action is 'complete' in this case doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text.
                    dialog.SetSession(a);
                    solutionAction = a;
                    return(a);
                }
                solutionAction = a;
                solution       = Solution.None;
                // we show this, then register an event handler on the action completed to re-update the text/solution
                this.error = Messages.EVACUATE_SOLUTION_IN_PROGRESS;
                return(a);
            }
Exemple #3
0
        private void dataGridViewVms_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0 && e.RowIndex < dataGridViewVms.RowCount &&
                e.ColumnIndex == columnAction.Index &&
                dataGridViewVms.Rows[e.RowIndex] is VmPrecheckRow row && row.HasSolution())
            {
                AsyncAction action = null;
                switch (row.Solution)
                {
                case Solution.EjectCD:
                    action = new ChangeVMISOAction(row.vm.Connection, row.vm, null, row.vm.FindVMCDROM());
                    break;

                case Solution.Suspend:
                    action = new VMSuspendAction(row.vm);
                    break;

                case Solution.Shutdown:
                    action = new VMHardShutdown(row.vm);
                    break;

                case Solution.InstallPVDrivers:
                    var cmd = new InstallToolsCommand(Program.MainWindow, row.vm, dataGridViewVms);
                    cmd.Execute();
                    // The install pv tools action is marked as complete after they have taken the user to the
                    // console and loaded the disc. Rescanning when the action is 'complete' in this case
                    // doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text.
                    return;
                }

                if (action != null)
                {
                    action.Completed += a => Rebuild();
                    action.RunAsync(GetSudoElevationResult());
                }
                //set this after starting the action so that the row is updated correctly
                row.SolutionAction = action;
            }
        }