mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
CP-23454: Export function in "By Host" view
Signed-off-by: Ji Jiang <ji.jiang@citrix.com>
This commit is contained in:
parent
8b2bc83a12
commit
b5a8282089
@ -343,16 +343,17 @@ namespace XenAdmin.TabPages
|
||||
}
|
||||
}
|
||||
|
||||
private string RecommendedPatchesForHost(Host host)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var recommendedPatches = Updates.RecommendedPatchesForHost(host);
|
||||
}
|
||||
|
||||
foreach (var patch in recommendedPatches)
|
||||
result.Add(patch.Name);
|
||||
private static string RecommendedPatchesForHost(Host host)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var recommendedPatches = Updates.RecommendedPatchesForHost(host);
|
||||
|
||||
return string.Join(", ", result.ToArray());
|
||||
}
|
||||
foreach (var patch in recommendedPatches)
|
||||
result.Add(patch.Name);
|
||||
|
||||
return string.Join(", ", result.ToArray());
|
||||
}
|
||||
|
||||
private void RebuildHostView()
|
||||
@ -1151,28 +1152,87 @@ namespace XenAdmin.TabPages
|
||||
{
|
||||
using (StreamWriter stream = new StreamWriter(fileName, false, UTF8Encoding.UTF8))
|
||||
{
|
||||
stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
|
||||
Messages.DESCRIPTION, Messages.APPLIES_TO,
|
||||
Messages.TIMESTAMP, Messages.WEB_PAGE);
|
||||
if (byUpdateToolStripMenuItem.Checked) // update view
|
||||
{
|
||||
stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
|
||||
Messages.DESCRIPTION, Messages.APPLIES_TO,
|
||||
Messages.TIMESTAMP, Messages.WEB_PAGE);
|
||||
|
||||
if (exportAll)
|
||||
{
|
||||
foreach (Alert a in Updates.UpdateAlerts)
|
||||
stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataGridViewRow row in dataGridViewUpdates.Rows)
|
||||
if (exportAll)
|
||||
{
|
||||
var a = row.Tag as Alert;
|
||||
if (a != null)
|
||||
foreach (Alert a in Updates.UpdateAlerts)
|
||||
stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataGridViewRow row in dataGridViewUpdates.Rows)
|
||||
{
|
||||
var a = row.Tag as Alert;
|
||||
if (a != null)
|
||||
stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
|
||||
}
|
||||
}
|
||||
}
|
||||
else // host view
|
||||
{
|
||||
stream.WriteLine("{0},{1},{2},{3},{4},{5}", Messages.POOL,
|
||||
Messages.SERVER, Messages.VERSION, Messages.PATCHING_STATUS,
|
||||
Messages.REQUIRED_UPDATES, Messages.INSTALLED_UPDATES);
|
||||
|
||||
if (exportAll)
|
||||
{
|
||||
List<IXenConnection> xenConnections = ConnectionsManager.XenConnectionsCopy;
|
||||
xenConnections.Sort();
|
||||
|
||||
foreach (IXenConnection xenConnection in xenConnections)
|
||||
{
|
||||
Pool pool = Helpers.GetPool(xenConnection);
|
||||
var hasPool = (pool != null);
|
||||
|
||||
Host[] hosts = xenConnection.Cache.Hosts;
|
||||
Array.Sort(hosts);
|
||||
foreach (Host host in hosts)
|
||||
stream.WriteLine(GetHostUpdateDetailsCsvQuotes(xenConnection, host, hasPool));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (UpdatePageDataGridViewRow row in dataGridViewHosts.Rows)
|
||||
{
|
||||
Host host = row.Tag as Host;
|
||||
if (host != null)
|
||||
stream.WriteLine(GetHostUpdateDetailsCsvQuotes(host.Connection, host, row.HasPool));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).RunAsync();
|
||||
}
|
||||
|
||||
private string GetHostUpdateDetailsCsvQuotes(IXenConnection xenConnection, Host host, bool hasPool)
|
||||
{
|
||||
string pool = String.Empty;
|
||||
string patchingStatus = String.Empty;
|
||||
string requiredUpdates = String.Empty;
|
||||
string installedUpdates = String.Empty;
|
||||
|
||||
Program.Invoke(Program.MainWindow, delegate
|
||||
{
|
||||
pool = hasPool ? Helpers.GetPool(xenConnection).Name : String.Empty;
|
||||
patchingStatus = Updates.RecommendedPatchesForHost(host).Count > 0 ? Messages.NOT_UPDATED : Messages.UPDATED;
|
||||
requiredUpdates = RecommendedPatchesForHost(host);
|
||||
installedUpdates = string.Join(", ", Helpers.HostAppliedPatchesList(host).ToArray());
|
||||
});
|
||||
|
||||
return String.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\"",
|
||||
pool.EscapeQuotes(),
|
||||
host.Name.EscapeQuotes(),
|
||||
host.ProductVersionTextShort.EscapeQuotes(),
|
||||
patchingStatus.EscapeQuotes(),
|
||||
requiredUpdates.EscapeQuotes(),
|
||||
installedUpdates.EscapeQuotes());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
36
XenModel/Messages.Designer.cs
generated
36
XenModel/Messages.Designer.cs
generated
@ -18963,6 +18963,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Installed Updates.
|
||||
/// </summary>
|
||||
public static string INSTALLED_UPDATES {
|
||||
get {
|
||||
return ResourceManager.GetString("INSTALLED_UPDATES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not find a CD drive on the selected VM..
|
||||
/// </summary>
|
||||
@ -26260,6 +26269,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Patching Status.
|
||||
/// </summary>
|
||||
public static string PATCHING_STATUS {
|
||||
get {
|
||||
return ResourceManager.GetString("PATCHING_STATUS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Disable HA until after all the hosts have been rebooted.
|
||||
/// </summary>
|
||||
@ -29206,6 +29224,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Required Updates.
|
||||
/// </summary>
|
||||
public static string REQUIRED_UPDATES {
|
||||
get {
|
||||
return ResourceManager.GetString("REQUIRED_UPDATES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Resolved as {0}.
|
||||
/// </summary>
|
||||
@ -35084,6 +35111,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version.
|
||||
/// </summary>
|
||||
public static string VERSION {
|
||||
get {
|
||||
return ResourceManager.GetString("VERSION", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to [XenCenter] version {0} (build {1}.{2}) {3}-bit.
|
||||
/// </summary>
|
||||
|
@ -6587,6 +6587,9 @@ Click Configure HA to alter the settings displayed below.</value>
|
||||
<data name="INITIALIZING_WLB_ON" xml:space="preserve">
|
||||
<value>Connecting pool {0} to Workload Balancing server.</value>
|
||||
</data>
|
||||
<data name="INSTALLED_UPDATES" xml:space="preserve">
|
||||
<value>Installed Updates</value>
|
||||
</data>
|
||||
<data name="INSTALLTOOLS_COULDNOTFIND_CD" xml:space="preserve">
|
||||
<value>Could not find a CD drive on the selected VM.</value>
|
||||
</data>
|
||||
@ -9331,6 +9334,9 @@ Please wait for this operation to complete, then click Next to continue with the
|
||||
<data name="PATCHING_EJECT_CDS" xml:space="preserve">
|
||||
<value>Eject any virtual CDs from your VMs</value>
|
||||
</data>
|
||||
<data name="PATCHING_STATUS" xml:space="preserve">
|
||||
<value>Patching Status</value>
|
||||
</data>
|
||||
<data name="PATCHING_WARNING_HA" xml:space="preserve">
|
||||
<value>Disable HA until after all the hosts have been rebooted</value>
|
||||
</data>
|
||||
@ -10157,6 +10163,9 @@ Click Server Status Report to open the Compile Server Status Report Wizard or cl
|
||||
<data name="REQUIRED_HOTFIX_ISNOT_INSTALLED" xml:space="preserve">
|
||||
<value>{0}: The required hotfix is not installed</value>
|
||||
</data>
|
||||
<data name="REQUIRED_UPDATES" xml:space="preserve">
|
||||
<value>Required Updates</value>
|
||||
</data>
|
||||
<data name="RESOLVED_AS" xml:space="preserve">
|
||||
<value>Resolved as {0}</value>
|
||||
</data>
|
||||
@ -12156,6 +12165,9 @@ To learn more about the [XenServer] Dynamic Workload Balancing feature or to sta
|
||||
<data name="VERIFYING_SIGNATURE_ERROR" xml:space="preserve">
|
||||
<value>Signature verification failed. {0}</value>
|
||||
</data>
|
||||
<data name="VERSION" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
<data name="VERSION_NUMBER" xml:space="preserve">
|
||||
<value>[XenCenter] version {0} (build {1}.{2}) {3}-bit</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user