mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CP-16192: [Performance] xapi vmss object should have recentAlerts, like vmpp
Significant improvements has been done in "schedule snapshot" policy wizard for loading messages, hence we do not require recentAlerts field. Signed-off-by: Sharath Babu <Sharath.Babu@citrix.com>
This commit is contained in:
parent
ba0a060e06
commit
74c6242d56
@ -201,43 +201,54 @@ namespace XenAdmin.Dialogs.VMPolicies
|
||||
dataGridView1.SuspendLayout();
|
||||
var selectedPolicy = currentSelected;
|
||||
dataGridView1.Rows.Clear();
|
||||
var policyList = VMGroup<T>.VMPolicies(Pool.Connection.Cache);
|
||||
|
||||
/* creating a dictionary to hold (policy_uuid, message list) */
|
||||
|
||||
Dictionary<string, List<XenAPI.Message>> policyMessage = new Dictionary<string, List<XenAPI.Message>>();
|
||||
|
||||
/* populate the dictionary with policy uuid */
|
||||
|
||||
foreach (var policy in policyList)
|
||||
{
|
||||
policy.PolicyAlerts.Clear();
|
||||
List<XenAPI.Message> messageList = new List<XenAPI.Message>();
|
||||
policyMessage.Add(policy.uuid, messageList);
|
||||
}
|
||||
|
||||
/* iterate through all messages and populate the dictionary with message list */
|
||||
|
||||
/* filter out the messages for VMSS as the VMSS does not have recent alerts and that need to be populated below*/
|
||||
List<XenAPI.Message> vmssMessages = new List<XenAPI.Message>();
|
||||
if (!VMGroup<T>.isVMPolicyVMPP)
|
||||
{
|
||||
var messages = Pool.Connection.Cache.Messages;
|
||||
List<XenAPI.Message> value = new List<XenAPI.Message>();
|
||||
|
||||
foreach (var message in messages)
|
||||
{
|
||||
if (message.cls == cls.VMSS)
|
||||
{
|
||||
vmssMessages.Add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var policy in VMGroup<T>.VMPolicies(Pool.Connection.Cache))
|
||||
{
|
||||
if (!VMGroup<T>.isVMPolicyVMPP)
|
||||
{
|
||||
policy.PolicyAlerts.Clear();
|
||||
List<XenAPI.Message> processedMessages = new List<XenAPI.Message>();
|
||||
/*for VMSS: Populate the alerts from Messages by filtering out the alerts for this schedule
|
||||
This is not required in VMPP as the VMPP record itself has the recentAlerts */
|
||||
foreach (var message in vmssMessages)
|
||||
{
|
||||
if (message.obj_uuid == policy.uuid)
|
||||
if (policyMessage.TryGetValue(message.obj_uuid, out value))
|
||||
{
|
||||
policy.PolicyAlerts.Add(new PolicyAlert(message.priority, message.name, message.timestamp));
|
||||
processedMessages.Add(message);
|
||||
value.Add(message);
|
||||
}
|
||||
}
|
||||
vmssMessages.RemoveAll(message => processedMessages.Contains(message));
|
||||
}
|
||||
|
||||
if (dataGridView1.ColumnCount > 0)
|
||||
dataGridView1.Rows.Add(new PolicyRow(policy));
|
||||
}
|
||||
}
|
||||
}
|
||||
RefreshButtons();
|
||||
|
||||
/* add only 10 messages for each policy and referesh the rows*/
|
||||
|
||||
foreach (var policy in policyList)
|
||||
{
|
||||
for (int messageCount = 0; messageCount < 10 && messageCount < policyMessage[policy.uuid].Count; messageCount++)
|
||||
{
|
||||
policy.PolicyAlerts.Add(new PolicyAlert(policyMessage[policy.uuid][messageCount].priority, policyMessage[policy.uuid][messageCount].name, policyMessage[policy.uuid][messageCount].timestamp));
|
||||
}
|
||||
if (dataGridView1.ColumnCount > 0)
|
||||
dataGridView1.Rows.Add(new PolicyRow(policy));
|
||||
}
|
||||
|
||||
RefreshButtons();
|
||||
if (selectedPolicy != null)
|
||||
{
|
||||
foreach (PolicyRow row in dataGridView1.Rows)
|
||||
|
Loading…
Reference in New Issue
Block a user