Example #1
0
        private void ReconfigureManagementInterfaces(List <PIF> slaves, PIF new_master, int hi)
        {
            int lo  = PercentComplete;
            int inc = (hi - lo) / slaves.Count;

            foreach (PIF pif in slaves)
            {
                lo += inc;

                // In Boston and later, the only thing we need to do is move the ManagementPurpose
                // (= management interface name) to the bond (see PR-1006/CP-2059).
                if (bostonOrGreater)
                {
                    NetworkingActionHelpers.MoveManagementInterfaceName(this, pif, new_master);
                }
                else if (pif.management)
                {
                    log.DebugFormat("Moving primary management interface to {0}...", pif.uuid);
                    NetworkingActionHelpers.ReconfigureSinglePrimaryManagement(this, pif, new_master, lo);
                    log.DebugFormat("Moving primary management interface to {0} done.", pif.uuid);
                }
                else if (pif.IsSecondaryManagementInterface(true))
                {
                    log.DebugFormat("Moving secondary management interface to {0}...", pif.uuid);
                    ReconfigureSecondaryManagement(pif, new_master, lo);
                    log.DebugFormat("Moving secondary management interface to {0} done.", pif.uuid);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Nothrow guarantee.
        /// </summary>
        /// <param name="slaves"></param>
        /// <param name="master"></param>
        private void RevertManagementInterfaces(NewBond new_bond)
        {
            List <PIF> slaves = new_bond.slaves;
            PIF        master = new_bond.master;
            Bond       bond   = new_bond.bond;

            PIF slave = Connection.Resolve(bond.primary_slave);

            if (slave == null)
            {
                if (slaves.Count == 0)
                {
                    return;
                }
                slave = slaves[0];
            }

            try
            {
                NetworkingActionHelpers.MoveManagementInterfaceName(this, master, slave);
            }
            catch (Exception exn)
            {
                log.Warn(exn, exn);
            }
        }
Example #3
0
        protected override void Run()
        {
            PercentComplete             = 0;
            Connection.ExpectDisruption = true;

            int incr = Masters.Count > 0 ? 50 / Masters.Count : 0;

            try
            {
                foreach (PIF master in Masters)
                {
                    NetworkingActionHelpers.MoveManagementInterfaceName(this, master, FirstSlaves[master]);
                    PercentComplete += incr;
                }
            }
            catch (WebException we)
            {
                //ignore keep-alive failure since disruption is expected
                if (we.Status != WebExceptionStatus.KeepAliveFailure)
                {
                    throw;
                }
            }

            PercentComplete = 50;

            Exception e = null;

            int inc = Bonds.Count > 0 ? 40 / Bonds.Count : 0;

            foreach (Bond bond in Bonds)
            {
                Bond bond1 = bond;
                BestEffort(ref e, delegate() { RelatedTask = Bond.async_destroy(Session, bond1.opaque_ref); });
                PollToCompletion(PercentComplete, PercentComplete + inc);
            }

            PercentComplete = 90;

            if (Network != null)
            {
                string oldNetworkName = Network.Name();

                // Destroy the old network
                log.DebugFormat("Destroying network {0} ({1})...", oldNetworkName, Network.uuid);
                BestEffort(ref e, delegate()
                {
                    XenAPI.Network.destroy(Session, Network.opaque_ref);
                    log.DebugFormat("Network {0} ({1}) destroyed.", oldNetworkName, Network.uuid);
                });
            }

            if (e != null)
            {
                throw e;
            }

            Description = string.Format(Messages.ACTION_DESTROY_BOND_DONE, Name);
        }
        private void ReconfigureManagementInterfaces()
        {
            int progress = 0;
            int inc      = 50 / Masters.Count;

            foreach (PIF master in Masters)
            {
                progress += inc;
                NetworkingActionHelpers.MoveManagementInterfaceName(this, master, FirstSlaves[master]);
            }
        }
Example #5
0
        private void ReconfigureManagementInterfaces(List <PIF> slaves, PIF new_master, int hi)
        {
            int lo  = PercentComplete;
            int inc = (hi - lo) / slaves.Count;

            foreach (PIF pif in slaves)
            {
                lo += inc;
                NetworkingActionHelpers.MoveManagementInterfaceName(this, pif, new_master);
            }
        }
Example #6
0
        protected override void Run()
        {
            PercentComplete             = 0;
            Connection.ExpectDisruption = true;

            int incr = Masters.Count > 0 ? 50 / Masters.Count : 0;

            try
            {
                foreach (PIF master in Masters)
                {
                    NetworkingActionHelpers.MoveManagementInterfaceName(this, master, FirstSlaves[master]);
                    PercentComplete += incr;
                }
            }
            catch (WebException we)
            {
                //ignore keep-alive failure since disruption is expected
                if (we.Status != WebExceptionStatus.KeepAliveFailure)
                {
                    throw;
                }
            }

            PercentComplete = 50;

            var caughtExceptions = new List <Exception>();

            int inc = Bonds.Count > 0 ? 40 / Bonds.Count : 0;

            foreach (Bond bond in Bonds)
            {
                Bond bond1 = bond;
                try
                {
                    RelatedTask = Bond.async_destroy(Session, bond1.opaque_ref);
                }
                catch (Exception exn)
                {
                    if (Connection != null && Connection.ExpectDisruption &&
                        exn is WebException webEx && webEx.Status == WebExceptionStatus.KeepAliveFailure)
                    {
                        //ignore
                    }
Example #7
0
        /// <summary>
        /// Nothrow guarantee.
        /// </summary>
        /// <param name="slaves"></param>
        /// <param name="master"></param>
        private void RevertManagementInterfaces(NewBond new_bond)
        {
            List <PIF> slaves = new_bond.slaves;
            PIF        master = new_bond.master;
            Bond       bond   = new_bond.bond;

            PIF slave = Connection.Resolve(bond.primary_slave);

            if (slave == null)
            {
                if (slaves.Count == 0)
                {
                    return;
                }
                slave = slaves[0];
            }

            try
            {
                if (bostonOrGreater)
                {
                    NetworkingActionHelpers.MoveManagementInterfaceName(this, master, slave);
                }
                else if (master.management)
                {
                    log.DebugFormat("Reverting primary management interface change for {0} as part of cleanup...", master.uuid);
                    NetworkingActionHelpers.ReconfigurePrimaryManagement(this, master, slave, PercentComplete);
                    log.DebugFormat("Reverting primary management interface change for {0} as part of cleanup done.", master.uuid);
                }
                else if (master.IsSecondaryManagementInterface(true))
                {
                    log.DebugFormat("Reverting secondary management interface change for {0} as part of cleanup...", master.uuid);
                    ReconfigureSecondaryManagement(master, slave, PercentComplete);
                    log.DebugFormat("Reverting secondary management interface change for {0} as part of cleanup done.", master.uuid);
                }
            }
            catch (Exception exn)
            {
                log.Warn(exn, exn);
            }
        }
Example #8
0
        private void ReconfigureManagementInterfaces()
        {
            int progress = 0;
            int inc      = 50 / Masters.Count;

            foreach (PIF master in Masters)
            {
                progress += inc;
                if (bostonOrGreater)
                {
                    NetworkingActionHelpers.MoveManagementInterfaceName(this, master, FirstSlaves[master]);
                }
                else if (master.management)
                {
                    ReconfigurePrimaryManagement(master, progress);
                }
                else if (master.IsSecondaryManagementInterface(true))
                {
                    DeconfigureSecondaryManagement(master, progress);
                }
            }
        }