mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +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)
|
||||
{
|
||||
return sr != null && sr.IsDetachable() && !HelpersGUI.GetActionInProgress(sr);
|
||||
return sr != null && !sr.IsDetached() && !sr.HasRunningVMs() && !HelpersGUI.GetActionInProgress(sr);
|
||||
}
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_DETACH_SR;
|
||||
}
|
||||
}
|
||||
public override string MenuText => Messages.MAINWINDOW_DETACH_SR;
|
||||
|
||||
protected override bool ConfirmationRequired
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected override bool ConfirmationRequired => true;
|
||||
|
||||
protected override string ConfirmationDialogText
|
||||
{
|
||||
get
|
||||
{
|
||||
SelectedItemCollection selection = GetSelection();
|
||||
protected override string ConfirmationDialogText =>
|
||||
GetSelection().Count == 1
|
||||
? Messages.MESSAGEBOX_DETACH_SR_CONTINUE
|
||||
: Messages.MESSAGEBOX_DETACH_SRS_CONTINUE;
|
||||
|
||||
if (selection.Count == 1)
|
||||
{
|
||||
return Messages.MESSAGEBOX_DETACH_SR_CONTINUE;
|
||||
}
|
||||
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 string ConfirmationDialogTitle =>
|
||||
GetSelection().Count == 1
|
||||
? Messages.MESSAGEBOX_DETACH_SR_CONTINUE_TITLE
|
||||
: Messages.MESSAGEBOX_DETACH_SRS_CONTINUE_TITLE;
|
||||
|
||||
protected override CommandErrorDialog GetErrorDialogCore(IDictionary<IXenObject, string> cantExecuteReasons)
|
||||
{
|
||||
@ -144,10 +115,6 @@ namespace XenAdmin.Commands
|
||||
{
|
||||
return Messages.SR_HAS_RUNNING_VMS;
|
||||
}
|
||||
if (!sr.CanCreateWithXenCenter())
|
||||
{
|
||||
return Messages.SR_CANNOT_BE_DETACHED_WITH_XC;
|
||||
}
|
||||
if (HelpersGUI.GetActionInProgress(sr))
|
||||
{
|
||||
return Messages.SR_ACTION_IN_PROGRESS;
|
||||
|
@ -31,10 +31,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using XenAdmin.Core;
|
||||
using XenAPI;
|
||||
using XenAdmin.Wizards;
|
||||
using XenAPI;
|
||||
|
||||
|
||||
namespace XenAdmin.Commands
|
||||
@ -65,9 +64,7 @@ namespace XenAdmin.Commands
|
||||
private void Execute(SR sr)
|
||||
{
|
||||
if (CanReattachSR(sr))
|
||||
{
|
||||
MainWindowCommandInterface.ShowPerConnectionWizard(sr.Connection, new NewSRWizard(sr.Connection, sr));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
@ -77,29 +74,18 @@ namespace XenAdmin.Commands
|
||||
|
||||
protected override bool CanExecuteCore(SelectedItemCollection selection)
|
||||
{
|
||||
if (selection.Count == 1)
|
||||
{
|
||||
return CanReattachSR(selection[0].XenObject as SR);
|
||||
}
|
||||
return false;
|
||||
return selection.Count == 1 && CanReattachSR(selection[0].XenObject as SR);
|
||||
}
|
||||
|
||||
private static bool CanReattachSR(SR sr)
|
||||
{
|
||||
return sr != null
|
||||
&& !sr.HasPBDs()
|
||||
&& sr.CanCreateWithXenCenter()
|
||||
&& !HelpersGUI.GetActionInProgress(sr)
|
||||
&& !(sr.type == "cslg" && Helpers.FeatureForbidden(sr.Connection, Host.RestrictStorageChoices))
|
||||
&& (SM.GetByType(sr.Connection, sr.type) != null);
|
||||
}
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_REATTACH_SR;
|
||||
}
|
||||
}
|
||||
public override string MenuText => 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>
|
||||
/// Looks up a localized string similar to This SR cannot be forgotten with [XenCenter]..
|
||||
/// </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">
|
||||
<value>This SR cannot be destroyed with [XenCenter].</value>
|
||||
</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">
|
||||
<value>This SR cannot be forgotten with [XenCenter].</value>
|
||||
</data>
|
||||
|
@ -218,11 +218,6 @@ namespace XenAPI
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsDetachable()
|
||||
{
|
||||
return !IsDetached() && !HasRunningVMs() && CanCreateWithXenCenter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can create with XC, or is citrix storage link gateway. Special case alert!
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user