Exemplo n.º 1
0
        public static UpgradeSequence GetUpgradeSequence(IXenConnection conn)
        {
            if (XenServerVersions == null)
            {
                return(null);
            }

            Host master = Helpers.GetMaster(conn);

            if (master == null)
            {
                return(null);
            }

            var version = GetCommonServerVersionOfHostsInAConnection(conn, XenServerVersions);

            if (version != null)
            {
                if (version.MinimalPatches == null)
                {
                    return(null);
                }

                var uSeq = new UpgradeSequence();
                uSeq.MinimalPatches = new List <XenServerPatch>(version.MinimalPatches);

                // if there is a "new version" update in the update sequence, also add the minimal patches of this new version
                if (uSeq.MinimalPatches.Count > 0)
                {
                    // assuming that the new version update (if there is one) is the last one in the minimal patches list
                    var lastUpdate = uSeq.MinimalPatches[uSeq.MinimalPatches.Count - 1];

                    var newServerVersion = XenServerVersions.FirstOrDefault(
                        v => v.IsVersionAvailableAsAnUpdate && v.PatchUuid.Equals(lastUpdate.Uuid, StringComparison.OrdinalIgnoreCase));

                    if (newServerVersion != null && newServerVersion.MinimalPatches != null)
                    {
                        uSeq.MinimalPatches.AddRange(newServerVersion.MinimalPatches);
                    }
                }

                List <Host> hosts = conn.Cache.Hosts.ToList();

                foreach (Host h in hosts)
                {
                    uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches);
                }

                return(uSeq);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets an upgrade sequence that contains a version upgrade, optionally followed by the minimal patches for the new version
        /// </summary>
        /// <param name="conn">Connection for the pool</param>
        /// <param name="alert">The alert that refers the version-update</param>
        /// <param name="updateTheNewVersion">Also add the minimum patches for the new version (true) or not (false).</param>
        /// <returns></returns>
        public static UpgradeSequence GetUpgradeSequence(IXenConnection conn, XenServerPatchAlert alert, bool updateTheNewVersion)
        {
            Debug.Assert(conn != null);
            Debug.Assert(alert != null);

            var uSeq = new UpgradeSequence();

            if (XenServerVersions == null)
            {
                return(null);
            }

            Host master = Helpers.GetMaster(conn);

            if (master == null)
            {
                return(null);
            }

            var version = GetCommonServerVersionOfHostsInAConnection(conn, XenServerVersions);

            // the pool has to be homogeneous
            if (version != null)
            {
                uSeq.MinimalPatches = new List <XenServerPatch>();
                uSeq.MinimalPatches.Add(alert.Patch);

                // if it's a version updgrade the min sequence will be this patch (the upgrade) and the min patches for the new version
                if (updateTheNewVersion && alert.NewServerVersion != null && alert.NewServerVersion.MinimalPatches != null)
                {
                    uSeq.MinimalPatches.AddRange(alert.NewServerVersion.MinimalPatches);
                }

                conn.Cache.Hosts.ToList().ForEach(h =>
                                                  uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches)
                                                  );

                return(uSeq);
            }

            return(null);
        }
Exemplo n.º 3
0
        public static UpgradeSequence GetUpgradeSequence(IXenConnection conn)
        {
            if (XenServerVersions == null)
            {
                return(null);
            }

            Host master = Helpers.GetMaster(conn);

            if (master == null)
            {
                return(null);
            }

            var version = GetCommonServerVersionOfHostsInAConnection(conn, XenServerVersions);

            if (version != null)
            {
                if (version.MinimalPatches == null)
                {
                    return(null);
                }

                var uSeq = new UpgradeSequence();
                uSeq.MinimalPatches = version.MinimalPatches;

                List <Host> hosts = conn.Cache.Hosts.ToList();

                foreach (Host h in hosts)
                {
                    uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches);
                }

                return(uSeq);
            }
            else
            {
                return(null);
            }
        }