Exemple #1
0
        protected override void Run()
        {
            ActionCountCompleted = 0;
            ActionCountTotal     = VmsToSuspend.Count + VmsToShutdown.Count;

            foreach (VM vm in VmsToSuspend)
            {
                Description = string.Format(Messages.SUSPENDING_VM_OUT_OF, ActionCountCompleted + 1, VmsToSuspend.Count);
                var action = new VMSuspendAction(vm);
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }

            foreach (VM vm in VmsToShutdown)
            {
                Description = string.Format(Messages.SHUTTING_DOWN_VM_OUT_OF, ActionCountCompleted - VmsToSuspend.Count + 1, VmsToShutdown.Count);
                var action = new VMHardShutdown(vm);
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }
        }
        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);
        }
        protected override void Run()
        {
            ActionCountCompleted = 0;
            ActionCountTotal = VmsToSuspend.Count + VmsToShutdown.Count;

            foreach (VM vm in VmsToSuspend)
            {
                Description = string.Format(Messages.SUSPENDING_VM_OUT_OF, ActionCountCompleted + 1, VmsToSuspend.Count);
                var action = new VMSuspendAction(vm);
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }

            foreach (VM vm in VmsToShutdown)
            {
                Description = string.Format(Messages.SHUTTING_DOWN_VM_OUT_OF, ActionCountCompleted - VmsToSuspend.Count + 1, VmsToShutdown.Count);
                var action = new VMHardShutdown(vm);
                action.Changed += action_Changed;
                action.RunExternal(Session);
                ActionCountCompleted++;
            }
        }