mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 14:27:26 +01:00
Merge pull request #1387 from geosharath/CA-213512
CA-213512: [VMSS] XC mentions VMPR instead of VMSS on failure of snapshot
This commit is contained in:
commit
a6e95e3cb7
@ -237,6 +237,15 @@ namespace XenAdmin.Alerts
|
||||
case Message.MessageType.VMPP_XAPI_LOGON_FAILURE:
|
||||
var policyAlert = new PolicyAlert(Message.Connection, Message.body);
|
||||
return policyAlert.Text;
|
||||
case Message.MessageType.VMSS_SNAPSHOT_MISSED_EVENT:
|
||||
case Message.MessageType.VMSS_XAPI_LOGON_FAILURE:
|
||||
case Message.MessageType.VMSS_LICENSE_ERROR:
|
||||
case Message.MessageType.VMSS_SNAPSHOT_FAILED:
|
||||
case Message.MessageType.VMSS_SNAPSHOT_SUCCEEDED:
|
||||
case Message.MessageType.VMSS_SNAPSHOT_LOCK_FAILED:
|
||||
VMSS vmss = Helpers.XenObjectFromMessage(Message) as VMSS;
|
||||
var policyAlertVMSS = new PolicyAlert(Message.priority, Message.name, Message.timestamp, Message.body, vmss.Name);
|
||||
return policyAlertVMSS.Text;
|
||||
}
|
||||
|
||||
return Message.body;
|
||||
|
@ -245,7 +245,7 @@ namespace XenAdmin.Dialogs.VMPolicies
|
||||
var messageListSorted = policyMessage[policy.uuid].OrderByDescending(message => message.timestamp).ToList();
|
||||
for (int messageCount = 0; messageCount < 10 && messageCount < messageListSorted.Count; messageCount++)
|
||||
{
|
||||
policy.PolicyAlerts.Add(new PolicyAlert(messageListSorted[messageCount].priority, messageListSorted[messageCount].name, messageListSorted[messageCount].timestamp));
|
||||
policy.PolicyAlerts.Add(new PolicyAlert(messageListSorted[messageCount].priority, messageListSorted[messageCount].name, messageListSorted[messageCount].timestamp, messageListSorted[messageCount].body, policy.Name));
|
||||
}
|
||||
if (dataGridView1.ColumnCount > 0)
|
||||
dataGridView1.Rows.Add(new PolicyRow(policy));
|
||||
|
@ -70,7 +70,7 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
if (message.cls == cls.VMSS && message.obj_uuid == VMSS.uuid && messageCounter < 10)
|
||||
{
|
||||
listAlerts.Add(new PolicyAlert(message.priority, message.name, message.timestamp));
|
||||
listAlerts.Add(new PolicyAlert(message.priority, message.name, message.timestamp, message.body, VMSS.Name));
|
||||
messageCounter++;
|
||||
}
|
||||
else if (messageCounter >= 10)
|
||||
@ -83,7 +83,7 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
if (message.cls == cls.VMSS && message.obj_uuid == VMSS.uuid && message.timestamp > offset)
|
||||
{
|
||||
listAlerts.Add(new PolicyAlert(message.priority, message.name, message.timestamp));
|
||||
listAlerts.Add(new PolicyAlert(message.priority, message.name, message.timestamp, message.body, VMSS.Name));
|
||||
}
|
||||
|
||||
/* since the messages are sorted on timestamp you need not scan the entire message list */
|
||||
|
@ -30,6 +30,8 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@ -43,16 +45,66 @@ namespace XenAdmin.Alerts
|
||||
public readonly string Type;
|
||||
public readonly string Text;
|
||||
public readonly DateTime Time;
|
||||
public readonly string PolicyType;
|
||||
public readonly int numberOfVMsFailed;
|
||||
|
||||
public PolicyAlert(long priority, string name, DateTime _time)
|
||||
public PolicyAlert(long priority, string name, DateTime _time, string body, string policyName)
|
||||
{
|
||||
Type = (priority == 4 ? "info": "error");
|
||||
Time = _time;
|
||||
Text = Message.FriendlyBody(name);
|
||||
PolicyType = "VMSS";
|
||||
|
||||
if(Type == "info")
|
||||
{
|
||||
Text = Message.FriendlyBody(name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We reach here when message type is an error hence we need
|
||||
* to parse the message body accordingly */
|
||||
|
||||
numberOfVMsFailed = Regex.Matches(body, "VM:").Count;
|
||||
if(numberOfVMsFailed == 0)
|
||||
{
|
||||
Text = Message.FriendlyBody(name);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat(Message.FriendlyBody(name), policyName, numberOfVMsFailed);
|
||||
string[] messageHeader = Regex.Split(body.Replace("\n", " "), "Details:");
|
||||
|
||||
/* get a list of all VMs that have encountered an error */
|
||||
string[] vmList = Regex.Split(messageHeader[1], "VM:");
|
||||
|
||||
if(vmList.Length > 1)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.Append(Messages.VMSS_ALERT_DETAILS);
|
||||
}
|
||||
/* for each VM entry parse the data and get VM name and corresponding error message */
|
||||
for (int vmIterator = 1; vmIterator < vmList.Length; vmIterator++)
|
||||
{
|
||||
vmList[vmIterator].Trim();
|
||||
string[] tmp = Regex.Split(vmList[vmIterator], "Error:");
|
||||
string vmName = Regex.Split(tmp[0], "UUID:")[0];
|
||||
|
||||
string[] errorCode = Regex.Split(tmp[1].Replace("[", "").Replace("],", "").Replace("]", ""), "\',");
|
||||
for (int errorCodeIterator = 0; errorCodeIterator < errorCode.Length; errorCodeIterator++)
|
||||
errorCode[errorCodeIterator] = errorCode[errorCodeIterator].Replace("\'", "").Trim();
|
||||
|
||||
string errorMessage = new Failure(errorCode).Message;
|
||||
sb.AppendLine();
|
||||
sb.AppendFormat(Messages.VMSS_ALERT_VM_ERROR_FORMAT, vmIterator, vmName.Trim(), errorMessage);
|
||||
}
|
||||
Text = sb.ToString();
|
||||
}
|
||||
|
||||
public PolicyAlert(IXenConnection connection, string body)
|
||||
{
|
||||
PolicyType = "VMPP";
|
||||
numberOfVMsFailed = Text.Split('\n').Length;
|
||||
var sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
@ -114,9 +166,23 @@ namespace XenAdmin.Alerts
|
||||
{
|
||||
{
|
||||
if (Type == "error")
|
||||
{
|
||||
int numberOfVMsFailed = Text.Split('\n').Length;
|
||||
return string.Format(Messages.VM_PROTECTION_POLICY_FAILED, Message.FriendlyName(XenAPI.Message.MessageType.VMPP_SNAPSHOT_FAILED.ToString()), numberOfVMsFailed);
|
||||
{
|
||||
if (PolicyType == "VMSS")
|
||||
{
|
||||
if (numberOfVMsFailed == 0)
|
||||
{
|
||||
return Message.FriendlyName(XenAPI.Message.MessageType.VMSS_SNAPSHOT_FAILED.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format(Messages.VM_SNAPSHOT_SCHEDULE_FAILED, Message.FriendlyName(XenAPI.Message.MessageType.VMSS_SNAPSHOT_FAILED.ToString()), numberOfVMsFailed);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format(Messages.VM_PROTECTION_POLICY_FAILED, Message.FriendlyName(XenAPI.Message.MessageType.VMPP_SNAPSHOT_FAILED.ToString()), numberOfVMsFailed);
|
||||
}
|
||||
}
|
||||
else return Text;
|
||||
}
|
||||
|
26
XenModel/FriendlyNames.Designer.cs
generated
26
XenModel/FriendlyNames.Designer.cs
generated
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18408
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -4005,7 +4005,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The XenServer license you are using does not allow you to use the Scheduled Snapshots feature..
|
||||
/// Looks up a localized string similar to The XenServer license you are using does not allow you to use the snapshot schedule feature..
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_license_error {
|
||||
get {
|
||||
@ -4014,7 +4014,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot failed: snapshot could not be created.
|
||||
/// Looks up a localized string similar to The snapshot schedule '{0}' failed because a snapshot could not be created on {1} VMs..
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_snapshot_failed {
|
||||
get {
|
||||
@ -4023,7 +4023,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unable to create snapshots at this time because the scheduled snapshot operation for this policy is already in progress. Please try again later..
|
||||
/// Looks up a localized string similar to Unable to create snapshots at this time because the snapshot schedule operation for this policy is already in progress. Please try again later..
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_snapshot_lock_failed {
|
||||
get {
|
||||
@ -4032,7 +4032,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unable to create snapshots at this time because a scheduled snapshot operation is already in progress in this pool. One only scheduled snapshot operation can run at a time in the same pool. Please check that the snapshot schedules in this pool do not clash..
|
||||
/// Looks up a localized string similar to Unable to create snapshots at this time because a snapshot schedule's snapshot operation is already in progress in this pool. One only snapshot schedule operation can run at a time in the same pool. Please check that the snapshot schedules in this pool do not clash..
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_snapshot_missed_event {
|
||||
get {
|
||||
@ -4041,7 +4041,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled Snapshot succeeded.
|
||||
/// Looks up a localized string similar to Snapshot schedule succeeded.
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_snapshot_succeeded {
|
||||
get {
|
||||
@ -4050,7 +4050,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot XAPI logon failure.
|
||||
/// Looks up a localized string similar to Snapshot schedule XAPI logon failure.
|
||||
/// </summary>
|
||||
public static string Message_body_vmss_xapi_logon_failure {
|
||||
get {
|
||||
@ -4878,7 +4878,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot failed: insufficient license for Scheduled snapshots.
|
||||
/// Looks up a localized string similar to Snapshot schedule failed: insufficient license for Scheduled snapshots.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_license_error {
|
||||
get {
|
||||
@ -4887,7 +4887,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot failed: snapshot could not be created.
|
||||
/// Looks up a localized string similar to Snapshot schedule failed.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_snapshot_failed {
|
||||
get {
|
||||
@ -4896,7 +4896,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot failed: snapshot could not be created.
|
||||
/// Looks up a localized string similar to Snapshot schedule failed.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_snapshot_lock_failed {
|
||||
get {
|
||||
@ -4905,7 +4905,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot failed: snapshot could not be created.
|
||||
/// Looks up a localized string similar to Snapshot schedule failed.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_snapshot_missed_event {
|
||||
get {
|
||||
@ -4914,7 +4914,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot succeeded.
|
||||
/// Looks up a localized string similar to Snapshot schedule succeeded.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_snapshot_succeeded {
|
||||
get {
|
||||
@ -4923,7 +4923,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scheduled snapshot XAPI logon failure.
|
||||
/// Looks up a localized string similar to Snapshot schedule XAPI logon failure.
|
||||
/// </summary>
|
||||
public static string Message_name_vmss_xapi_logon_failure {
|
||||
get {
|
||||
|
@ -1215,22 +1215,22 @@
|
||||
<value>Unable to log in to XAPI session.</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_license_error" xml:space="preserve">
|
||||
<value>The XenServer license you are using does not allow you to use the Scheduled Snapshots feature.</value>
|
||||
<value>The XenServer license you are using does not allow you to use the snapshot schedule feature.</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_snapshot_failed" xml:space="preserve">
|
||||
<value>Scheduled snapshot failed: snapshot could not be created</value>
|
||||
<value>The snapshot schedule '{0}' failed because a snapshot could not be created on {1} VMs.</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_snapshot_lock_failed" xml:space="preserve">
|
||||
<value>Unable to create snapshots at this time because the scheduled snapshot operation for this policy is already in progress. Please try again later.</value>
|
||||
<value>Unable to create snapshots at this time because the snapshot schedule operation for this policy is already in progress. Please try again later.</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_snapshot_missed_event" xml:space="preserve">
|
||||
<value>Unable to create snapshots at this time because a scheduled snapshot operation is already in progress in this pool. One only scheduled snapshot operation can run at a time in the same pool. Please check that the snapshot schedules in this pool do not clash.</value>
|
||||
<value>Unable to create snapshots at this time because a snapshot schedule's snapshot operation is already in progress in this pool. One only snapshot schedule operation can run at a time in the same pool. Please check that the snapshot schedules in this pool do not clash.</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_snapshot_succeeded" xml:space="preserve">
|
||||
<value>Scheduled Snapshot succeeded</value>
|
||||
<value>Snapshot schedule succeeded</value>
|
||||
</data>
|
||||
<data name="Message.body-vmss_xapi_logon_failure" xml:space="preserve">
|
||||
<value>Scheduled snapshot XAPI logon failure</value>
|
||||
<value>Snapshot schedule XAPI logon failure</value>
|
||||
</data>
|
||||
<data name="Message.body-wlb_consultation_failed" xml:space="preserve">
|
||||
<value>Pool '{0}' failed to retrieve placement recommendations from WLB for VM '{1}'.</value>
|
||||
@ -1458,22 +1458,22 @@
|
||||
<value>VMPP XAPI logon failure</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_license_error" xml:space="preserve">
|
||||
<value>Scheduled snapshot failed: insufficient license for Scheduled snapshots</value>
|
||||
<value>Snapshot schedule failed: insufficient license for Scheduled snapshots</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_snapshot_failed" xml:space="preserve">
|
||||
<value>Scheduled snapshot failed: snapshot could not be created</value>
|
||||
<value>Snapshot schedule failed</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_snapshot_lock_failed" xml:space="preserve">
|
||||
<value>Scheduled snapshot failed: snapshot could not be created</value>
|
||||
<value>Snapshot schedule failed</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_snapshot_missed_event" xml:space="preserve">
|
||||
<value>Scheduled snapshot failed: snapshot could not be created</value>
|
||||
<value>Snapshot schedule failed</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_snapshot_succeeded" xml:space="preserve">
|
||||
<value>Scheduled snapshot succeeded</value>
|
||||
<value>Snapshot schedule succeeded</value>
|
||||
</data>
|
||||
<data name="Message.name-vmss_xapi_logon_failure" xml:space="preserve">
|
||||
<value>Scheduled snapshot XAPI logon failure</value>
|
||||
<value>Snapshot schedule XAPI logon failure</value>
|
||||
</data>
|
||||
<data name="Message.name-wlb_consultation_failed" xml:space="preserve">
|
||||
<value>WLB consultation has failed</value>
|
||||
@ -1883,4 +1883,4 @@
|
||||
<data name="Label-host.edition-basic" xml:space="preserve">
|
||||
<value>[Citrix] [XenServer product] Basic Edition</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
29
XenModel/Messages.Designer.cs
generated
29
XenModel/Messages.Designer.cs
generated
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18408
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -34757,6 +34757,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} ({1} VMs failed).
|
||||
/// </summary>
|
||||
public static string VM_SNAPSHOT_SCHEDULE_FAILED {
|
||||
get {
|
||||
return ResourceManager.GetString("VM_SNAPSHOT_SCHEDULE_FAILED", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to VM successfully created.
|
||||
/// </summary>
|
||||
@ -34937,6 +34946,24 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Details:.
|
||||
/// </summary>
|
||||
public static string VMSS_ALERT_DETAILS {
|
||||
get {
|
||||
return ResourceManager.GetString("VMSS_ALERT_DETAILS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}. {1}: {2}.
|
||||
/// </summary>
|
||||
public static string VMSS_ALERT_VM_ERROR_FORMAT {
|
||||
get {
|
||||
return ResourceManager.GetString("VMSS_ALERT_VM_ERROR_FORMAT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Snapshot sched&ules ....
|
||||
/// </summary>
|
||||
|
@ -11907,6 +11907,12 @@ To learn more about the [XenServer] Dynamic Workload Balancing feature or to sta
|
||||
<data name="VMS" xml:space="preserve">
|
||||
<value>VMs</value>
|
||||
</data>
|
||||
<data name="VMSS_ALERT_DETAILS" xml:space="preserve">
|
||||
<value>Details:</value>
|
||||
</data>
|
||||
<data name="VMSS_ALERT_VM_ERROR_FORMAT" xml:space="preserve">
|
||||
<value>{0}. {1}: {2}</value>
|
||||
</data>
|
||||
<data name="VMSS_CONTEXT_MENU" xml:space="preserve">
|
||||
<value>Snapshot sched&ules ...</value>
|
||||
</data>
|
||||
@ -12147,6 +12153,9 @@ To learn more about the [XenServer] Dynamic Workload Balancing feature or to sta
|
||||
<data name="VM_SHUT_DOWN" xml:space="preserve">
|
||||
<value>This VM is shut down.</value>
|
||||
</data>
|
||||
<data name="VM_SNAPSHOT_SCHEDULE_FAILED" xml:space="preserve">
|
||||
<value>{0} ({1} VMs failed)</value>
|
||||
</data>
|
||||
<data name="VM_SUCCESSFULLY_CREATED" xml:space="preserve">
|
||||
<value>VM successfully created</value>
|
||||
</data>
|
||||
|
@ -1597,6 +1597,11 @@ namespace XenAdmin.Core
|
||||
if (vmpp != null)
|
||||
return vmpp;
|
||||
break;
|
||||
case cls.VMSS:
|
||||
VMSS vmss = message.Connection.Cache.Find_By_Uuid<VMSS>(message.obj_uuid);
|
||||
if (vmss != null)
|
||||
return vmss;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user