CP-8547: Add button in XenCenter to initiate space reclamation on an SR: Changes following code review.

- Added check for null for sm.features in SR.SupportsTrim;
- Better error messages;
- Moved error messages from Messages to FriendlyNames;
- Removed the check for actions in progress from TrimSRCommand.CanExecute().

-

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2014-06-24 14:48:31 +01:00
parent 1f217b9983
commit 1ff55016c8
7 changed files with 39 additions and 40 deletions

View File

@ -74,7 +74,7 @@ namespace XenAdmin.Commands
private static bool CanExecute(SR sr) private static bool CanExecute(SR sr)
{ {
return sr != null && sr.SupportsTrim && !HelpersGUI.GetActionInProgress(sr); return sr != null && sr.SupportsTrim;
} }
} }
} }

View File

@ -131,8 +131,7 @@ namespace XenAdmin.Actions
{ {
if (errCode == null) if (errCode == null)
return null; return null;
var messageKey = "SR_TRIM_ERROR_" + errCode.ToUpper(); return PropertyManager.GetFriendlyName("Message.name-" + errCode);
return Messages.ResourceManager.GetString(messageKey);
} }
} }
} }

View File

@ -4094,6 +4094,33 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Cannot reclaim freed space because the SR is already busy.
/// </summary>
public static string Message_name_SRUnavailable {
get {
return ResourceManager.GetString("Message.name-SRUnavailable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An unknown error occurred when reclaiming freed space.
/// </summary>
public static string Message_name_UnknownTrimException {
get {
return ResourceManager.GetString("Message.name-UnknownTrimException", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reclaiming freed space not supported on this SR.
/// </summary>
public static string Message_name_UnsupportedSRForTrim {
get {
return ResourceManager.GetString("Message.name-UnsupportedSRForTrim", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to VM Disk QoS Failed. /// Looks up a localized string similar to VM Disk QoS Failed.
/// </summary> /// </summary>

View File

@ -1679,4 +1679,13 @@
<data name="Label-host.edition-free/libre" xml:space="preserve"> <data name="Label-host.edition-free/libre" xml:space="preserve">
<value>Citrix XenServer</value> <value>Citrix XenServer</value>
</data> </data>
<data name="Message.name-SRUnavailable" xml:space="preserve">
<value>Cannot reclaim freed space because the SR is already busy</value>
</data>
<data name="Message.name-UnknownTrimException" xml:space="preserve">
<value>An unknown error occurred when reclaiming freed space</value>
</data>
<data name="Message.name-UnsupportedSRForTrim" xml:space="preserve">
<value>Reclaiming freed space not supported on this SR</value>
</data>
</root> </root>

View File

@ -28327,33 +28327,6 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Unable to get SR lock.
/// </summary>
public static string SR_TRIM_ERROR_SRUNAVAILABLE {
get {
return ResourceManager.GetString("SR_TRIM_ERROR_SRUNAVAILABLE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An unknown exception occurred.
/// </summary>
public static string SR_TRIM_ERROR_UNKNOWNTRIMEXCEPTION {
get {
return ResourceManager.GetString("SR_TRIM_ERROR_UNKNOWNTRIMEXCEPTION", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Operation not supported.
/// </summary>
public static string SR_TRIM_ERROR_UNSUPPORTEDSRFORTRIM {
get {
return ResourceManager.GetString("SR_TRIM_ERROR_UNSUPPORTEDSRFORTRIM", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Unable to connect to iSCSI target. /// Looks up a localized string similar to Unable to connect to iSCSI target.
/// </summary> /// </summary>

View File

@ -9866,15 +9866,6 @@ Do you want to connect to the pool master '{1}'?</value>
<data name="SR_SIZE_USED" xml:space="preserve"> <data name="SR_SIZE_USED" xml:space="preserve">
<value>{0} used of {1} total ({2} allocated)</value> <value>{0} used of {1} total ({2} allocated)</value>
</data> </data>
<data name="SR_TRIM_ERROR_SRUNAVAILABLE" xml:space="preserve">
<value>Unable to get SR lock</value>
</data>
<data name="SR_TRIM_ERROR_UNKNOWNTRIMEXCEPTION" xml:space="preserve">
<value>An unknown exception occurred</value>
</data>
<data name="SR_TRIM_ERROR_UNSUPPORTEDSRFORTRIM" xml:space="preserve">
<value>Operation not supported</value>
</data>
<data name="SR_UNABLE_TO_CONNECT_TO_SCSI_TARGET" xml:space="preserve"> <data name="SR_UNABLE_TO_CONNECT_TO_SCSI_TARGET" xml:space="preserve">
<value>Unable to connect to iSCSI target</value> <value>Unable to connect to iSCSI target</value>
</data> </data>

View File

@ -1044,7 +1044,7 @@ namespace XenAPI
System.Diagnostics.Trace.Assert(Connection != null, "Connection must not be null"); System.Diagnostics.Trace.Assert(Connection != null, "Connection must not be null");
SM sm = SM.GetByType(Connection, type); SM sm = SM.GetByType(Connection, type);
return sm != null && sm.features.ContainsKey("SR_TRIM"); return sm != null && sm.features != null && sm.features.ContainsKey("SR_TRIM");
} }
} }