protected override void Run()
        {
            try
            {
                log.Debug("Retrieving Workload Balancing configuration for pool " + Pool.Name);
                this.WlbConfiguration = XenAPI.Pool.retrieve_wlb_configuration(this.Session);

                if (this.WlbConfiguration.Count == 0)
                {
                    //We didn;t get a configuration, so there is somethign wrong
                    log.Debug("Failure retrieving Workload Balancing configuration on pool " + Pool.Name);
                    this.Description = Messages.FAILED;
                    Failure f = new Failure(FriendlyErrorNames.WLB_NOT_INITIALIZED);
                    throw f;

                }
                else
                {

                    log.Debug("Success retrieving Workload Balancing configuration on pool " + Pool.Name);
                    this.Description = Messages.COMPLETED;

                    //Retrieving the configuration was successful, so update the WlbServerState to report the current state
                    //  This is here in case there was a previous communication error which has been fixed.
                    if (Helpers.WlbEnabled(Pool.Connection))
                    {
                        WlbServerState.SetState(Pool, WlbServerState.ServerState.Enabled);
                    }
                    else
                    {
                        WlbServerState.SetState(Pool, WlbServerState.ServerState.Disabled);
                    }
                }
            }
            catch(Exception ex)
            {
                if (ex is Failure)
                {
                    // Retrieving the configuration error could also because WLB is not initialized
                    if (((Failure)ex).Message == FriendlyErrorNames.WLB_NOT_INITIALIZED)
                        WlbServerState.SetState(Pool, WlbServerState.ServerState.NotConfigured);

                    else
                        WlbServerState.SetState(Pool, WlbServerState.ServerState.ConnectionError, (Failure)ex);

                    if (((Failure)ex).Message == FriendlyErrorNames.WLB_INTERNAL_ERROR)
                    {
                        Failure f = new Failure(new string[] { Messages.ResourceManager.GetString("WLB_ERROR_" + ((Failure)ex).ErrorDescription[1]) });
                        throw (f);
                    }
                    else
                    {
                        throw (ex);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void TestFailureSeralization(Failure failure)
        {
            Failure deserializedFailure;

            // Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream())
            {
                bf.Serialize(ms, failure);
                ms.Seek(0, 0);
                deserializedFailure = (Failure)(bf.Deserialize(ms));
            }

            // Check that properties are preserved
            Assert.AreEqual(failure.Message, deserializedFailure.Message, "Message is different");
            Assert.AreEqual(failure.ShortMessage, deserializedFailure.ShortMessage, "ShortMessage is different");
            if (failure.ErrorDescription != null)
            {
                Assert.IsNotNull(deserializedFailure.ErrorDescription);
                Assert.AreEqual(failure.ErrorDescription.Count, deserializedFailure.ErrorDescription.Count,
                                "ErrorDescription count is different");
                for (int i = 0; i < failure.ErrorDescription.Count; i++)
                {
                    Assert.AreEqual(failure.ErrorDescription[i], deserializedFailure.ErrorDescription[i],
                                    string.Format("ErrorDescription[{0}] count is different", i));
                }
            }
            else
            {
                Assert.IsNull(deserializedFailure.ErrorDescription);
            }

            if (failure.InnerException != null)
            {
                Assert.IsNotNull(deserializedFailure.InnerException);
                Assert.AreEqual(failure.InnerException.Message, deserializedFailure.InnerException.Message, "Message is different");
            }
            else
            {
                Assert.IsNull(deserializedFailure.InnerException);
            }

        }
Ejemplo n.º 3
0
 public PrecheckFailed(Check check, Host host, Failure failure)
     : base(check,  host)
 {
     Failure = failure;
     _host = host;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Changes a techy RBAC Failure into a pretty print one that shows the roles that would be required to complete the failed action.
 /// Requires context such as the the connection and current session to populate these fields.
 /// </summary>
 /// <param name="failure">The Failure to update</param>
 /// <param name="Connection">The current connection</param>
 /// <param name="Session">The current session, passed separately because it could be an elevated session, different to the heartbeat</param>
 public static void ParseRBACFailure(Failure failure, IXenConnection Connection, Session Session)
 {
     List<Role> authRoles = Role.ValidRoleList(failure.ErrorDescription[1], Connection);
     failure.ErrorDescription[0] = Failure.RBAC_PERMISSION_DENIED_FRIENDLY;
     // Current Role(s)
     failure.ErrorDescription[1] = Session.FriendlyRoleDescription;
     // Authorized roles
     failure.ErrorDescription[2] = Role.FriendlyCSVRoleList(authRoles);
     failure.Setup();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// This overload is for the special case of us doing an action over multiple connections. Assumes the role requirement is the same across all conections.
 /// </summary>
 /// <param name="failure">The Failure to update</param>
 /// <param name="Sessions">One session per connection, the ones used to perform the action. Passed separately because they could be elevated sessions, different to the heartbeat</param>
 public static void ParseRBACFailure(Failure failure, Session[] Sessions)
 {
     List<Role> authRoles = Role.ValidRoleList(failure.ErrorDescription[1], Sessions[0].Connection);
     failure.ErrorDescription[0] = Failure.RBAC_PERMISSION_DENIED_FRIENDLY;
     // Current Role(s)
     StringBuilder sb = new StringBuilder();
     foreach (Session s in Sessions)
     {
         sb.Append(string.Format(Messages.ROLE_ON_CONNECTION, s.FriendlyRoleDescription, Helpers.GetName(s.Connection).Ellipsise(50)));
         sb.Append(", ");
     }
     string output = sb.ToString();
     // remove trailing comma and space
     output = output.Substring(0, output.Length - 2);
     failure.ErrorDescription[1] = output;
     // Authorized roles
     failure.ErrorDescription[2] = Role.FriendlyCSVRoleList(authRoles);
     failure.Setup();
 }
Ejemplo n.º 6
0
        public WlbRecommendation GetStarRating(Host host)
        {
            Verify();

            List<double> starRatings = new List<double>();
            Dictionary<VM, bool> canExecutes = new Dictionary<VM, bool>();
            Dictionary<VM, string> cantExecuteReasons = new Dictionary<VM, string>();

            foreach (VM vm in _vms)
            {
                Host residentHost = vm.Connection.Resolve(vm.resident_on);
                string[] rec = new string[0];

                if (residentHost != null && residentHost.opaque_ref == host.opaque_ref)
                {
                    cantExecuteReasons[vm] = Messages.HOST_MENU_CURRENT_SERVER;
                    canExecutes[vm] = false;
                }
                else if (_recommendations[vm].TryGetValue(new XenRef<Host>(host.opaque_ref), out rec))
                {
                    if (rec.Length > 0 && rec[0].Trim().ToLower() == "wlb")
                    {
                        double stars = 0;
                        ParseStarRating(rec, out stars);
                        canExecutes[vm] = true;
                        starRatings.Add(stars);
                    }
                    else
                    {
                        cantExecuteReasons[vm] = new Failure(rec).ShortMessage;
                        canExecutes[vm] = false;
                    }
                }
                else
                {
                    cantExecuteReasons[vm] = FriendlyErrorNames.HOST_NOT_LIVE_SHORT;
                    canExecutes[vm] = false;
                }
            }

            double averageStarRating = 0.0;

            foreach (double s in starRatings)
            {
                averageStarRating += s;
            }
            averageStarRating /= starRatings.Count;

            return new WlbRecommendation(canExecutes, averageStarRating, cantExecuteReasons);
        }
Ejemplo n.º 7
0
 public void TestEmptyFailure()
 {
     var failure = new Failure();
     TestFailureSeralization(failure);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// In the case there being nowhere to start/resume the VM (NO_HOSTS_AVAILABLE), shows the reason why the VM could not be started
        /// on each host. If the start failed due to HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN, offers to decrement ntol and try the operation
        /// again.
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="f"></param>
        /// <param name="kind">The kind of the operation that failed. Must be one of Start/StartOn/Resume/ResumeOn.</param>
        public static void StartDiagnosisForm(VMStartAbstractAction VMStartAction , Failure failure)
        {

            if (failure.ErrorDescription[0] == Failure.NO_HOSTS_AVAILABLE)
            {
                // Show a dialog displaying why the VM couldn't be started on each host
                StartDiagnosisForm(VMStartAction.VM);
            }
            else if (failure.ErrorDescription[0] == Failure.HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN)
            {
                // The action was blocked by HA because it would reduce the number of tolerable server failures.
                // With the user's consent, we'll reduce the number of configured failures to tolerate and try again.
                Pool pool = Helpers.GetPool(VMStartAction.VM.Connection);
                if (pool == null)
                {
                    log.ErrorFormat("Could not get pool for VM {0} in StartDiagnosisForm()", Helpers.GetName(VMStartAction.VM));
                    return;
                }

                long ntol = pool.ha_host_failures_to_tolerate;
                long newNtol = Math.Min(pool.ha_plan_exists_for - 1, ntol - 1);
                if (newNtol <= 0)
                {
                    // We would need to basically turn HA off to start this VM
                    string msg = String.Format(VMStartAction.IsStart ? Messages.HA_VM_START_NTOL_ZERO : Messages.HA_VM_RESUME_NTOL_ZERO,
                        Helpers.GetName(pool).Ellipsise(100),
                        Helpers.GetName(VMStartAction.VM).Ellipsise(100));
                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow);
                    });
                }
                else
                {
                    // Show 'reduce ntol?' dialog
                    string msg = String.Format(VMStartAction.IsStart ? Messages.HA_VM_START_NTOL_DROP : Messages.HA_VM_RESUME_NTOL_DROP,
                        Helpers.GetName(pool).Ellipsise(100), ntol,
                        Helpers.GetName(VMStartAction.VM).Ellipsise(100), newNtol);

                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        DialogResult r = new ThreeButtonDialog(
                            new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY),
                            ThreeButtonDialog.ButtonYes,
                            new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow);

                        if (r == DialogResult.Yes)
                        {
                            DelegatedAsyncAction action = new DelegatedAsyncAction(VMStartAction.VM.Connection, Messages.HA_LOWERING_NTOL, null, null,
                                delegate(Session session)
                                {
                                    // Set new ntol, then retry action
                                    XenAPI.Pool.set_ha_host_failures_to_tolerate(session, pool.opaque_ref, newNtol);
                                    // ntol set succeeded, start new action
                                    VMStartAction.Clone().RunAsync();
                                });
                            action.RunAsync();
                        }
                    });
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Find problem from xapi Failure
        /// </summary>
        /// <param name="failure">Xapi failure, thrown by Pool_patch.precheck() call.
        ///     E.g.: failure.ErrorDescription.Count = 4
        ///         ErrorDescription[0] = "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION"
        ///         ErrorDescription[1] = "OpaqueRef:612b5eee-03dc-bbf5-3385-6905fdc9b079"
        ///         ErrorDescription[2] = "6.5.0"
        ///         ErrorDescription[3] = "^6\\.2\\.0$"
        ///     E.g.: failure.ErrorDescription.Count = 2
        ///         ErrorDescription[0] = "OUT_OF_SPACE"
        ///         ErrorDescription[1] = "/var/patch"
        /// </param>
        /// <returns>Problem or null, if no problem found</returns>
        private Problem FindProblem(Failure failure)
        {
            if (failure.ErrorDescription.Count == 0)
                return null;

            var errorcode = failure.ErrorDescription[0];
            var found = "";
            var required = "";

            if (failure.ErrorDescription.Count > 2)
                found = failure.ErrorDescription[2];
            if (failure.ErrorDescription.Count > 3)
                required = failure.ErrorDescription[3];

            return FindProblem(errorcode, found, required);
        }
Ejemplo n.º 10
0
 private void SetFatalErrorData(Task task)
 {
     string[] err = task.error_info;
     if (err != null && err.Length > 0)
         Exception = new Failure(err);
     else if (task.status == task_status_type.cancelled)
         Exception = new CancelledException();
 }
Ejemplo n.º 11
0
 public void TestFailureWithFriendlyErrorNames()
 {
     var failure = new Failure(friendlyErrorDescriptions);
     TestFailureSeralization(failure);
 }
Ejemplo n.º 12
0
 public void TestFailureWithErrorDescriptions()
 {
     var failure = new Failure(errorDescriptions);
     TestFailureSeralization(failure);
 }
Ejemplo n.º 13
0
 public void TestSimpleFailure()
 {
     var failure = new Failure(errorText);
     TestFailureSeralization(failure);
 }
Ejemplo n.º 14
0
 public void TestInnerExceptionFailure()
 {
     var failure = new Failure(errorText, new Exception(errorText));
     TestFailureSeralization(failure);
 }
Ejemplo n.º 15
0
        private void action_Completed(ActionBase sender)
        {
            if (_srList.Count > 0 && _srList.Any(s => s != null && !s.MultipathAOK))
            {
                SucceededWithWarning            = true;
                SucceededWithWarningDescription = Messages.REPAIR_SR_WARNING_MULTIPATHS_DOWN;
            }

            Program.Invoke(this, () =>
            {
                if (sender is MultipleAction)
                {
                    Build();
                }

                FinalizeProgressControls(sender);
            });
            if (_srList.Count == 1 && _srList[0].GetSRType(true) == SR.SRTypes.lvmobond)
            {
                Program.Invoke(this, delegate()
                {
                    if (!sender.Succeeded)
                    {
                        SrRepairAction act = sender as SrRepairAction;
                        XenAPI.Failure f   = act.failure;
                        if (f.ErrorDescription[0] == "SR_BACKEND_FAILURE_1")
                        {
                            String s      = f.ErrorDescription[2];
                            int start     = s.IndexOf(":");
                            String scsiid = s.Substring(start + 2, s.Length - start - 2);
                            DialogResult confirmResult = MessageBox.Show(string.Format(Messages.REPAIR_SR_DIALOG_SINGLE_LUN_RAID_WARNING, scsiid),
                                                                         Messages.MESSAGEBOX_CONFIRM,
                                                                         MessageBoxButtons.OKCancel,
                                                                         MessageBoxIcon.Question);
                            if (confirmResult == DialogResult.OK)
                            {
                                _repairAction = new SrRepairLUNAction(_srList[0].Connection, _srList[0], scsiid);
                                _repairAction.RunAsync();
                            }
                            else
                            {
                                //AsyncAction removeAction = new SrRepairLUNAction(_srList[0].Connection, _srList[0], scsiid);
                                //removeAction.RunExternal(null);
                                List <FibreChannelDevice> devices;
                                var success = LVMoBond.FiberChannelScan(this, _srList[0].Connection, out devices);
                                Program.MainWindow.ShowPerConnectionWizard(_srList[0].Connection, new AddMirrorLUNDialog(_srList[0], devices));
                            }
                            this.Close();
                        }
                    }
                });
            }
            if (_srList.Count == 1 && _srList[0].GetSRType(true) == SR.SRTypes.lvmomirror)
            {
                Program.Invoke(this, delegate()
                {
                    if (!sender.Succeeded)
                    {
                        SrRepairAction act = sender as SrRepairAction;
                        XenAPI.Failure f   = act.failure;
                        if (f.ErrorDescription[0] == "SR_BACKEND_FAILURE_1")
                        {
                            String s      = f.ErrorDescription[2];
                            int start     = s.IndexOf(":");
                            String scsiid = s.Substring(start + 2, s.Length - start - 2);
                            DialogResult confirmResult = MessageBox.Show(string.Format(Messages.REPAIR_SR_DIALOG_SINGLE_LUN_RAID_WARNING, scsiid),
                                                                         Messages.MESSAGEBOX_CONFIRM,
                                                                         MessageBoxButtons.OKCancel,
                                                                         MessageBoxIcon.Question);
                            if (confirmResult == DialogResult.OK)
                            {
                                _repairAction = new SrRepairLUNAction(_srList[0].Connection, _srList[0], scsiid);
                                _repairAction.RunAsync();
                            }
                            else
                            {
                                //AsyncAction removeAction = new SrRepairLUNAction(_srList[0].Connection, _srList[0], scsiid);
                                //removeAction.RunExternal(null);
                                List <FibreChannelDevice> devices;
                                var success = LVMoMirror.FiberChannelScan(this, _srList[0].Connection, out devices);
                                Program.MainWindow.ShowPerConnectionWizard(_srList[0].Connection, new AddMirrorLUNDialog(_srList[0], devices));
                            }
                            this.Close();
                        }
                    }
                });
            }
        }
Ejemplo n.º 16
0
        protected override void Run()
        {
            log.Debug("Running SR repair");
            log.DebugFormat("SR='{0}'", SR.Name);

            //CA-176935, CA-173497 - we need to run Plug for the master first - creating a new list of hosts where the master is always first
            var allHosts = new List<Host>();

            var master = Helpers.GetMaster(Connection);
            if (master != null)
                allHosts.Add(master);

            foreach (var host in Connection.Cache.Hosts)
                if (!allHosts.Contains(host))
                    allHosts.Add(host);

            foreach (Host host in allHosts)
            {
                Host stoHost = SR.GetStorageHost();
                if (SR.shared
                    || (stoHost != null && host.opaque_ref == stoHost.opaque_ref))
                {
                    _hostList.Add(host);
                }
            }

            if (_hostList.Count == 0)
            {
                return;
            }

            for (int i = 0; i < _hostList.Count; i++)
            {
                log.DebugFormat("_hostList[{0}]='{1}'", i, _hostList[i].Name);
            }

            int max = _hostList.Count * 2;
            int delta = 100 / max;

            foreach (Host host in _hostList)
            {
                if (!host.HasPBDTo(SR) && SR.shared && SR.PBDs.Count > 0)
                {
                    PBD template = SR.Connection.Resolve(SR.PBDs[0]);
                    if (template != null)
                    {
                        this.Description = string.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host));
                        log.Debug(this.Description);

                        Proxy_PBD proxyPBD = new Proxy_PBD();
                        proxyPBD.currently_attached = false;
                        proxyPBD.device_config = new Hashtable(template.device_config);
                        proxyPBD.SR = template.SR;
                        proxyPBD.host = new XenRef<Host>(host.opaque_ref);

                        try
                        {
                            RelatedTask = XenAPI.PBD.async_create(this.Session, new PBD(proxyPBD));

                            if (PercentComplete + delta <= 100)
                            {
                                PollToCompletion(PercentComplete, PercentComplete + delta);
                            }
                            else
                            {
                                PollToCompletion(PercentComplete, 100);
                                PercentComplete = 100;
                            }
                        }
                        catch (XenAPI.Failure f)
                        {
                            failure = f;
                            failureDescription = Description;
                        }
                    }
                }
                else
                {
                    PercentComplete += delta;
                }

                PBD thePBD = host.GetPBDTo(SR);
                if (thePBD != null && !thePBD.currently_attached)
                {
                    this.Description = string.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host));
                    log.Debug(this.Description);

                    try
                    {
                        RelatedTask = XenAPI.PBD.async_plug(this.Session, thePBD.opaque_ref);

                        if (PercentComplete + delta <= 100)
                        {
                            PollToCompletion(PercentComplete, PercentComplete + delta);
                        }
                        else
                        {
                            PollToCompletion(PercentComplete, 100);
                            PercentComplete = 100;
                        }
                    }
                    catch (XenAPI.Failure f)
                    {
                        failure = f;
                        failureDescription = Description;
                    }
                }
                else
                {
                    PercentComplete += delta;
                }
            }

            if (failure != null && failureDescription != null)
            {
                Description = failureDescription;
                throw failure;
            }

            // CA-14928: Sometimes we have too many PBDs if there has just been a host
            // eject and the GC hasn't collected the PBD yet.
            //
            //if (SR.PBDs.Count != _hostList.Count && SR.shared && !SR.IsToolsSR)
            //{
            //    throw new Exception(Messages.ACTION_SR_REPAIR_FAILED);
            //}
            if (isSharedAction)
                Description = string.Format(Messages.ACTION_SR_SHARE_SUCCESSFUL, SR.NameWithoutHost);
            else
                Description = string.Format(Messages.ACTION_SR_REPAIR_SUCCESSFUL, SR.NameWithoutHost);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Public method for updating the Wlb Server state.  If the state is ConnectionFailure and
 /// a Failure is supplied, it's message is stored in the OtherConfig
 /// </summary>
 /// <param name="pool">The pool who's Wlb connection state we are updating</param>
 /// <param name="state">The current state of the pool's Wlb Server State</param>
 /// <param name="failure">The Failure (if any) describing the Connection Error</param>
 public static void SetState(Pool pool, ServerState state, Failure failure)
 {
     SetState(pool.Connection.Session, pool, state, failure);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// In the case there was nowhere to start/resume the VM (NO_HOSTS_AVAILABLE), shows the reason why the VM could not be started
        /// on each host. If the start failed due to HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN, offers to decrement ntol and try the operation
        /// again.
        /// </summary>
        /// <param name="vm">vm</param>
        /// <param name="failure">failure, xapi exception</param>
        //private static bool StartDiagnosisForm(XenObject<VM> vm, Failure failure, string recommendationId)
        private bool RaiseHANotl(VM vm, Failure failure, out long newNtol)
        {
            bool error = false;
            newNtol = 0;

            if (failure.ErrorDescription[0] == Failure.NO_HOSTS_AVAILABLE)
            {
                VMOperationCommand.StartDiagnosisForm(vm);
            }
            else if (failure.ErrorDescription[0] == Failure.HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN)
            {
                // The action was blocked by HA because it would reduce the number of tolerable server failures.
                // With the user's consent, we'll reduce the number of configured failures to tolerate and try again.
                if (this.Pool == null)
                {
                    log.ErrorFormat("Could not get pool for VM {0} in StartDiagnosisForm()", Helpers.GetName(vm));
                    return error;
                }

                long ntol = this.Pool.ha_host_failures_to_tolerate;
                newNtol = Math.Min(this.Pool.ha_plan_exists_for - 1, ntol - 1);
                if (newNtol <= 0)
                {
                    // We would need to basically turn HA off to start this VM
                    string msg = String.Format(Messages.HA_OPT_VM_RELOCATE_NTOL_ZERO,
                        Helpers.GetName(this.Pool).Ellipsise(100),
                        Helpers.GetName(vm).Ellipsise(100));
                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Warning,
                               msg,
                               Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow);
                    });
                }
                else
                {
                    // Show 'reduce ntol?' dialog
                    string msg = String.Format(Messages.HA_OPT_DISABLE_NTOL_DROP,
                        Helpers.GetName(this.Pool).Ellipsise(100), ntol,
                        Helpers.GetName(vm).Ellipsise(100), newNtol);

                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        DialogResult r = new ThreeButtonDialog(
                            new ThreeButtonDialog.Details(
                               SystemIcons.Warning,
                               msg,
                               Messages.HIGH_AVAILABILITY),
                            ThreeButtonDialog.ButtonYes,
                            new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow);

                        if (r != DialogResult.Yes)
                        {
                            error = true;
                        }
                    });
                }
            }
            return error;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Public method for updating the Wlb Server state.  If the state is ConnectionFailure and
        /// a Failure is supplied, it's message is stored in the OtherConfig
        /// </summary>
        /// <param name="session">The User session use to do this operation</param>
        /// <param name="pool">The pool who's Wlb connection state we are updating</param>
        /// <param name="state">The current state of the pool's Wlb Server State</param>
        /// <param name="failure">The Failure (if any) describing the Connection Error</param>
        public static void SetState(Session session, Pool pool, ServerState state, Failure failure)
        {
            //only update the state if new value if different than current value
            //  this is to cut down on unneeded Pool_PropertiesChanged events
            if (GetState(pool) != state)
            {
                // set a lock so we are setting state one at a time
                lock (_lockObject)
                {
                    Helpers.SetOtherConfig(session, pool, WLB_CONNECTION_STATUS, state.ToString());

                    if (null != failure && state == ServerState.ConnectionError)
                    {
                        string error = String.Empty;
                        if (failure.Message == FriendlyErrorNames.WLB_INTERNAL_ERROR)
                        {
                            error = Messages.ResourceManager.GetString("WLB_ERROR_" + failure.ErrorDescription[1]);
                        }
                        else
                        {
                            error = failure.Message;
                        }
                        Helpers.SetOtherConfig(session, pool, WLB_CONNECTION_ERROR, error);
                    }
                    else
                    {
                        Helpers.SetOtherConfig(session, pool, WLB_CONNECTION_ERROR, String.Empty);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        protected override void Run()
        {
            try
            {
                log.Debug("Initializing Workload Balancing for pool " + Pool.Name);
                RelatedTask = XenAPI.Pool.async_initialize_wlb(this.Session, _wlbUrl, _wlbUserName, _wlbPassword, _xenServerUserName, _xenServerPassword);
                PollToCompletion();
                log.Debug("Success initializing WLB on pool " + Pool.Name);
                this.Description = Messages.COMPLETED;

                //Clear the Optimizing Pool flag in case it was left behind
                Helpers.SetOtherConfig(this.Session, this.Pool, OPTIMIZINGPOOL, string.Empty);
            }
            catch (Failure e)
            {
                if (e.Message == FriendlyErrorNames.WLB_INTERNAL_ERROR)
                {
                    Failure f = new Failure(new string[] { Messages.ResourceManager.GetString("WLB_ERROR_" + e.ErrorDescription[1]) });
                    throw (f);
                }
                else if (e.ErrorDescription[0] == FriendlyErrorNames.INTERNAL_ERROR)
                {
                    Failure f = new Failure(new string[] { Messages.ResourceManager.GetString("WLB_ERROR_SERVER_NOT_FOUND") });
                }
                else
                {
                    throw (e);
                }
            }
        }
Ejemplo n.º 21
0
        protected override void Run()
        {
            log.Debug("Sending Workload Balancing configuration for pool " + Pool.Name);

            ClearKeys();

            if ((_kind & SendWlbConfigurationKind.SetHostConfiguration) == SendWlbConfigurationKind.SetHostConfiguration)
            {
                this.WlbConfiguration.Add(SET_HOST_CONFIGURATION, "true");
            }
            if ((_kind & SendWlbConfigurationKind.SetScheduledTask) == SendWlbConfigurationKind.SetScheduledTask)
            {
                this.WlbConfiguration.Add(SET_SCHEDULED_TASK, "true");
            }
            if ((_kind & SendWlbConfigurationKind.DeleteScheduledTask) == SendWlbConfigurationKind.DeleteScheduledTask)
            {
                this.WlbConfiguration.Add(DELETE_SCHEDULED_TASK, "true");
            }
            if ((_kind & SendWlbConfigurationKind.SetReportSubscription) == SendWlbConfigurationKind.SetReportSubscription)
            {
                this.WlbConfiguration.Add(SET_REPORT_SUBSCRIPTIONS, "true");
            }
            if ((_kind & SendWlbConfigurationKind.DeleteReportSubscription) == SendWlbConfigurationKind.DeleteReportSubscription)
            {
                this.WlbConfiguration.Add(DELETE_REPORT_SUBSCRIPTIONS, "true");
            }

            try
            {
                XenAPI.Pool.send_wlb_configuration(this.Session, this.WlbConfiguration);
                log.Debug("Successfully sent Workload Balancing configuration on pool " + Pool.Name);
                this.Description = Messages.COMPLETED;
            }
            catch (Exception ex)
            {
                if (ex is Failure)
                {
                    WlbServerState.SetState(Pool, WlbServerState.ServerState.ConnectionError, (Failure)ex);

                    if (((Failure)ex).Message == FriendlyErrorNames.WLB_INTERNAL_ERROR)
                    {
                        Failure f = new Failure(new string[] { Messages.ResourceManager.GetString("WLB_ERROR_" + ((Failure)ex).ErrorDescription[1]) });
                        throw (f);
                    }
                    else
                    {
                        throw (ex);
                    }
                }
            }
        }