mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
CA-67866: Step 2 - moved code common to XenServerPatchAlert and XenServerVersionAlert
to a base class XenServerUpdateAlert. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
0eaf776399
commit
cc78711c56
@ -40,10 +40,8 @@ using XenAPI;
|
|||||||
|
|
||||||
namespace XenAdmin.Alerts
|
namespace XenAdmin.Alerts
|
||||||
{
|
{
|
||||||
public class XenServerPatchAlert : Alert
|
public class XenServerPatchAlert : XenServerUpdateAlert
|
||||||
{
|
{
|
||||||
private readonly List<IXenConnection> connections = new List<IXenConnection>();
|
|
||||||
private readonly List<Host> hosts = new List<Host>();
|
|
||||||
public List<Host> Hosts
|
public List<Host> Hosts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -60,10 +58,6 @@ namespace XenAdmin.Alerts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool canIgnore;
|
|
||||||
public bool CanIgnore
|
|
||||||
{ get { return canIgnore; } }
|
|
||||||
|
|
||||||
public XenServerPatch Patch;
|
public XenServerPatch Patch;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -111,29 +105,6 @@ namespace XenAdmin.Alerts
|
|||||||
canIgnore = true;
|
canIgnore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncludeConnection(IXenConnection newConnection)
|
|
||||||
{
|
|
||||||
connections.Add(newConnection);
|
|
||||||
if (connections.Count > 0)
|
|
||||||
canIgnore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IncludeHosts(IEnumerable<Host> newHosts)
|
|
||||||
{
|
|
||||||
hosts.AddRange(newHosts);
|
|
||||||
if (hosts.Count > 0)
|
|
||||||
canIgnore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyConnectionsAndHosts(XenServerPatchAlert alert)
|
|
||||||
{
|
|
||||||
connections.Clear();
|
|
||||||
connections.AddRange(alert.connections);
|
|
||||||
hosts.Clear();
|
|
||||||
hosts.AddRange(alert.hosts);
|
|
||||||
canIgnore = connections.Count == 0 && hosts.Count == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string WebPageLabel
|
public override string WebPageLabel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -154,22 +125,6 @@ namespace XenAdmin.Alerts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string AppliesTo
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
|
|
||||||
foreach (Host host in hosts)
|
|
||||||
names.Add(host.Name);
|
|
||||||
|
|
||||||
foreach (IXenConnection connection in connections)
|
|
||||||
names.Add(Helpers.GetName(connection));
|
|
||||||
|
|
||||||
return string.Join(", ", names.ToArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Description
|
public override string Description
|
||||||
{
|
{
|
||||||
get { return Patch.Description; }
|
get { return Patch.Description; }
|
||||||
@ -218,10 +173,8 @@ namespace XenAdmin.Alerts
|
|||||||
{
|
{
|
||||||
base.Dismiss();
|
base.Dismiss();
|
||||||
foreach (IXenConnection connection in connections)
|
foreach (IXenConnection connection in connections)
|
||||||
{
|
|
||||||
new IgnorePatchAction(connection, Patch).RunAsync();
|
new IgnorePatchAction(connection, Patch).RunAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(Alert other)
|
public override bool Equals(Alert other)
|
||||||
{
|
{
|
||||||
|
93
XenAdmin/Alerts/Types/XenServerUpdateAlert.cs
Normal file
93
XenAdmin/Alerts/Types/XenServerUpdateAlert.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* 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;
|
||||||
|
using System.Linq;
|
||||||
|
using XenAdmin.Network;
|
||||||
|
using XenAdmin.Actions;
|
||||||
|
using XenAdmin.Core;
|
||||||
|
using XenAPI;
|
||||||
|
|
||||||
|
|
||||||
|
namespace XenAdmin.Alerts
|
||||||
|
{
|
||||||
|
public abstract class XenServerUpdateAlert : Alert
|
||||||
|
{
|
||||||
|
protected readonly List<IXenConnection> connections = new List<IXenConnection>();
|
||||||
|
protected readonly List<Host> hosts = new List<Host>();
|
||||||
|
|
||||||
|
protected bool canIgnore;
|
||||||
|
public bool CanIgnore
|
||||||
|
{
|
||||||
|
get { return canIgnore; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IncludeConnection(IXenConnection newConnection)
|
||||||
|
{
|
||||||
|
connections.Add(newConnection);
|
||||||
|
if (connections.Count > 0)
|
||||||
|
canIgnore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IncludeHosts(IEnumerable<Host> newHosts)
|
||||||
|
{
|
||||||
|
hosts.AddRange(newHosts);
|
||||||
|
if (hosts.Count > 0)
|
||||||
|
canIgnore = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyConnectionsAndHosts(XenServerUpdateAlert alert)
|
||||||
|
{
|
||||||
|
connections.Clear();
|
||||||
|
connections.AddRange(alert.connections);
|
||||||
|
hosts.Clear();
|
||||||
|
hosts.AddRange(alert.hosts);
|
||||||
|
canIgnore = connections.Count == 0 && hosts.Count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string AppliesTo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<string> names = new List<string>();
|
||||||
|
|
||||||
|
foreach (Host host in hosts)
|
||||||
|
names.Add(host.Name);
|
||||||
|
|
||||||
|
foreach (IXenConnection connection in connections)
|
||||||
|
names.Add(Helpers.GetName(connection));
|
||||||
|
|
||||||
|
return string.Join(", ", names.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,15 +40,8 @@ using XenAPI;
|
|||||||
|
|
||||||
namespace XenAdmin.Alerts
|
namespace XenAdmin.Alerts
|
||||||
{
|
{
|
||||||
public class XenServerVersionAlert : Alert
|
public class XenServerVersionAlert : XenServerUpdateAlert
|
||||||
{
|
{
|
||||||
private readonly List<IXenConnection> connections = new List<IXenConnection>();
|
|
||||||
private readonly List<Host> hosts = new List<Host>();
|
|
||||||
|
|
||||||
private bool canIgnore;
|
|
||||||
public bool CanIgnore
|
|
||||||
{ get { return canIgnore; } }
|
|
||||||
|
|
||||||
public XenServerVersion Version;
|
public XenServerVersion Version;
|
||||||
|
|
||||||
public XenServerVersionAlert(XenServerVersion version)
|
public XenServerVersionAlert(XenServerVersion version)
|
||||||
@ -58,29 +51,6 @@ namespace XenAdmin.Alerts
|
|||||||
canIgnore = true;
|
canIgnore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncludeConnection(IXenConnection newConnection)
|
|
||||||
{
|
|
||||||
connections.Add(newConnection);
|
|
||||||
if (connections.Count > 0)
|
|
||||||
canIgnore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IncludeHosts(IEnumerable<Host> newHosts)
|
|
||||||
{
|
|
||||||
hosts.AddRange(newHosts);
|
|
||||||
if (hosts.Count > 0)
|
|
||||||
canIgnore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyConnectionsAndHosts(XenServerVersionAlert alert)
|
|
||||||
{
|
|
||||||
connections.Clear();
|
|
||||||
connections.AddRange(alert.connections);
|
|
||||||
hosts.Clear();
|
|
||||||
hosts.AddRange(alert.hosts);
|
|
||||||
canIgnore = connections.Count == 0 && hosts.Count == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string WebPageLabel
|
public override string WebPageLabel
|
||||||
{
|
{
|
||||||
get { return Messages.AVAILABLE_UPDATES_DOWNLOAD_TEXT; }
|
get { return Messages.AVAILABLE_UPDATES_DOWNLOAD_TEXT; }
|
||||||
@ -111,22 +81,6 @@ namespace XenAdmin.Alerts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string AppliesTo
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
|
|
||||||
foreach (Host host in hosts)
|
|
||||||
names.Add(host.Name);
|
|
||||||
|
|
||||||
foreach (IXenConnection connection in connections)
|
|
||||||
names.Add(Helpers.GetName(connection));
|
|
||||||
|
|
||||||
return string.Join(", ", names.ToArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string FixLinkText
|
public override string FixLinkText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -113,6 +113,7 @@
|
|||||||
<Compile Include="Actions\GUIActions\SaveDataSourceStateAction.cs" />
|
<Compile Include="Actions\GUIActions\SaveDataSourceStateAction.cs" />
|
||||||
<Compile Include="Actions\GUIActions\SearchAction.cs" />
|
<Compile Include="Actions\GUIActions\SearchAction.cs" />
|
||||||
<Compile Include="Alerts\Types\AlarmMessageAlert.cs" />
|
<Compile Include="Alerts\Types\AlarmMessageAlert.cs" />
|
||||||
|
<Compile Include="Alerts\Types\XenServerUpdateAlert.cs" />
|
||||||
<Compile Include="Alerts\Types\DuplicateIqnAlert.cs" />
|
<Compile Include="Alerts\Types\DuplicateIqnAlert.cs" />
|
||||||
<Compile Include="Alerts\Types\MissingIqnAlert.cs" />
|
<Compile Include="Alerts\Types\MissingIqnAlert.cs" />
|
||||||
<Compile Include="Alerts\Types\GuiOldAlert.cs" />
|
<Compile Include="Alerts\Types\GuiOldAlert.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user