From 0963f8ccd2002d20bb50965567d09af68ce2294e Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Fri, 6 Nov 2015 15:01:31 +0000 Subject: [PATCH] CA-186234: Group the issues found in a pool when retrieving CIS analysis results for a pool Signed-off-by: Mihaela Stoica --- .../GetHealthCheckAnalysisResultAction.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/XenModel/Actions/HealthCheck/GetHealthCheckAnalysisResultAction.cs b/XenModel/Actions/HealthCheck/GetHealthCheckAnalysisResultAction.cs index ebbac9a4a..7996d5e06 100644 --- a/XenModel/Actions/HealthCheck/GetHealthCheckAnalysisResultAction.cs +++ b/XenModel/Actions/HealthCheck/GetHealthCheckAnalysisResultAction.cs @@ -36,6 +36,7 @@ using System.Net; using System.Web.Script.Serialization; using XenAdmin.Model; using XenAPI; +using System.Linq; namespace XenAdmin.Actions { @@ -84,7 +85,7 @@ namespace XenAdmin.Actions log.Info("Saving analysis result"); Dictionary newConfig = Pool.health_check_config; newConfig[HealthCheckSettings.REPORT_ANALYSIS_SEVERITY] = GetMaxSeverity(analysisResult).ToString(); - newConfig[HealthCheckSettings.REPORT_ANALYSIS_ISSUES_DETECTED] = analysisResult.Count.ToString(); + newConfig[HealthCheckSettings.REPORT_ANALYSIS_ISSUES_DETECTED] = GetDistinctIssueCount(analysisResult).ToString(); newConfig[HealthCheckSettings.REPORT_ANALYSIS_UPLOAD_UUID] = Pool.HealthCheckSettings.UploadUuid; newConfig[HealthCheckSettings.REPORT_ANALYSIS_UPLOAD_TIME] = Pool.HealthCheckSettings.LastSuccessfulUpload; Pool.set_health_check_config(Session, Pool.opaque_ref, newConfig); @@ -111,6 +112,12 @@ namespace XenAdmin.Actions return maxSeverity; } + private int GetDistinctIssueCount(List issues) + { + // get the number of distinct issues (by name) + return issues.Select(issue => issue.name).Distinct().Count(); + } + private List GetAnalysisResult(string diagnosticToken, string uploadUuid) { var urlString = string.Format("{0}{1}?upload_uuid={2}", diagnosticDomainName, DIAG_RESULT_URL, uploadUuid); @@ -137,7 +144,7 @@ namespace XenAdmin.Actions private class AnalysisResult { public string severity { get; set; } - /*public string extra_information { get; set; } + public string extra_information { get; set; } public string owner { get; set; } public string crm_id { get; set; } public string id { get; set; } @@ -152,7 +159,7 @@ namespace XenAdmin.Actions public string upload_description { get; set; } public string upload_id { get; set; } public string recommendations { get; set; } - public string env_identifier { get; set; }*/ + public string env_identifier { get; set; } } } }