2013-06-24 13:41:48 +02:00
|
|
|
|
/* Copyright (c) Citrix Systems Inc.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-12-05 13:46:39 +01:00
|
|
|
|
using System.ComponentModel;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using XenAdmin.Alerts;
|
|
|
|
|
using XenAdmin.Network;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Core
|
|
|
|
|
{
|
|
|
|
|
public class Updates
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
2013-11-21 15:27:34 +01:00
|
|
|
|
public static event Action<bool, string> CheckForUpdatesCompleted;
|
2013-12-05 13:46:39 +01:00
|
|
|
|
public static event Action CheckForUpdatesStarted;
|
2013-11-21 15:27:34 +01:00
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
private static readonly object downloadedUpdatesLock = new object();
|
2013-12-05 13:46:39 +01:00
|
|
|
|
private static List<XenServerVersion> XenServerVersions = new List<XenServerVersion>();
|
|
|
|
|
private static List<XenServerPatch> XenServerPatches = new List<XenServerPatch>();
|
2014-01-08 14:17:02 +01:00
|
|
|
|
private static List<XenCenterVersion> XenCenterVersions = new List<XenCenterVersion>();
|
2013-12-05 13:46:39 +01:00
|
|
|
|
|
|
|
|
|
private static readonly object updateAlertsLock = new object();
|
|
|
|
|
private static readonly ChangeableList<Alert> updateAlerts = new ChangeableList<Alert>();
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<Alert> UpdateAlerts
|
2013-11-21 15:27:34 +01:00
|
|
|
|
{
|
|
|
|
|
get { return updateAlerts; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
public static int UpdateAlertsCount
|
|
|
|
|
{
|
|
|
|
|
get { return updateAlerts.Count; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddUpate(Alert update)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (updateAlertsLock)
|
|
|
|
|
updateAlerts.Add(update);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.Error("Failed to add update", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void RemoveUpdate(Alert update)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (updateAlertsLock)
|
|
|
|
|
updateAlerts.Remove(update);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.Error("Failed to remove update", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Alert FindUpdate(Alert alert)
|
|
|
|
|
{
|
|
|
|
|
lock (updateAlertsLock)
|
|
|
|
|
return FindUpdate(a => a.Equals(alert));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Alert FindUpdate(Predicate<Alert> predicate)
|
|
|
|
|
{
|
|
|
|
|
lock (updateAlertsLock)
|
|
|
|
|
return updateAlerts.Find(predicate);
|
|
|
|
|
}
|
2013-11-21 15:27:34 +01:00
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// If AutomaticCheck is enabled it checks for updates regardless the
|
|
|
|
|
/// value of the parameter force. If AutomaticCheck is disabled it only
|
|
|
|
|
/// checks if force is true.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void CheckForUpdates(bool force)
|
|
|
|
|
{
|
|
|
|
|
if (Helpers.CommonCriteriaCertificationRelease)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (Properties.Settings.Default.AllowXenCenterUpdates ||
|
|
|
|
|
Properties.Settings.Default.AllowXenServerUpdates ||
|
|
|
|
|
Properties.Settings.Default.AllowPatchesUpdates || force)
|
|
|
|
|
{
|
|
|
|
|
DownloadUpdatesXmlAction action = new DownloadUpdatesXmlAction(
|
|
|
|
|
Properties.Settings.Default.AllowXenCenterUpdates || force,
|
|
|
|
|
Properties.Settings.Default.AllowXenServerUpdates || force,
|
|
|
|
|
Properties.Settings.Default.AllowPatchesUpdates || force);
|
|
|
|
|
{
|
|
|
|
|
action.Completed += actionCompleted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CheckForUpdatesStarted != null)
|
|
|
|
|
CheckForUpdatesStarted();
|
|
|
|
|
|
|
|
|
|
action.RunAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-21 15:27:34 +01:00
|
|
|
|
private static void actionCompleted(ActionBase sender)
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOffEventThread();
|
2013-12-05 13:46:39 +01:00
|
|
|
|
|
2013-11-21 15:27:34 +01:00
|
|
|
|
DownloadUpdatesXmlAction action = sender as DownloadUpdatesXmlAction;
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (action == null)
|
|
|
|
|
return;
|
2013-11-21 15:27:34 +01:00
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
bool succeeded = action.Succeeded;
|
2013-11-21 15:27:34 +01:00
|
|
|
|
string errorMessage = string.Empty;
|
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
lock (updateAlertsLock)
|
2013-11-21 15:27:34 +01:00
|
|
|
|
updateAlerts.Clear();
|
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (succeeded)
|
|
|
|
|
{
|
2014-01-08 14:17:02 +01:00
|
|
|
|
lock (downloadedUpdatesLock)
|
|
|
|
|
{
|
|
|
|
|
var xcvs = action.XenCenterVersions.Where(v => !XenCenterVersions.Contains(v));
|
|
|
|
|
XenCenterVersions.AddRange(xcvs);
|
|
|
|
|
|
|
|
|
|
var vers = action.XenServerVersions.Where(v => !XenServerVersions.Contains(v));
|
|
|
|
|
XenServerVersions.AddRange(vers);
|
2013-11-21 15:27:34 +01:00
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var patches = action.XenServerPatches.Where(p => !XenServerPatches.Contains(p));
|
|
|
|
|
XenServerPatches.AddRange(patches);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var xenCenterAlert = NewXenCenterUpdateAlert(XenCenterVersions, Program.Version);
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (xenCenterAlert != null)
|
|
|
|
|
updateAlerts.Add(xenCenterAlert);
|
2013-11-21 15:27:34 +01:00
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var xenServerUpdateAlert = NewXenServerVersionAlert(XenServerVersions);
|
|
|
|
|
if (xenServerUpdateAlert != null && !xenServerUpdateAlert.CanIgnore)
|
2013-12-05 13:46:39 +01:00
|
|
|
|
updateAlerts.Add(xenServerUpdateAlert);
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (xenServerPatchAlerts != null)
|
2014-01-08 14:17:02 +01:00
|
|
|
|
updateAlerts.AddRange(xenServerPatchAlerts.Where(alert => !alert.CanIgnore));
|
2013-12-05 13:46:39 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (action.Exception != null)
|
2013-11-21 15:27:34 +01:00
|
|
|
|
{
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (action.Exception is System.Net.Sockets.SocketException)
|
2013-11-21 15:27:34 +01:00
|
|
|
|
{
|
2013-12-05 13:46:39 +01:00
|
|
|
|
errorMessage = Messages.AVAILABLE_UPDATES_NETWORK_ERROR;
|
2013-11-21 15:27:34 +01:00
|
|
|
|
}
|
2013-12-05 13:46:39 +01:00
|
|
|
|
else
|
2013-11-21 15:27:34 +01:00
|
|
|
|
{
|
2013-12-05 13:46:39 +01:00
|
|
|
|
// Clean up and remove excess newlines, carriage returns, trailing nonsense
|
|
|
|
|
string errorText = action.Exception.Message.Trim();
|
|
|
|
|
errorText = System.Text.RegularExpressions.Regex.Replace(errorText, @"\r\n+", "");
|
|
|
|
|
errorMessage = string.Format(Messages.AVAILABLE_UPDATES_ERROR, errorText);
|
2013-11-21 15:27:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 13:46:39 +01:00
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(errorMessage))
|
|
|
|
|
errorMessage = Messages.AVAILABLE_UPDATES_INTERNAL_ERROR;
|
2013-11-21 15:27:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CheckForUpdatesCompleted != null)
|
|
|
|
|
CheckForUpdatesCompleted(succeeded, errorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
public static void RegisterCollectionChanged(CollectionChangeEventHandler handler)
|
|
|
|
|
{
|
|
|
|
|
updateAlerts.CollectionChanged += handler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DeregisterCollectionChanged(CollectionChangeEventHandler handler)
|
|
|
|
|
{
|
|
|
|
|
updateAlerts.CollectionChanged -= handler;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-12-05 13:59:38 +01:00
|
|
|
|
public static XenCenterUpdateAlert NewXenCenterUpdateAlert(List<XenCenterVersion> xenCenterVersions, Version currentProgramVersion)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (Helpers.CommonCriteriaCertificationRelease)
|
|
|
|
|
return null;
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
XenCenterVersion toUse = null;
|
|
|
|
|
if (xenCenterVersions.Count != 0 && currentProgramVersion != new Version(0, 0, 0, 0))
|
|
|
|
|
{
|
|
|
|
|
var latest = from v in xenCenterVersions where v.IsLatest select v;
|
|
|
|
|
|
|
|
|
|
toUse = latest.FirstOrDefault(xcv => xcv.Lang == Program.CurrentLanguage) ??
|
|
|
|
|
latest.FirstOrDefault(xcv => string.IsNullOrEmpty(xcv.Lang));
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (toUse == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if (toUse.Version > currentProgramVersion ||
|
|
|
|
|
(toUse.Version == currentProgramVersion && toUse.Lang == Program.CurrentLanguage &&
|
|
|
|
|
!PropertyManager.IsCultureLoaded(Program.CurrentCulture)))
|
|
|
|
|
{
|
|
|
|
|
return new XenCenterUpdateAlert(toUse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Info(string.Format("Not alerting XenCenter update - lastest = {0}, detected = {1}",
|
|
|
|
|
toUse.VersionAndLang, Program.VersionAndLanguage));
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 13:59:38 +01:00
|
|
|
|
public static List<XenServerPatchAlert> NewXenServerPatchAlerts(List<XenServerVersion> xenServerVersions,
|
2013-12-05 12:34:16 +01:00
|
|
|
|
List<XenServerPatch> xenServerPatches)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (Helpers.CommonCriteriaCertificationRelease)
|
|
|
|
|
return null;
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var alerts = new List<XenServerPatchAlert>();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy)
|
|
|
|
|
{
|
|
|
|
|
Host master = Helpers.GetMaster(xenConnection);
|
|
|
|
|
Pool pool = Helpers.GetPoolOfOne(xenConnection);
|
|
|
|
|
List<Host> hosts = xenConnection.Cache.Hosts.ToList();
|
|
|
|
|
if (master == null || pool == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var serverVersions = xenServerVersions.FindAll(version =>
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (version.BuildNumber != string.Empty)
|
|
|
|
|
return (master.BuildNumberRaw == version.BuildNumber);
|
|
|
|
|
|
|
|
|
|
return Helpers.HostProductVersionWithOEM(master) == version.VersionAndOEM
|
|
|
|
|
|| (version.Oem != null && Helpers.OEMName(master).StartsWith(version.Oem)
|
|
|
|
|
&& Helpers.HostProductVersion(master) == version.Version.ToString());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (serverVersions.Count == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (XenServerVersion xenServerVersion in serverVersions)
|
|
|
|
|
{
|
|
|
|
|
XenServerVersion version = xenServerVersion;
|
|
|
|
|
List<XenServerPatch> patches = xenServerPatches.FindAll(patch => version.Patches.Contains(patch));
|
|
|
|
|
|
|
|
|
|
if (patches.Count == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (XenServerPatch xenServerPatch in patches)
|
|
|
|
|
{
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var alert = new XenServerPatchAlert(xenServerPatch);
|
|
|
|
|
var existingAlert = alerts.Find(al => al.Equals(alert));
|
|
|
|
|
|
|
|
|
|
if (existingAlert != null)
|
|
|
|
|
alert = existingAlert;
|
|
|
|
|
else
|
|
|
|
|
alerts.Add(alert);
|
|
|
|
|
|
|
|
|
|
if (!xenConnection.IsConnected)
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
XenServerPatch serverPatch = xenServerPatch;
|
2014-02-17 10:31:57 +01:00
|
|
|
|
|
|
|
|
|
// A patch can be installed on a host if:
|
|
|
|
|
// 1. it is not already installed and
|
|
|
|
|
// 2. the host has all the required patches installed and
|
|
|
|
|
// 3. the host doesn't have any of the conflicting patches installed
|
|
|
|
|
|
|
|
|
|
var noPatchHosts = hosts.Where(host =>
|
|
|
|
|
{
|
|
|
|
|
var appliedPatches = host.AppliedPatches();
|
|
|
|
|
// 1. patch is not already installed
|
|
|
|
|
if (appliedPatches.Any(patch => patch.uuid == serverPatch.Uuid))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// 2. the host has all the required patches installed
|
|
|
|
|
if (serverPatch.RequiredPatches != null && serverPatch.RequiredPatches.Count > 0 &&
|
|
|
|
|
!serverPatch.RequiredPatches.All(requiredPatchUuid => appliedPatches.Any(patch => patch.uuid == requiredPatchUuid)))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// 3. the host doesn't have any of the conflicting patches installed
|
|
|
|
|
if (serverPatch.ConflictingPatches != null && serverPatch.ConflictingPatches.Count > 0 &&
|
|
|
|
|
serverPatch.ConflictingPatches.Any(conflictingPatchUuid => appliedPatches.Any(patch => patch.uuid == conflictingPatchUuid)))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-12-05 13:03:34 +01:00
|
|
|
|
if (noPatchHosts.Count() == hosts.Count)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
alert.IncludeConnection(xenConnection);
|
|
|
|
|
else
|
|
|
|
|
alert.IncludeHosts(noPatchHosts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return alerts;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-03 09:37:45 +01:00
|
|
|
|
public static XenServerVersionAlert NewXenServerVersionAlert(List<XenServerVersion> xenServerVersions)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (Helpers.CommonCriteriaCertificationRelease)
|
|
|
|
|
return null;
|
|
|
|
|
|
2013-12-05 13:03:34 +01:00
|
|
|
|
var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault();
|
|
|
|
|
if (latestVersion == null)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return null;
|
2014-01-03 09:37:45 +01:00
|
|
|
|
|
|
|
|
|
var alert = new XenServerVersionAlert(latestVersion);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
|
|
|
|
|
{
|
2014-01-08 14:17:02 +01:00
|
|
|
|
if (!xc.IsConnected)
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
Host master = Helpers.GetMaster(xc);
|
|
|
|
|
Pool pool = Helpers.GetPoolOfOne(xc);
|
|
|
|
|
List<Host> hosts = xc.Cache.Hosts.ToList();
|
|
|
|
|
if (master == null || pool == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-12-05 13:03:34 +01:00
|
|
|
|
var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-12-05 13:03:34 +01:00
|
|
|
|
if (outOfDateHosts.Count() == hosts.Count)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
alert.IncludeConnection(xc);
|
|
|
|
|
else
|
|
|
|
|
alert.IncludeHosts(outOfDateHosts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return alert;
|
|
|
|
|
}
|
2013-12-05 13:46:39 +01:00
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
|
2013-12-05 13:46:39 +01:00
|
|
|
|
public static void CheckServerVersion()
|
|
|
|
|
{
|
2014-01-03 09:37:45 +01:00
|
|
|
|
var alert = NewXenServerVersionAlert(XenServerVersions);
|
2013-12-05 13:46:39 +01:00
|
|
|
|
if (alert == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-08 14:17:02 +01:00
|
|
|
|
CheckUpdate(alert);
|
2013-12-05 13:46:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void CheckServerPatches()
|
|
|
|
|
{
|
2014-01-08 14:17:02 +01:00
|
|
|
|
var alerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
|
|
|
|
|
if (alerts == null)
|
2013-12-05 13:46:39 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
foreach (var alert in alerts)
|
2014-01-08 14:17:02 +01:00
|
|
|
|
CheckUpdate(alert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CheckUpdate(XenServerUpdateAlert alert)
|
|
|
|
|
{
|
|
|
|
|
var existingAlert = FindUpdate(alert);
|
|
|
|
|
|
|
|
|
|
if (existingAlert != null && alert.CanIgnore)
|
|
|
|
|
RemoveUpdate(existingAlert);
|
|
|
|
|
else if (existingAlert != null)
|
|
|
|
|
((XenServerUpdateAlert)existingAlert).CopyConnectionsAndHosts(alert);
|
|
|
|
|
else if (!alert.CanIgnore)
|
|
|
|
|
AddUpate(alert);
|
2013-12-05 13:46:39 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|