xenadmin/XenAdmin/Dialogs/PropertiesDialog.cs

668 lines
25 KiB
C#
Raw Normal View History

/* Copyright (c) Citrix Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using XenAdmin.Wizards.NewVMWizard;
using XenAPI;
using XenAdmin.Actions;
using XenAdmin.SettingsPanels;
using XenAdmin.Controls;
using XenAdmin.Core;
using XenAdmin.Wizards.NewPolicyWizard;
using XenAdmin.Wizards.NewVMApplianceWizard;
using XenAdmin.Wizards.GenericPages;
using System.Linq;
namespace XenAdmin.Dialogs
{
public partial class PropertiesDialog : VerticallyTabbedDialog
{
#region Tabs
private CPUMemoryEditPage VCpuMemoryEditPage;
private HostMultipathPage hostMultipathPage1;
private CustomFieldsDisplayPage CustomFieldsEditPage;
private LogDestinationEditPage LogDestinationEditPage;
private HomeServerEditPage HomeServerPage;
private BootOptionsEditPage StartupOptionsEditPage;
private VMAdvancedEditPage VMAdvancedEditPage;
private PerfmonAlertEditPage PerfmonAlertEditPage;
private EditNetworkPage editNetworkPage;
private VDISizeLocationPage vdiSizeLocation;
private VMHAEditPage VMHAEditPage;
private GeneralEditPage GeneralEditPage;
private UpsellPage PerfmonAlertUpsellEditPage;
private UpsellPage PerfmonAlertOptionsUpsellEditPage;
private PerfmonAlertOptionsPage PerfmonAlertOptionsEditPage;
private HostPowerONEditPage HostPowerONEditPage;
private NewPolicySnapshotFrequencyPage newPolicySnapshotFrequencyPage1;
private NewPolicySnapshotTypePage newPolicyVMSSTypePage1;
private NewVMGroupVMsPage<VMSS> newVMSSVMsPage1;
private NewVMGroupVMsPage<VM_appliance> newVMApplianceVMsPage1;
private NewVMApplianceVMOrderAndDelaysPage newVmApplianceVmOrderAndDelaysPage1;
private UpsellPage GpuUpsellEditPage;
private GpuEditPage GpuEditPage;
private PoolGpuEditPage PoolGpuEditPage;
private VMEnlightenmentEditPage VMEnlightenmentEditPage;
private Page_CloudConfigParameters CloudConfigParametersPage;
private SecurityEditPage SecurityEditPage;
private LivePatchingEditPage LivePatchingEditPage;
private USBEditPage usbEditPage;
private NetworkOptionsEditPage NetworkOptionsEditPage;
private ClusteringEditPage ClusteringEditPage;
private SrReadCachingEditPage SrReadCachingEditPage;
#endregion
private IXenObject xenObject, xenObjectBefore, xenObjectCopy;
private AsyncAction _action;
private bool _startAction = true;
private System.Timers.Timer timer = new System.Timers.Timer();
public new event EventHandler<PropertiesDialogClosingEventArgs> FormClosing;
public PropertiesDialog(IXenObject xenObject)
: base(xenObject.Connection)
{
// xenObject must not be null. If this occurs, we shouldn't have offered Properties in the UI.
Debug.Assert(xenObject != null, "XenObject is null");
InitializeComponent();
this.xenObject = xenObject;
xenObjectBefore = xenObject.Clone();
xenObjectCopy = xenObject.Clone();
Name = String.Format("Edit{0}GeneralSettingsDialog", xenObject.GetType().Name);
Text = String.Format(Messages.PROPERTIES_DIALOG_TITLE, Helpers.GetName(xenObject));
if (!Application.RenderWithVisualStyles)
ContentPanel.BackColor = SystemColors.Control;
Build();
}
private void Build()
{
var pool = Helpers.GetPoolOfOne(connection);
bool is_host = xenObjectCopy is Host;
bool is_vm = xenObjectCopy is VM && !((VM)xenObjectCopy).is_a_snapshot;
bool is_sr = xenObjectCopy is SR;
bool is_pool = xenObjectCopy is Pool;
bool is_vdi = xenObjectCopy is VDI;
bool is_network = xenObjectCopy is XenAPI.Network;
bool is_hvm = is_vm && ((VM)xenObjectCopy).IsHVM();
bool is_template = is_vm && ((VM)xenObjectCopy).is_a_template;
bool is_in_pool = Helpers.GetPool(xenObjectCopy.Connection) != null;
bool is_pool_or_standalone = is_pool || (is_host && !is_in_pool);
bool wlb_enabled = (Helpers.WlbEnabledAndConfigured(xenObjectCopy.Connection));
bool is_VM_appliance = xenObjectCopy is VM_appliance;
bool is_VMSS = xenObjectCopy is VMSS;
ContentPanel.SuspendLayout();
verticalTabs.BeginUpdate();
try
{
verticalTabs.Items.Clear();
ShowTab(GeneralEditPage = new GeneralEditPage());
if (!is_VM_appliance)
ShowTab(CustomFieldsEditPage = new CustomFieldsDisplayPage {AutoScroll = true});
if (is_vm)
{
ShowTab(VCpuMemoryEditPage = new CPUMemoryEditPage());
ShowTab(StartupOptionsEditPage = new BootOptionsEditPage());
VMHAEditPage = new VMHAEditPage();
VMHAEditPage.Populated += EditPage_Populated;
ShowTab(VMHAEditPage);
}
if (is_vm || is_host || is_sr)
{
if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
{
PerfmonAlertUpsellEditPage = new UpsellPage
{
Image = Images.StaticImages._000_Alert2_h32bit_16,
Text = Messages.ALERTS,
BlurbText = Messages.UPSELL_BLURB_ALERTS
};
ShowTab(PerfmonAlertUpsellEditPage);
}
else
{
ShowTab(PerfmonAlertEditPage = new PerfmonAlertEditPage {AutoScroll = true});
}
}
if (is_pool_or_standalone)
{
if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictAlerts))
{
PerfmonAlertOptionsUpsellEditPage = new UpsellPage
{
Image = Images.StaticImages._000_Email_h32bit_16,
Text = Messages.EMAIL_OPTIONS,
BlurbText = Messages.UPSELL_BLURB_ALERTS
};
ShowTab(PerfmonAlertOptionsUpsellEditPage);
}
else
{
ShowTab(PerfmonAlertOptionsEditPage = new PerfmonAlertOptionsPage());
}
}
if (is_host)
{
ShowTab(hostMultipathPage1 = new HostMultipathPage());
ShowTab(LogDestinationEditPage = new LogDestinationEditPage());
}
if (is_host || is_pool)
ShowTab(HostPowerONEditPage = new HostPowerONEditPage());
if ((is_pool_or_standalone && Helpers.VGpuCapability(xenObjectCopy.Connection))
|| (is_host && ((Host)xenObjectCopy).CanEnableDisableIntegratedGpu()))
{
ShowTab(PoolGpuEditPage = new PoolGpuEditPage());
}
if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictSslLegacySwitch) && !Helpers.StockholmOrGreater(connection))
ShowTab(SecurityEditPage = new SecurityEditPage());
if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictLivePatching))
ShowTab(LivePatchingEditPage = new LivePatchingEditPage());
CP-34231: Remove language with negative connotations (#2860) * CA-34231: Replace negative language with `block list` in code and references Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `stop` in code and references Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `freezing` in code Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run/ran` in code comments Some paramater mentions have been renamed, as they will be renamed in future commits. Excluded mentions in XenAPI/Host.cs and XenAPI/VM.cs since code is autogenerated. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # CFUValidator/CommandLineOptions/CFUCommandLineOptionManager.cs # XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs # XenAdmin/Dialogs/Wlb/WorkloadReports.cs * CA-34231: Replace negative language with `run` in Command.cs Run method Used Resharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/TabPages/GeneralTabPage.cs * CA-34231: Replace negative language with `run` in Command.cs CanRun method Used Resharper rename utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in Command.cs CanRunCore method Used ReSharper rename utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/DRConfigureCommand.cs # XenAdmin/Commands/DRDryrunCommand.cs # XenAdmin/Commands/DRFailbackCommand.cs # XenAdmin/Commands/DRFailoverCommand.cs # XenAdmin/Commands/DisasterRecoveryCommand.cs # XenAdmin/Commands/VMGroupCommand.cs * CA-34231: Replace negative language with `run` in Command.cs RunCore method Used ReSharper rename utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in Command.cs GetCantExecuteReasonCore method Used ReSharper rename utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in Command.cs GetCantRunReasons method Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative language with `run` in Command.cs Also applied to related symbols. Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in methods named CanRun Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in methods in CrossPoolMigrateCommand.cs Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/CrossPoolMigrateCommand.cs * CA-34231: Replace negative language with `run` in remaining Run methods Also updated negative language in `DeleteVMCommand` Also updated in comment in `CrossPoolMigrateCommand` Also renamed missed instances of `CanRun` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `run` in `CanRunCore` and `RunCore` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative language with `run` in Commands folder Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative language with `run` in XenAdmin/Controls folder Used ReSharper renaming utility. Had to rename `WlbReportView.xs:RunReport()` to `WlbReportView.xs:StartRunReport()` to resolve conflict with change from `WlbReportView:ExecuteReport()` to `WlbReportView:RunReport()` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Controls/Wlb/WlbOptModeScheduler.cs # XenAdmin/Dialogs/Wlb/WorkloadReports.cs # XenAdminTests/UnitTests/WlbTests/WlbScheduledTaskTests.cs * CA-34231: Replace all remaining negative language with `run` in code Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/Controls/WlbRecommendations.cs # XenAdminTests/UnitTests/WlbTests/WlbScheduledTaskTests.cs # XenModel/WLB/WlbScheduledTask.cs * CA-34231: Replace negative language with `supporter` or `bond member` in code strings Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `supporter` or `bond member` in Messages string Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/MainWindow.cs # XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs # XenModel/Messages.Designer.cs # XenModel/Messages.resx * CA-34231: Replace remaining negative language with `supporter` in .resx files Used ReSharper renaming utility. FriendlyErrorNames.resx has been excluded. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `supporter` or `bond member` in XenAdmin code Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/NewPoolDialog.cs * CA-34231: Replace negative language with `supporter` or `bond member` in XenModel code Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in CFUValidator code Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # CFUValidator/CFUValidator.cs * CA-34231: Replace negative language with `coordinator` in solution's comments and hardcoded strings Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `Helpers:GetCoordinator` method Used ReSharper renaming utility. also renamed similarly named method in `ObjectChange.cs` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Alerts/Types/HotfixEligibilityAlert.cs # XenAdmin/Controls/CustomDataGraph/ArchiveMaintainer.cs * CA-34231: Replace negative language with `coordinator` in `EvacuateHostDialog.resx` Used ReSharper renaming utility. Excluded jp and zh resources Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/EvacuateHostDialog.resx * CA-34231: Replace negative language with `coordinator` in `EvacuateHostDialog.resx` Used ReSharper renaming utility. Excluded jp and zh resource files. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/NewPoolDialog.resx * CA-34231: Rename missing language references for change to `coordinator` Misc files were not saved before last commits. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `Messages.resx`'s code Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/HACommand.cs # XenAdmin/TabPages/AdPage.cs # XenModel/Actions/Network/CreateBondAction.cs # XenModel/Actions/Network/NetworkAction.cs # XenModel/Messages.Designer.cs # XenModel/Messages.resx * CA-34231: Replace negative language with `coordinator` in `ExternalPluginAction.cs` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `XenAdmin/Commands` Used ReSharper renaming utility. Also replace negative language in missed comment in `ExternalPluginAction.cs` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/AddHostToPoolCommand.cs # XenAdmin/Commands/HACommand.cs * CA-34231: Replace negative language with `coordinator` in `Helpers.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `NetworkingHelper.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `PoolJoinRules.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/NewPoolDialog.cs * CA-34231: Replace negative language with `coordinator` in `XenAdmin/Commands`, `Controls`, and `Core` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Commands/AddHostToPoolCommand.cs * CA-34231: Replace negative language with `coordinator` in `XenAdmin/Diagnostics` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `coordinator` in `XenAdmin/Dialogs` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/NewPoolDialog.cs * CA-34231: Replace remaining negative language with `coordinator` in `XenAdmin` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/MainWindow.cs # XenAdmin/TabPages/GeneralTabPage.cs # XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs # XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeExtrasPage.cs # XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizard.cs # XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs # XenAdmin/XenSearch/Columns.cs * CA-34231: Replace remaining negative language with `coordinator` in `XenModel\Actions` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenModel/Actions/Network/CreateBondAction.cs * CA-34231: Replace remaining negative language with `coordinator` in `XenModel` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative strings with `main` in `Messages.resx` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenModel/Messages.Designer.cs # XenModel/Messages.resx * CA-34231: Replace remaining negative string names with `main` in `Messages.resx` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs # XenModel/Messages.resx * CA-34231: Rename dialogs to replace negative connotations with `main` Used ReSharper renaming utility Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `main` in `SaveAndResoreOptionsPage.cs` Also updated its resx file. Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> # Conflicts: # XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs * CA-34231: Fix invalid reference in `SaveAndRestoreOptionsPage.Designer.cs` after renaming Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `main` in `EnterMainPasswordDialog.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `main` in `ChangeMainPasswordDialog.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Fix invalid reference not changed after renaming `EnterMainPasswordDialog.cs` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative language with `main` in `XenAdmin/Dialogs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Update class names in HelpManager.resx Following renaming of main password dialog. Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace negative language with `main` in `Metadata.cs` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Remove remaning negative language with `coordinator` from `Messages.resx` Used ReSharper renaming Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Remove remaning negative language with `other pool member` from `Messages.resx` Used ReSharper Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-34231: Replace remaining negative language in solution Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Remove commented out code in VNCGraphicsClient.cs Code has only been improved partially as it's not strictly relevant to the PR Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Amend negative word replacement in XSVNCScreen.cs Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Simplify debug call formatting in NewPoolDialog.cs Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Add code mistakenly removed in MainWindow.cs Removed as part of `f155f9c8` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Revert renaming of constant related to Windows' API Considered external to CH Center Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Amend hotkey for Coordinator field in `NewPoolDialog` Previous ALT+<key> hotkey was conflicting with CreatePool Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Remove unecessary whitespace in EvacuateHostDialog.cs Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Update if block to exclude unecessary else in DRFailoverWizard.cs Not relevant to the PR, but the change is small enought to no need extra testing Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Amend typo in PoolJoinRules.cs supporer -> supporter Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Replace missing negative language with `coordinator` in `XenAPI-Extensions/Pool.cs` Variables and methods XenAPI-Extensions were mistakenly skipped Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Replace negative language in `XenApi-Extensions` with `coordinator/interface` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Replace negative language in `XenApi-Extensions` with `supporter/member` Used ReSharper renaming utility. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Replace remaining negative language in `XenServerHealthCheckBugTool.cs` This is only used to format the string Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Change line-endings to CRLF in `Page_CloudConfigParamters.cs` Done in order to fix merge conflict into master Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CP-34231: Amend misc negative language renaming typos `XenServerHealthCheckBugTool` and `XenServerHealthCheckService` Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
2021-08-31 12:31:16 +02:00
if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictIGMPSnooping) && Helpers.GetCoordinator(pool).vSwitchNetworkBackend())
ShowTab(NetworkOptionsEditPage = new NetworkOptionsEditPage());
if (is_pool_or_standalone && !Helpers.FeatureForbidden(xenObject.Connection, Host.RestrictCorosync))
ShowTab(ClusteringEditPage = new ClusteringEditPage());
if (is_network)
ShowTab(editNetworkPage = new EditNetworkPage());
if (is_vm && !wlb_enabled)
ShowTab(HomeServerPage = new HomeServerEditPage());
if (is_vm && ((VM)xenObjectCopy).CanHaveGpu())
{
2015-10-26 17:01:55 +01:00
if (Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictGpu))
{
GpuUpsellEditPage = new UpsellPage
{
Image = Images.StaticImages._000_GetMemoryInfo_h32bit_16,
Text = Messages.GPU,
BlurbText = Messages.UPSELL_BLURB_GPU
};
2015-10-26 17:01:55 +01:00
ShowTab(GpuUpsellEditPage);
}
else
{
CA-310974: Hide GPU page if the host has no GPU capability (#2847) * CA-310974: Hide GPU page if the host has no GPU capability * Hid GPU page in PropertiesDialog * Hid GPU page in NewVMWizard Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-310974: Move GPU availability check to Helpers class * Switch from field to method based check * Update affected logic * Remove rubric toggle in PopulatePage when GpuEditPage is shown * Hide AddVGPUDialog when GpusAvailable returns false Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-310974: Remove missing GPUs strings in Messages.resx * GPU_RUBRIC_NO_GPUS_POOL * GPU_RUBRIC_NO_GPUS_SERVER Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-310974: Disable combobox in AddVGPUDialog when there are no GPUs Avoids exception being thrown if user tries to select empty first item Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-310974: Amend position of GPU availability check Moved since gpuCapability is used in the Finish method of the wizard Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com> * CA-310974: Remove unecessary null checks in Helpers method The Cache and its properties (e.g. GPU_groups) are readonly and initialised as empty. The API object properties that are ref lists (g.PGPUs, g.supported_VGPU_types) are also initialised as empty and are demarshalled by the SDK as empty if they have no values. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
2021-08-23 11:58:41 +02:00
if(Helpers.GpusAvailable(connection))
ShowTab(GpuEditPage = new GpuEditPage());
}
}
if (is_hvm && !is_template && !Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictUsbPassthrough) &&
pool.Connection.Cache.Hosts.Any(host => host.PUSBs.Count > 0))
{
usbEditPage = new USBEditPage();
usbEditPage.Populated += EditPage_Populated;
ShowTab(usbEditPage);
}
if (is_hvm)
{
ShowTab(VMAdvancedEditPage = new VMAdvancedEditPage());
}
if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanBeEnlightened())
ShowTab(VMEnlightenmentEditPage = new VMEnlightenmentEditPage());
if (is_vm && Helpers.ContainerCapability(xenObject.Connection) && ((VM)xenObjectCopy).CanHaveCloudConfigDrive())
ShowTab(CloudConfigParametersPage = new Page_CloudConfigParameters());
if(is_VMSS)
{
ShowTab(newVMSSVMsPage1 = new NewVMGroupVMsPage<VMSS> {Pool = pool});
ShowTab(newPolicyVMSSTypePage1 = new NewPolicySnapshotTypePage());
newPolicySnapshotFrequencyPage1 = new NewPolicySnapshotFrequencyPage {Connection = pool.Connection};
newPolicySnapshotFrequencyPage1.Populated += EditPage_Populated;
ShowTab(newPolicySnapshotFrequencyPage1);
}
if (is_VM_appliance)
{
ShowTab(newVMApplianceVMsPage1 = new NewVMGroupVMsPage<VM_appliance> { Pool = pool });
ShowTab(newVmApplianceVmOrderAndDelaysPage1 = new NewVMApplianceVMOrderAndDelaysPage { Pool = pool });
}
if (is_sr && ((SR)xenObjectCopy).SupportsReadCaching() && !Helpers.FeatureForbidden(xenObjectCopy, Host.RestrictReadCaching))
ShowTab(SrReadCachingEditPage = new SrReadCachingEditPage());
//
// Now add one tab per VBD (for VDIs only)
//
if (!is_vdi)
return;
ShowTab(vdiSizeLocation = new VDISizeLocationPage());
VDI vdi = xenObjectCopy as VDI;
List<VBDEditPage> vbdEditPages = new List<VBDEditPage>();
foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
{
VBDEditPage editPage = new VBDEditPage();
editPage.SetXenObjects(null, vbd);
vbdEditPages.Add(editPage);
ShowTab(editPage);
}
if (vbdEditPages.Count <= 0)
return;
using (var dialog = new ActionProgressDialog(
new DelegatedAsyncAction(vdi.Connection, Messages.DEVICE_POSITION_SCANNING,
Messages.DEVICE_POSITION_SCANNING, Messages.DEVICE_POSITION_SCANNED,
delegate(Session session)
{
foreach (VBDEditPage page in vbdEditPages)
page.UpdateDevicePositions(session);
}),
ProgressBarStyle.Continuous))
{
dialog.ShowCancel = true;
dialog.ShowDialog(Program.MainWindow);
}
}
finally
{
ContentPanel.ResumeLayout();
verticalTabs.EndUpdate();
verticalTabs.SelectedIndex = 0;
}
}
private void ShowTab(IEditPage editPage)
{
var pageAsControl = (Control)editPage;
ContentPanel.Controls.Add(pageAsControl);
pageAsControl.BackColor = Color.Transparent;
pageAsControl.Dock = DockStyle.Fill;
editPage.SetXenObjects(xenObject, xenObjectCopy);
verticalTabs.Items.Add(editPage);
}
private void EditPage_Populated()
{
verticalTabs.Refresh();
}
private void btnOK_Click(object sender, EventArgs e)
{
if (!ValidToSave)
{
// Keep dialog open and allow user to correct the error as
// indicated by the balloon tooltip.
DialogResult = DialogResult.None;
return;
}
// Have any of the fields in the tab pages changed?
if (!HasChanged)
{
Close();
return;
}
// Yes, save to the LocalXenObject.
List<AsyncAction> actions = SaveSettings();
Program.Invoke(Program.MainWindow.GeneralPage, Program.MainWindow.GeneralPage.UpdateButtons);
// Add a save changes on the beginning of the actions to enact the alterations that were just changes to the xenObjectCopy.
// Must come first because some pages' SaveChanges() rely on modifying the object via the xenObjectCopy before their actions are run.
if(xenObjectBefore is VMSS)
{
XenAPI.VMSS VMSSObj = xenObjectBefore as XenAPI.VMSS;
if (VMSSObj.type == vmss_type.snapshot_with_quiesce)
{
actions.Insert(0, new SaveChangesAction(xenObjectCopy, xenObjectBefore, true));
}
else
{
actions.Insert(actions.Count, new SaveChangesAction(xenObjectCopy, xenObjectBefore, true));
}
}
else
{
actions.Insert(0, new SaveChangesAction(xenObjectCopy, xenObjectBefore, true));
}
var objName = Helpers.GetName(xenObject).Ellipsise(50);
_action = new MultipleAction(
connection,
string.Format(Messages.UPDATE_PROPERTIES, objName),
Messages.UPDATING_PROPERTIES,
string.Format(Messages.UPDATED_PROPERTIES, objName),
actions);
_action.SetObject(xenObjectCopy);
_action.Completed += action_Completed;
Close();
if (_startAction)
{
_action.RunAsync();
}
}
private void action_Completed(ActionBase sender)
{
Program.Invoke(Program.MainWindow.GeneralPage, Program.MainWindow.GeneralPage.UpdateButtons);
}
/*
* Iterates through all of the tab pages checking for changes and
* return the status.
*/
private bool HasChanged
{
get
{
foreach (IEditPage editPage in verticalTabs.Items)
if (editPage.HasChanged)
return true;
return false;
}
}
/*
* Iterate through all tab pages looking for local validation errors. If
* we encounter a local validation error on a TabPage, then make the TabPage
* the selected, and have the inner control show one or more balloon tips. Keep
* the dialog open.
*/
private bool ValidToSave
{
get
{
foreach (IEditPage editPage in verticalTabs.Items)
if (!editPage.ValidToSave)
{
SelectPage(editPage);
// Show local validation balloon message for this tab page.
editPage.ShowLocalValidationMessages();
return false;
}
return true;
}
}
/*
* Iterates through all of the tab pages, saving changes to their cloned XenObjects,
* and accumulating and returning their Actions for further processing.
*/
private List<AsyncAction> SaveSettings()
{
List<AsyncAction> actions = new List<AsyncAction>();
AsyncAction finalAction = null;
foreach (IEditPage editPage in verticalTabs.Items)
{
if (!editPage.HasChanged)
continue;
AsyncAction action = editPage.SaveSettings();
if (action == null)
continue;
if (action is SetSslLegacyAction)
finalAction = action; // annoying special case: SetSslLegacyAction must be last because it will disrupt the connection and we may lose later actions
else
actions.Add(action);
}
if (finalAction != null)
actions.Add(finalAction);
return actions;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
Close();
}
protected sealed override void OnFormClosing(FormClosingEventArgs e)
{
foreach (IEditPage editPage in verticalTabs.Items)
{
editPage.Cleanup();
}
var args = new PropertiesDialogClosingEventArgs(_action, _startAction);
OnFormClosing(args);
_startAction = args.StartAction;
}
protected virtual void OnFormClosing(PropertiesDialogClosingEventArgs e)
{
var handler = FormClosing;
if (handler != null)
{
handler(this, e);
}
}
private void verticalTabs_SelectedIndexChanged(object sender, EventArgs e)
{
var snapshotTypePage = verticalTabs.SelectedItem as NewPolicySnapshotTypePage;
if (snapshotTypePage != null)
{
newPolicyVMSSTypePage1.ToggleQuiesceCheckBox(newVMSSVMsPage1.SelectedVMs);
return;
}
var vmApplianceStartOrderPage = verticalTabs.SelectedItem as NewVMApplianceVMOrderAndDelaysPage;
if (vmApplianceStartOrderPage != null && newVMApplianceVMsPage1 != null)
{
vmApplianceStartOrderPage.SetSelectedVMs(newVMApplianceVMsPage1.SelectedVMs);
return;
}
if (verticalTabs.SelectedItem == VMHAEditPage)
{
VMHAEditPage.StartNtolUpdate();
if (GpuEditPage != null)
{
VMHAEditPage.VGpus = GpuEditPage.VGpus;
VMHAEditPage.RefillPrioritiesComboBox();
}
return;
}
if (verticalTabs.SelectedItem == GpuEditPage && VMHAEditPage != null)
{
GpuEditPage.SelectedPriority = VMHAEditPage.SelectedPriority;
GpuEditPage.ShowHideWarnings();
return;
}
if (verticalTabs.SelectedItem == usbEditPage && VMHAEditPage != null)
{
usbEditPage.SelectedPriority = VMHAEditPage.SelectedPriority;
usbEditPage.ShowHideWarnings();
return;
}
if (verticalTabs.SelectedItem == HostPowerONEditPage)
{
HostPowerONEditPage.LoadPowerOnMode();
return;
}
HideToolTips();
}
private void HideToolTips()
{
foreach (IEditPage page in verticalTabs.Items)
{
page.HideLocalValidationMessages();
}
}
private void PropertiesDialog_Moved(object sender, EventArgs e)
{
HideToolTips();
}
private void PropertiesDialog_FormClosed(object sender, FormClosedEventArgs e)
{
timer.Stop();
}
#region Select page methods
public void EditName()
{
SelectPage(GeneralEditPage);
GeneralEditPage.SelectName();
}
public void EditDescription()
{
SelectPage(GeneralEditPage);
GeneralEditPage.SelectDescription();
}
public void EditIqn()
{
SelectPage(GeneralEditPage);
GeneralEditPage.SelectIqn();
}
public void SelectCustomFieldsEditPage()
{
SelectPage(CustomFieldsEditPage);
}
public void SelectPoolGpuEditPage()
{
SelectPage(PoolGpuEditPage);
}
public void SelectPerfmonAlertEditPage()
{
SelectPage(PerfmonAlertEditPage);
}
public void SelectStartupOptionsEditPage()
{
SelectPage(StartupOptionsEditPage);
}
public void SelectHomeServerEditPage()
{
SelectPage(HomeServerPage);
}
public void SelectLogDestinationEditPage()
{
SelectPage(LogDestinationEditPage);
}
public void SelectVMHAEditPage()
{
SelectPage(VMHAEditPage);
}
public void SelectVMCPUEditPage()
{
SelectPage(VCpuMemoryEditPage);
}
public void SelectVdiSizeLocationPage()
{
SelectPage(vdiSizeLocation);
}
public void SelectClusteringEditPage()
{
SelectPage(ClusteringEditPage);
}
#endregion
}
public class PropertiesDialogClosingEventArgs : EventArgs
{
public AsyncAction Action { get; private set; }
public bool StartAction { get; set; }
public PropertiesDialogClosingEventArgs(AsyncAction action, bool startAction)
{
StartAction = startAction;
Action = action;
}
}
}