mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 23:39:51 +01:00
CA-334756: Allow detaching and reattaching all types of SRs.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
57cbf560d5
commit
a07c68a345
@ -78,51 +78,22 @@ namespace XenAdmin.Commands
|
|||||||
|
|
||||||
private static bool CanExecute(SR sr)
|
private static bool CanExecute(SR sr)
|
||||||
{
|
{
|
||||||
return sr != null && sr.IsDetachable() && !HelpersGUI.GetActionInProgress(sr);
|
return sr != null && !sr.IsDetached() && !sr.HasRunningVMs() && !HelpersGUI.GetActionInProgress(sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string MenuText
|
public override string MenuText => Messages.MAINWINDOW_DETACH_SR;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Messages.MAINWINDOW_DETACH_SR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool ConfirmationRequired
|
protected override bool ConfirmationRequired => true;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string ConfirmationDialogText
|
protected override string ConfirmationDialogText =>
|
||||||
{
|
GetSelection().Count == 1
|
||||||
get
|
? Messages.MESSAGEBOX_DETACH_SR_CONTINUE
|
||||||
{
|
: Messages.MESSAGEBOX_DETACH_SRS_CONTINUE;
|
||||||
SelectedItemCollection selection = GetSelection();
|
|
||||||
|
|
||||||
if (selection.Count == 1)
|
protected override string ConfirmationDialogTitle =>
|
||||||
{
|
GetSelection().Count == 1
|
||||||
return Messages.MESSAGEBOX_DETACH_SR_CONTINUE;
|
? Messages.MESSAGEBOX_DETACH_SR_CONTINUE_TITLE
|
||||||
}
|
: Messages.MESSAGEBOX_DETACH_SRS_CONTINUE_TITLE;
|
||||||
return Messages.MESSAGEBOX_DETACH_SRS_CONTINUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string ConfirmationDialogTitle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (GetSelection().Count == 1)
|
|
||||||
{
|
|
||||||
return Messages.MESSAGEBOX_DETACH_SR_CONTINUE_TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Messages.MESSAGEBOX_DETACH_SRS_CONTINUE_TITLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override CommandErrorDialog GetErrorDialogCore(IDictionary<IXenObject, string> cantExecuteReasons)
|
protected override CommandErrorDialog GetErrorDialogCore(IDictionary<IXenObject, string> cantExecuteReasons)
|
||||||
{
|
{
|
||||||
@ -144,10 +115,6 @@ namespace XenAdmin.Commands
|
|||||||
{
|
{
|
||||||
return Messages.SR_HAS_RUNNING_VMS;
|
return Messages.SR_HAS_RUNNING_VMS;
|
||||||
}
|
}
|
||||||
if (!sr.CanCreateWithXenCenter())
|
|
||||||
{
|
|
||||||
return Messages.SR_CANNOT_BE_DETACHED_WITH_XC;
|
|
||||||
}
|
|
||||||
if (HelpersGUI.GetActionInProgress(sr))
|
if (HelpersGUI.GetActionInProgress(sr))
|
||||||
{
|
{
|
||||||
return Messages.SR_ACTION_IN_PROGRESS;
|
return Messages.SR_ACTION_IN_PROGRESS;
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using XenAdmin.Core;
|
using XenAdmin.Core;
|
||||||
using XenAPI;
|
|
||||||
using XenAdmin.Wizards;
|
using XenAdmin.Wizards;
|
||||||
|
using XenAPI;
|
||||||
|
|
||||||
|
|
||||||
namespace XenAdmin.Commands
|
namespace XenAdmin.Commands
|
||||||
@ -65,9 +64,7 @@ namespace XenAdmin.Commands
|
|||||||
private void Execute(SR sr)
|
private void Execute(SR sr)
|
||||||
{
|
{
|
||||||
if (CanReattachSR(sr))
|
if (CanReattachSR(sr))
|
||||||
{
|
|
||||||
MainWindowCommandInterface.ShowPerConnectionWizard(sr.Connection, new NewSRWizard(sr.Connection, sr));
|
MainWindowCommandInterface.ShowPerConnectionWizard(sr.Connection, new NewSRWizard(sr.Connection, sr));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||||
@ -77,29 +74,18 @@ namespace XenAdmin.Commands
|
|||||||
|
|
||||||
protected override bool CanExecuteCore(SelectedItemCollection selection)
|
protected override bool CanExecuteCore(SelectedItemCollection selection)
|
||||||
{
|
{
|
||||||
if (selection.Count == 1)
|
return selection.Count == 1 && CanReattachSR(selection[0].XenObject as SR);
|
||||||
{
|
|
||||||
return CanReattachSR(selection[0].XenObject as SR);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CanReattachSR(SR sr)
|
private static bool CanReattachSR(SR sr)
|
||||||
{
|
{
|
||||||
return sr != null
|
return sr != null
|
||||||
&& !sr.HasPBDs()
|
&& !sr.HasPBDs()
|
||||||
&& sr.CanCreateWithXenCenter()
|
|
||||||
&& !HelpersGUI.GetActionInProgress(sr)
|
&& !HelpersGUI.GetActionInProgress(sr)
|
||||||
&& !(sr.type == "cslg" && Helpers.FeatureForbidden(sr.Connection, Host.RestrictStorageChoices))
|
&& !(sr.type == "cslg" && Helpers.FeatureForbidden(sr.Connection, Host.RestrictStorageChoices))
|
||||||
&& (SM.GetByType(sr.Connection, sr.type) != null);
|
&& (SM.GetByType(sr.Connection, sr.type) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string MenuText
|
public override string MenuText => Messages.MAINWINDOW_REATTACH_SR;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Messages.MAINWINDOW_REATTACH_SR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
XenModel/Messages.Designer.cs
generated
9
XenModel/Messages.Designer.cs
generated
@ -33894,15 +33894,6 @@ namespace XenAdmin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to This SR cannot be detached with [XenCenter]..
|
|
||||||
/// </summary>
|
|
||||||
public static string SR_CANNOT_BE_DETACHED_WITH_XC {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("SR_CANNOT_BE_DETACHED_WITH_XC", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to This SR cannot be forgotten with [XenCenter]..
|
/// Looks up a localized string similar to This SR cannot be forgotten with [XenCenter]..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -11800,9 +11800,6 @@ You may need to reboot your server(s) to enable SR-IOV network.</value>
|
|||||||
<data name="SR_CANNOT_BE_DESTROYED_WITH_XC" xml:space="preserve">
|
<data name="SR_CANNOT_BE_DESTROYED_WITH_XC" xml:space="preserve">
|
||||||
<value>This SR cannot be destroyed with [XenCenter].</value>
|
<value>This SR cannot be destroyed with [XenCenter].</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SR_CANNOT_BE_DETACHED_WITH_XC" xml:space="preserve">
|
|
||||||
<value>This SR cannot be detached with [XenCenter].</value>
|
|
||||||
</data>
|
|
||||||
<data name="SR_CANNOT_BE_FORGOTTEN_WITH_XC" xml:space="preserve">
|
<data name="SR_CANNOT_BE_FORGOTTEN_WITH_XC" xml:space="preserve">
|
||||||
<value>This SR cannot be forgotten with [XenCenter].</value>
|
<value>This SR cannot be forgotten with [XenCenter].</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -218,11 +218,6 @@ namespace XenAPI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDetachable()
|
|
||||||
{
|
|
||||||
return !IsDetached() && !HasRunningVMs() && CanCreateWithXenCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can create with XC, or is citrix storage link gateway. Special case alert!
|
/// Can create with XC, or is citrix storage link gateway. Special case alert!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user