CA-235381: XenCenter should not allow users to edit the PVS cache storage if it is in use

- On the PVS Cache Configuration dialog, disable the cache storage fields with an information tooltip stating that this PVS cache storage cannot be changed because it is in use.
- Also set the minimum width for the splitter panels, to avoid display issues when the splitter is moved and either of the panels becomes unusable.

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2016-12-07 17:45:50 +00:00
parent c395a8ce14
commit 1156d57787
8 changed files with 163 additions and 12 deletions

View File

@ -28,16 +28,20 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PvsCacheStorageRow));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.labelUnits = new System.Windows.Forms.Label();
this.numericUpDownCacheSize = new System.Windows.Forms.NumericUpDown();
this.comboBoxCacheSr = new EnableableComboBox();
this.comboBoxCacheSr = new XenAdmin.Controls.EnableableComboBox();
this.labelHostName = new System.Windows.Forms.Label();
this.labelCacheStorage = new System.Windows.Forms.Label();
this.labelCacheSize = new System.Windows.Forms.Label();
this.pictureBoxInfo = new System.Windows.Forms.PictureBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCacheSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo)).BeginInit();
this.SuspendLayout();
//
// tableLayoutPanel1
@ -49,6 +53,7 @@
this.tableLayoutPanel1.Controls.Add(this.labelHostName, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.labelCacheStorage, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.labelCacheSize, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.pictureBoxInfo, 5, 1);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// labelUnits
@ -69,9 +74,10 @@
//
// comboBoxCacheSr
//
resources.ApplyResources(this.comboBoxCacheSr, "comboBoxCacheSr");
this.comboBoxCacheSr.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.comboBoxCacheSr.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCacheSr.FormattingEnabled = true;
resources.ApplyResources(this.comboBoxCacheSr, "comboBoxCacheSr");
this.comboBoxCacheSr.Name = "comboBoxCacheSr";
this.comboBoxCacheSr.SelectedIndexChanged += new System.EventHandler(this.comboBoxCacheSr_SelectedIndexChanged);
//
@ -91,6 +97,16 @@
resources.ApplyResources(this.labelCacheSize, "labelCacheSize");
this.labelCacheSize.Name = "labelCacheSize";
//
// pictureBoxInfo
//
this.pictureBoxInfo.Cursor = System.Windows.Forms.Cursors.Hand;
resources.ApplyResources(this.pictureBoxInfo, "pictureBoxInfo");
this.pictureBoxInfo.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16;
this.pictureBoxInfo.Name = "pictureBoxInfo";
this.pictureBoxInfo.TabStop = false;
this.pictureBoxInfo.Click += new System.EventHandler(this.pictureBoxInfo_Click);
this.pictureBoxInfo.MouseLeave += new System.EventHandler(this.pictureBoxInfo_MouseLeave);
//
// PvsCacheStorageRow
//
resources.ApplyResources(this, "$this");
@ -100,6 +116,7 @@
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCacheSize)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxInfo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -114,5 +131,7 @@
private System.Windows.Forms.Label labelCacheSize;
private System.Windows.Forms.Label labelUnits;
private System.Windows.Forms.NumericUpDown numericUpDownCacheSize;
private System.Windows.Forms.PictureBox pictureBoxInfo;
private System.Windows.Forms.ToolTip toolTip;
}
}

View File

@ -70,6 +70,9 @@ namespace XenAdmin.Controls
origCacheSizeGb = numericUpDownCacheSize.Value;
PopulateCacheSrCombobox();
var isInUse = OrigPvsCacheStorage != null && OrigPvsCacheStorage.IsInUse;
comboBoxCacheSr.Enabled = numericUpDownCacheSize.Enabled = !isInUse;
pictureBoxInfo.Visible = isInUse;
}
private void PopulateCacheSrCombobox()
@ -199,6 +202,16 @@ namespace XenAdmin.Controls
}
SomethingChanged(this, e);
}
private void pictureBoxInfo_Click(object sender, EventArgs e)
{
toolTip.Show(Messages.PVS_CACHE_STORAGE_CANNOT_BE_CHANGED, pictureBoxInfo, 20, 0);
}
private void pictureBoxInfo_MouseLeave(object sender, EventArgs e)
{
toolTip.Hide(pictureBoxInfo);
}
}
public class SrComboBoxItem : IEnableableComboBoxItem

View File

@ -122,7 +122,7 @@
<value>True</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>5</value>
<value>6</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labelUnits.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
@ -130,7 +130,7 @@
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="labelUnits.Location" type="System.Drawing.Point, System.Drawing">
<value>402, 22</value>
<value>395, 22</value>
</data>
<data name="labelUnits.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
@ -160,7 +160,7 @@
<value>0</value>
</data>
<data name="numericUpDownCacheSize.Location" type="System.Drawing.Point, System.Drawing">
<value>324, 22</value>
<value>317, 22</value>
</data>
<data name="numericUpDownCacheSize.Size" type="System.Drawing.Size, System.Drawing">
<value>72, 20</value>
@ -180,11 +180,14 @@
<data name="&gt;&gt;numericUpDownCacheSize.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="comboBoxCacheSr.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<data name="comboBoxCacheSr.Location" type="System.Drawing.Point, System.Drawing">
<value>114, 22</value>
</data>
<data name="comboBoxCacheSr.Size" type="System.Drawing.Size, System.Drawing">
<value>196, 21</value>
<value>189, 21</value>
</data>
<data name="comboBoxCacheSr.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -193,7 +196,7 @@
<value>comboBoxCacheSr</value>
</data>
<data name="&gt;&gt;comboBoxCacheSr.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>XenAdmin.Controls.EnableableComboBox, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;comboBoxCacheSr.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
@ -253,7 +256,7 @@
<value>3, 3, 3, 3</value>
</data>
<data name="labelCacheStorage.Size" type="System.Drawing.Size, System.Drawing">
<value>196, 13</value>
<value>189, 13</value>
</data>
<data name="labelCacheStorage.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -289,7 +292,7 @@
<value>NoControl</value>
</data>
<data name="labelCacheSize.Location" type="System.Drawing.Point, System.Drawing">
<value>324, 3</value>
<value>317, 3</value>
</data>
<data name="labelCacheSize.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
@ -318,6 +321,39 @@
<data name="&gt;&gt;labelCacheSize.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="pictureBoxInfo.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
</data>
<data name="pictureBoxInfo.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="pictureBoxInfo.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBoxInfo.Location" type="System.Drawing.Point, System.Drawing">
<value>427, 22</value>
</data>
<data name="pictureBoxInfo.Size" type="System.Drawing.Size, System.Drawing">
<value>20, 21</value>
</data>
<data name="pictureBoxInfo.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>CenterImage</value>
</data>
<data name="pictureBoxInfo.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="&gt;&gt;pictureBoxInfo.Name" xml:space="preserve">
<value>pictureBoxInfo</value>
</data>
<data name="&gt;&gt;pictureBoxInfo.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBoxInfo.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;pictureBoxInfo.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Top</value>
</data>
@ -328,7 +364,7 @@
<value>2</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>431, 46</value>
<value>450, 46</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -346,8 +382,11 @@
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelUnits" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="numericUpDownCacheSize" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="comboBoxCacheSr" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelHostName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="labelCacheStorage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelCacheSize" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,111,AutoSize,0,Absolute,8,AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelUnits" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="numericUpDownCacheSize" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="comboBoxCacheSr" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelHostName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="labelCacheStorage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelCacheSize" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="pictureBoxInfo" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,111,Percent,100,Absolute,8,AutoSize,0,AutoSize,0,Absolute,26" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -357,8 +396,17 @@
<data name="$this.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>360, 21</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>431, 47</value>
<value>450, 47</value>
</data>
<data name="&gt;&gt;toolTip.Name" xml:space="preserve">
<value>toolTip</value>
</data>
<data name="&gt;&gt;toolTip.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>PvsCacheStorageRow</value>

View File

@ -306,6 +306,9 @@
<data name="&gt;&gt;splitContainer.Panel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="splitContainer.Panel1MinSize" type="System.Int32, mscorlib">
<value>100</value>
</data>
<data name="&gt;&gt;splitContainer.Panel2.Name" xml:space="preserve">
<value>splitContainer.Panel2</value>
</data>
@ -318,6 +321,9 @@
<data name="&gt;&gt;splitContainer.Panel2.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="splitContainer.Panel2MinSize" type="System.Int32, mscorlib">
<value>400</value>
</data>
<data name="splitContainer.Size" type="System.Drawing.Size, System.Drawing">
<value>763, 474</value>
</data>

View File

@ -28191,6 +28191,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to This PVS cache storage cannot be changed because it is in use..
/// </summary>
public static string PVS_CACHE_STORAGE_CANNOT_BE_CHANGED {
get {
return ResourceManager.GetString("PVS_CACHE_STORAGE_CANNOT_BE_CHANGED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} (Incomplete Cache Storage configuration).
/// </summary>

View File

@ -9799,6 +9799,9 @@ Press OK to continue the wizard and return to the server and follow the instruct
<data name="PVS_CACHE_NOT_CONFIGURED" xml:space="preserve">
<value>Not configured</value>
</data>
<data name="PVS_CACHE_STORAGE_CANNOT_BE_CHANGED" xml:space="preserve">
<value>This PVS cache storage cannot be changed because it is in use.</value>
</data>
<data name="PVS_CACHE_STORAGE_NOT_CONFIGURED" xml:space="preserve">
<value>{0} (Incomplete Cache Storage configuration)</value>
</data>

View File

@ -0,0 +1,52 @@
/* 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.
*/
namespace XenAPI
{
public partial class PVS_cache_storage
{
public bool IsInUse
{
get
{
foreach (var pvsProxy in Connection.Cache.PVS_proxies)
{
var vm = pvsProxy.VM;
if (vm != null && vm.resident_on.opaque_ref == host.opaque_ref &&
pvsProxy.site.opaque_ref == site.opaque_ref && pvsProxy.currently_attached)
return true;
}
return false;
}
}
}
}

View File

@ -330,6 +330,7 @@
<Compile Include="WLB\WlbServerState.cs" />
<Compile Include="XenAPI-Extensions\Blob.cs" />
<Compile Include="XenAPI-Extensions\Pool_update.cs" />
<Compile Include="XenAPI-Extensions\PVS_cache_storage.cs" />
<Compile Include="XenAPI-Extensions\pvs_proxy_status.cs" />
<Compile Include="XenAPI-Extensions\PVS_site.cs" />
<Compile Include="XenAPI-Extensions\PVS_proxy.cs" />