mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-03 16:41:04 +01:00
CA-163782: Read the read-caching reason from the server
This commit is contained in:
parent
63c0187ffe
commit
a6f6b775fd
@ -1400,7 +1400,9 @@ namespace XenAdmin.TabPages
|
||||
else
|
||||
{
|
||||
s.AddEntry(FriendlyName("VM.read_caching_status"), Messages.VM_READ_CACHING_DISABLED);
|
||||
s.AddEntry(FriendlyName("VM.read_caching_reason"), vm.ReadCachingDisabledReason);
|
||||
var reason = vm.ReadCachingDisabledReason;
|
||||
if (reason != null)
|
||||
s.AddEntry(FriendlyName("VM.read_caching_reason"), reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
28
XenModel/Messages.Designer.cs
generated
28
XenModel/Messages.Designer.cs
generated
@ -33884,7 +33884,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This VM is not using Read Caching.
|
||||
/// Looks up a localized string similar to This VM is not using read caching.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED {
|
||||
get {
|
||||
@ -33893,7 +33893,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Not licensed for Read Caching.
|
||||
/// Looks up a localized string similar to This pool is not licensed for read caching.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED_REASON_LICENSE {
|
||||
get {
|
||||
@ -33902,7 +33902,25 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read Caching is not supported on any of the Storage Repositories used by this VM.
|
||||
/// Looks up a localized string similar to This VM does not have any read-only disks or disks with a read-only parent.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED_REASON_NO_RO_IMAGE {
|
||||
get {
|
||||
return ResourceManager.GetString("VM_READ_CACHING_DISABLED_REASON_NO_RO_IMAGE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This pool was not licensed for read caching when the VM was started.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED_REASON_PREV_LICENSE {
|
||||
get {
|
||||
return ResourceManager.GetString("VM_READ_CACHING_DISABLED_REASON_PREV_LICENSE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read caching is not supported on the type of Storage Repository used by this VM.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED_REASON_SR_TYPE {
|
||||
get {
|
||||
@ -33911,7 +33929,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read Caching is disabled on all supported Storage Repositories used by this VM.
|
||||
/// Looks up a localized string similar to Read caching has been disabled on the Storage Repository used by this VM.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_DISABLED_REASON_TURNED_OFF {
|
||||
get {
|
||||
@ -33920,7 +33938,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This VM has Read Caching enabled.
|
||||
/// Looks up a localized string similar to This VM is using read caching.
|
||||
/// </summary>
|
||||
public static string VM_READ_CACHING_ENABLED {
|
||||
get {
|
||||
|
@ -11736,19 +11736,25 @@ To learn more about the XenServer Dynamic Workload Balancing feature or to start
|
||||
<value>Succeeded</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED" xml:space="preserve">
|
||||
<value>This VM is not using Read Caching</value>
|
||||
<value>This VM is not using read caching</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED_REASON_LICENSE" xml:space="preserve">
|
||||
<value>Not licensed for Read Caching</value>
|
||||
<value>This pool is not licensed for read caching</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED_REASON_NO_RO_IMAGE" xml:space="preserve">
|
||||
<value>This VM does not have any read-only disks or disks with a read-only parent</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED_REASON_PREV_LICENSE" xml:space="preserve">
|
||||
<value>This pool was not licensed for read caching when the VM was started</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED_REASON_SR_TYPE" xml:space="preserve">
|
||||
<value>Read Caching is not supported on any of the Storage Repositories used by this VM</value>
|
||||
<value>Read caching is not supported on the type of Storage Repository used by this VM</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_DISABLED_REASON_TURNED_OFF" xml:space="preserve">
|
||||
<value>Read Caching is disabled on all supported Storage Repositories used by this VM</value>
|
||||
<value>Read caching has been disabled on the Storage Repository used by this VM</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_ENABLED" xml:space="preserve">
|
||||
<value>This VM has Read Caching enabled</value>
|
||||
<value>This VM is using read caching</value>
|
||||
</data>
|
||||
<data name="VM_READ_CACHING_ENABLED_SEARCH" xml:space="preserve">
|
||||
<value>Using read caching</value>
|
||||
@ -12680,4 +12686,4 @@ You will need to navigate to the Console on each of the selected VMs to complete
|
||||
<data name="YOU_ARE_HERE" xml:space="preserve">
|
||||
<value>You are here</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
@ -335,16 +335,31 @@ namespace XenAPI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether read caching is supported on this disk
|
||||
/// ... and if not, why not
|
||||
/// </summary>
|
||||
public bool ReadCachingSupported
|
||||
public ReadCachingDisabledReasonCode ReadCachingDisabledReason(Host host)
|
||||
{
|
||||
get
|
||||
string reasonstr;
|
||||
if (sm_config.TryGetValue("read-caching-reason-" + host.uuid, out reasonstr))
|
||||
{
|
||||
var sr = Connection.Resolve(SR);
|
||||
var srType = sr != null ? sr.GetSRType(false) : XenAPI.SR.SRTypes.unknown;
|
||||
return srType == XenAPI.SR.SRTypes.ext || srType == XenAPI.SR.SRTypes.nfs;
|
||||
ReadCachingDisabledReasonCode reason;
|
||||
if (Enum.TryParse(reasonstr, out reason))
|
||||
return reason;
|
||||
}
|
||||
return ReadCachingDisabledReasonCode.UNKNOWN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Possible reasons for read caching being disabled
|
||||
/// If there are multiple reasons, the topmost reason will be returned
|
||||
/// </summary>
|
||||
public enum ReadCachingDisabledReasonCode
|
||||
{
|
||||
UNKNOWN, // catch-all, shouldn't occur if read caching is disabled
|
||||
LICENSE_RESTRICTION, // self-explanatory
|
||||
SR_NOT_SUPPORTED, // the SR is not NFS or EXT
|
||||
NO_RO_IMAGE, // no part of the VDI is read-only => nothing to cache
|
||||
SR_OVERRIDE, // the feature has been explicitly disabled for the VDI's SR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1760,32 +1760,45 @@ namespace XenAPI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Read Caching is supported on any of the VDIs
|
||||
/// </summary>
|
||||
public bool ReadCachingSupported
|
||||
public string ReadCachingDisabledReason
|
||||
{
|
||||
get
|
||||
// The code in VDI.ReadCachingDisabledReason returns the first matching reason from the list
|
||||
// (LICENSE_RESTRICTION, SR_NOT_SUPPORTED, NO_RO_IMAGE, SR_OVERRIDE). In the case that there
|
||||
// are several VDIs with different reasons, this function returns the last matching reason,
|
||||
// because that is the VDI that is nearest to being read-cachable in some sense. As the reasons
|
||||
// are stored in an enum, we can just use greater-than to find the last reason
|
||||
get
|
||||
{
|
||||
var ans = VDI.ReadCachingDisabledReasonCode.UNKNOWN;
|
||||
foreach (var vbd in Connection.ResolveAll(VBDs).Where(vbd => vbd != null && vbd.currently_attached))
|
||||
{
|
||||
var vdi = Connection.Resolve(vbd.VDI);
|
||||
if (vdi != null && vdi.ReadCachingSupported)
|
||||
return true;
|
||||
var resident_host = Connection.Resolve(resident_on);
|
||||
if (vdi != null && resident_host != null && !vdi.ReadCachingEnabled(resident_host))
|
||||
{
|
||||
var reason = vdi.ReadCachingDisabledReason(resident_host);
|
||||
if (reason > ans)
|
||||
ans = reason;
|
||||
}
|
||||
}
|
||||
|
||||
switch (ans)
|
||||
{
|
||||
case VDI.ReadCachingDisabledReasonCode.LICENSE_RESTRICTION:
|
||||
if (Helpers.FeatureForbidden(Connection, Host.RestrictReadCaching))
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_LICENSE;
|
||||
else
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_PREV_LICENSE;
|
||||
case VDI.ReadCachingDisabledReasonCode.SR_NOT_SUPPORTED:
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_SR_TYPE;
|
||||
case VDI.ReadCachingDisabledReasonCode.NO_RO_IMAGE:
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_NO_RO_IMAGE;
|
||||
case VDI.ReadCachingDisabledReasonCode.SR_OVERRIDE:
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_TURNED_OFF;
|
||||
default:
|
||||
// should only happen transiently
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string ReadCachingDisabledReason
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Helpers.FeatureForbidden(Connection, Host.RestrictReadCaching))
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_LICENSE;
|
||||
if (!ReadCachingSupported)
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_SR_TYPE;
|
||||
return Messages.VM_READ_CACHING_DISABLED_REASON_TURNED_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user