Merge pull request #645 from agimofcarmen/CP-13902

CP 13902 - Refactors Provisioning page in SR wizards to use the new control…
This commit is contained in:
Mihaela Stoica 2015-09-02 13:30:45 +01:00
commit 90d4b09eab
8 changed files with 117 additions and 454 deletions

View File

@ -31,10 +31,10 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ThinProvisioningParametersControl));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.incremental_allocation_units = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.initial_allocation_label = new System.Windows.Forms.Label();
this.initialAllocationNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.initial_allocation_units = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.incremental_allocation_label = new System.Windows.Forms.Label();
this.allocationQuantumNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.initialAllocationNumericUpDown)).BeginInit();
@ -45,10 +45,10 @@
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.incremental_allocation_units, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.initial_allocation_label, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.initialAllocationNumericUpDown, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.initial_allocation_units, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.incremental_allocation_label, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.allocationQuantumNumericUpDown, 1, 1);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
@ -63,10 +63,10 @@
this.incremental_allocation_units.Name = "incremental_allocation_units";
this.incremental_allocation_units.SelectedIndexChanged += new System.EventHandler(this.incremental_allocation_units_SelectedIndexChanged);
//
// label1
// initial_allocation_label
//
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
resources.ApplyResources(this.initial_allocation_label, "initial_allocation_label");
this.initial_allocation_label.Name = "initial_allocation_label";
//
// initialAllocationNumericUpDown
//
@ -90,10 +90,10 @@
this.initial_allocation_units.Name = "initial_allocation_units";
this.initial_allocation_units.SelectedIndexChanged += new System.EventHandler(this.initial_allocation_units_SelectedIndexChanged);
//
// label2
// incremental_allocation_label
//
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
resources.ApplyResources(this.incremental_allocation_label, "incremental_allocation_label");
this.incremental_allocation_label.Name = "incremental_allocation_label";
//
// allocationQuantumNumericUpDown
//
@ -124,10 +124,10 @@
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label initial_allocation_label;
private System.Windows.Forms.NumericUpDown initialAllocationNumericUpDown;
private System.Windows.Forms.ComboBox initial_allocation_units;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label incremental_allocation_label;
private System.Windows.Forms.NumericUpDown allocationQuantumNumericUpDown;
private System.Windows.Forms.ComboBox incremental_allocation_units;
}

View File

@ -72,15 +72,19 @@ namespace XenAdmin.Controls
}
}
private long SRSize
public long SRSize
{
get
private get
{
if (sr != null)
return sr.physical_size;
return 0;
}
set
{
SR = new SR() { physical_size = value };
}
}
public Dictionary<string, string> SMConfig

View File

@ -145,7 +145,7 @@
<value>49, 23</value>
</data>
<data name="incremental_allocation_units.TabIndex" type="System.Int32, mscorlib">
<value>24</value>
<value>6</value>
</data>
<data name="&gt;&gt;incremental_allocation_units.Name" xml:space="preserve">
<value>incremental_allocation_units</value>
@ -159,40 +159,40 @@
<data name="&gt;&gt;incremental_allocation_units.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="label1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<data name="initial_allocation_label.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<data name="initial_allocation_label.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label1.Font" type="System.Drawing.Font, System.Drawing">
<data name="initial_allocation_label.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="label1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<data name="initial_allocation_label.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<data name="initial_allocation_label.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 7</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<data name="initial_allocation_label.Size" type="System.Drawing.Size, System.Drawing">
<value>94, 15</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
<data name="initial_allocation_label.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="label1.Text" xml:space="preserve">
<data name="initial_allocation_label.Text" xml:space="preserve">
<value>&amp;Initial allocation:</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
<data name="&gt;&gt;initial_allocation_label.Name" xml:space="preserve">
<value>initial_allocation_label</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<data name="&gt;&gt;initial_allocation_label.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<data name="&gt;&gt;initial_allocation_label.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<data name="&gt;&gt;initial_allocation_label.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="initialAllocationNumericUpDown.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
@ -211,7 +211,7 @@
<value>105, 23</value>
</data>
<data name="initialAllocationNumericUpDown.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
<value>2</value>
</data>
<data name="initialAllocationNumericUpDown.TextAlign" type="System.Windows.Forms.HorizontalAlignment, System.Windows.Forms">
<value>Right</value>
@ -244,7 +244,7 @@
<value>49, 23</value>
</data>
<data name="initial_allocation_units.TabIndex" type="System.Int32, mscorlib">
<value>23</value>
<value>3</value>
</data>
<data name="&gt;&gt;initial_allocation_units.Name" xml:space="preserve">
<value>initial_allocation_units</value>
@ -258,40 +258,40 @@
<data name="&gt;&gt;initial_allocation_units.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="label2.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<data name="incremental_allocation_label.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<data name="incremental_allocation_label.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label2.Font" type="System.Drawing.Font, System.Drawing">
<data name="incremental_allocation_label.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="label2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<data name="incremental_allocation_label.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<data name="incremental_allocation_label.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 36</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<data name="incremental_allocation_label.Size" type="System.Drawing.Size, System.Drawing">
<value>133, 15</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
<data name="incremental_allocation_label.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="label2.Text" xml:space="preserve">
<data name="incremental_allocation_label.Text" xml:space="preserve">
<value>In&amp;cremental allocations:</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
<data name="&gt;&gt;incremental_allocation_label.Name" xml:space="preserve">
<value>incremental_allocation_label</value>
</data>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<data name="&gt;&gt;incremental_allocation_label.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<data name="&gt;&gt;incremental_allocation_label.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<data name="&gt;&gt;incremental_allocation_label.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="allocationQuantumNumericUpDown.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
@ -310,7 +310,7 @@
<value>105, 23</value>
</data>
<data name="allocationQuantumNumericUpDown.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
<value>5</value>
</data>
<data name="allocationQuantumNumericUpDown.TextAlign" type="System.Windows.Forms.HorizontalAlignment, System.Windows.Forms">
<value>Right</value>
@ -352,7 +352,7 @@
<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="incremental_allocation_units" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="initialAllocationNumericUpDown" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="initial_allocation_units" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="allocationQuantumNumericUpDown" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0" /&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="incremental_allocation_units" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="initial_allocation_label" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="initialAllocationNumericUpDown" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="initial_allocation_units" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="incremental_allocation_label" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="allocationQuantumNumericUpDown" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>

View File

@ -728,7 +728,7 @@ namespace XenAdmin.Dialogs
// therefore they use the same converting function.
private void incr_alloc_units_SelectedIndexChanged(object sender, EventArgs e)
{
StorageProvisioning.UpdateValuesWhenUnitsChanged(allocationQuantumNumericUpDown, previousUnitsValueIncrAlloc, incr_alloc_units.SelectedItem.ToString());
UpdateValuesWhenUnitsChanged(allocationQuantumNumericUpDown, previousUnitsValueIncrAlloc, incr_alloc_units.SelectedItem.ToString());
previousUnitsValueIncrAlloc = incr_alloc_units.SelectedItem.ToString();
}

View File

@ -31,31 +31,19 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StorageProvisioning));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.initialAllocationNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.radioButtonThickProvisioning = new System.Windows.Forms.RadioButton();
this.labelInitialAllocation = new System.Windows.Forms.Label();
this.radioButtonThinProvisioning = new System.Windows.Forms.RadioButton();
this.labelAllocationQuantum = new System.Windows.Forms.Label();
this.allocationQuantumNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.initial_allocation_units = new System.Windows.Forms.ComboBox();
this.incremental_allocation_units = new System.Windows.Forms.ComboBox();
this.thinProvisioningAllocationsControl = new XenAdmin.Controls.ThinProvisioningParametersControl();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.initialAllocationNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.allocationQuantumNumericUpDown)).BeginInit();
this.SuspendLayout();
//
// tableLayoutPanel1
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.initialAllocationNumericUpDown, 2, 4);
this.tableLayoutPanel1.Controls.Add(this.radioButtonThickProvisioning, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.labelInitialAllocation, 1, 4);
this.tableLayoutPanel1.Controls.Add(this.radioButtonThinProvisioning, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.labelAllocationQuantum, 1, 5);
this.tableLayoutPanel1.Controls.Add(this.allocationQuantumNumericUpDown, 2, 5);
this.tableLayoutPanel1.Controls.Add(this.initial_allocation_units, 3, 4);
this.tableLayoutPanel1.Controls.Add(this.incremental_allocation_units, 3, 5);
this.tableLayoutPanel1.Controls.Add(this.thinProvisioningAllocationsControl, 1, 4);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// label1
@ -64,17 +52,6 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
this.tableLayoutPanel1.SetColumnSpan(this.label1, 5);
this.label1.Name = "label1";
//
// initialAllocationNumericUpDown
//
resources.ApplyResources(this.initialAllocationNumericUpDown, "initialAllocationNumericUpDown");
this.initialAllocationNumericUpDown.DecimalPlaces = 1;
this.initialAllocationNumericUpDown.Name = "initialAllocationNumericUpDown";
this.initialAllocationNumericUpDown.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// radioButtonThickProvisioning
//
resources.ApplyResources(this.radioButtonThickProvisioning, "radioButtonThickProvisioning");
@ -83,12 +60,6 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
this.radioButtonThickProvisioning.Name = "radioButtonThickProvisioning";
this.radioButtonThickProvisioning.TabStop = true;
this.radioButtonThickProvisioning.UseVisualStyleBackColor = true;
this.radioButtonThickProvisioning.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// labelInitialAllocation
//
resources.ApplyResources(this.labelInitialAllocation, "labelInitialAllocation");
this.labelInitialAllocation.Name = "labelInitialAllocation";
//
// radioButtonThinProvisioning
//
@ -96,45 +67,13 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
this.tableLayoutPanel1.SetColumnSpan(this.radioButtonThinProvisioning, 5);
this.radioButtonThinProvisioning.Name = "radioButtonThinProvisioning";
this.radioButtonThinProvisioning.UseVisualStyleBackColor = true;
this.radioButtonThinProvisioning.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//
// labelAllocationQuantum
// thinProvisioningAllocationsControl
//
resources.ApplyResources(this.labelAllocationQuantum, "labelAllocationQuantum");
this.labelAllocationQuantum.Name = "labelAllocationQuantum";
//
// allocationQuantumNumericUpDown
//
resources.ApplyResources(this.allocationQuantumNumericUpDown, "allocationQuantumNumericUpDown");
this.allocationQuantumNumericUpDown.DecimalPlaces = 1;
this.allocationQuantumNumericUpDown.Name = "allocationQuantumNumericUpDown";
this.allocationQuantumNumericUpDown.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// initial_allocation_units
//
this.initial_allocation_units.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.initial_allocation_units, "initial_allocation_units");
this.initial_allocation_units.FormattingEnabled = true;
this.initial_allocation_units.Items.AddRange(new object[] {
resources.GetString("initial_allocation_units.Items"),
resources.GetString("initial_allocation_units.Items1")});
this.initial_allocation_units.Name = "initial_allocation_units";
this.initial_allocation_units.SelectedIndexChanged += new System.EventHandler(this.initial_allocation_units_SelectedIndexChanged);
//
// incremental_allocation_units
//
this.incremental_allocation_units.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.incremental_allocation_units, "incremental_allocation_units");
this.incremental_allocation_units.FormattingEnabled = true;
this.incremental_allocation_units.Items.AddRange(new object[] {
resources.GetString("incremental_allocation_units.Items"),
resources.GetString("incremental_allocation_units.Items1")});
this.incremental_allocation_units.Name = "incremental_allocation_units";
this.incremental_allocation_units.SelectedIndexChanged += new System.EventHandler(this.incremental_allocation_units_SelectedIndexChanged);
resources.ApplyResources(this.thinProvisioningAllocationsControl, "thinProvisioningAllocationsControl");
this.tableLayoutPanel1.SetColumnSpan(this.thinProvisioningAllocationsControl, 3);
this.thinProvisioningAllocationsControl.Name = "thinProvisioningAllocationsControl";
this.thinProvisioningAllocationsControl.Enter += new System.EventHandler(this.thinProvisioningAllocationsControl_Enter);
//
// StorageProvisioning
//
@ -143,8 +82,6 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
resources.ApplyResources(this, "$this");
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.initialAllocationNumericUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.allocationQuantumNumericUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -152,15 +89,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
#endregion
private System.Windows.Forms.NumericUpDown initialAllocationNumericUpDown;
private System.Windows.Forms.Label labelInitialAllocation;
private System.Windows.Forms.RadioButton radioButtonThinProvisioning;
private System.Windows.Forms.RadioButton radioButtonThickProvisioning;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label labelAllocationQuantum;
private System.Windows.Forms.NumericUpDown allocationQuantumNumericUpDown;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox initial_allocation_units;
private System.Windows.Forms.ComboBox incremental_allocation_units;
private System.Windows.Forms.RadioButton radioButtonThinProvisioning;
private Controls.ThinProvisioningParametersControl thinProvisioningAllocationsControl;
}
}

View File

@ -44,18 +44,15 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
{
public partial class StorageProvisioning : XenTabPage
{
private string previousUnitsValueInitAlloc;
private string previousUnitsValueIncrAlloc;
private const int DecimalPlacesMB = 0;
private const int DecimalPlacesGB = 3;
private const int IncrementMB = 256;
private const int IncrementGB = 1;
private long srSize;
public StorageProvisioning()
{
InitializeComponent();
incremental_allocation_units.SelectedItem = previousUnitsValueIncrAlloc = Messages.VAL_MEGB;
initial_allocation_units.SelectedItem = previousUnitsValueInitAlloc = Messages.VAL_MEGB;
}
#region Accessors
@ -66,24 +63,30 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
{
get
{
var smconfig = new Dictionary<string, string>();
if (radioButtonThinProvisioning.Checked)
{
smconfig["allocation"] = "xlvhd";
smconfig["allocation_quantum"] = (incremental_allocation_units.SelectedItem.ToString() == Messages.VAL_MEGB ? (long)(allocationQuantumNumericUpDown.Value * Util.BINARY_MEGA)
: (long)(allocationQuantumNumericUpDown.Value * Util.BINARY_GIGA))
.ToString(CultureInfo.InvariantCulture);
smconfig["initial_allocation"] = (initial_allocation_units.SelectedItem.ToString() == Messages.VAL_MEGB ? (long)(initialAllocationNumericUpDown.Value * Util.BINARY_MEGA)
: (long)(initialAllocationNumericUpDown.Value * Util.BINARY_GIGA))
.ToString(CultureInfo.InvariantCulture);
return thinProvisioningAllocationsControl.SMConfig;
}
return smconfig;
return new Dictionary<string, string>();
}
}
public long SRSize { get; set; }
public long SRSize
{
get
{
return srSize;
}
set
{
if(srSize != value)
{
srSize = value;
thinProvisioningAllocationsControl.SRSize = SRSize;
}
}
}
#endregion
@ -92,72 +95,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
#region XenTabPage overrides
public override void PopulatePage()
{
InitializeNumericUpDowns();
UpdateControls();
{
OnPageUpdated();
}
private void InitializeNumericUpDowns()
{
// Because we do not initialize the NumericUpDown with values from an existing sm_config
// the value passed to the setup functions is -1.
SetUpInitAllocationNumericUpDown(-1);
SetUpIncrAllocationNumericUpDown(-1);
}
private void SetNumUpDownIncrementAndDecimals(NumericUpDown upDown, string units)
{
if (units == Messages.VAL_GIGB)
{
upDown.DecimalPlaces = DecimalPlacesGB;
upDown.Increment = IncrementGB;
}
else
{
upDown.DecimalPlaces = DecimalPlacesMB;
upDown.Increment = IncrementMB;
}
}
// The value parameter is -1 if we do not use an existing SM Config. Otherwise
// it is the value of the initial_allocation in the SM config. The value received is in bytes.
private void SetUpInitAllocationNumericUpDown(decimal value)
{
Helpers.AllocationBounds allocBounds = Helpers.SRInitialAllocationBounds(SRSize);
if(value != -1)
{
allocBounds = new Helpers.AllocationBounds(allocBounds.Min, allocBounds.Max, value);
}
initialAllocationNumericUpDown.Minimum = allocBounds.MinInUnits;
initialAllocationNumericUpDown.Maximum = allocBounds.MaxInUnits;
initialAllocationNumericUpDown.Value = allocBounds.DefaultValueInUnits;
initial_allocation_units.SelectedItem = previousUnitsValueInitAlloc = allocBounds.Unit;
SetNumUpDownIncrementAndDecimals(initialAllocationNumericUpDown, allocBounds.Unit);
}
// The value parameter is -1 if we do not use an existing SM Config. Otherwise
// it is the value of the allocation_quantum in the SM config.
private void SetUpIncrAllocationNumericUpDown(decimal value)
{
Helpers.AllocationBounds allocBounds = Helpers.SRIncrementalAllocationBounds(SRSize);
if (value != -1)
{
allocBounds = new Helpers.AllocationBounds(allocBounds.Min, allocBounds.Max, value);
}
allocationQuantumNumericUpDown.Minimum = allocBounds.MinInUnits;
allocationQuantumNumericUpDown.Maximum = allocBounds.MaxInUnits;
allocationQuantumNumericUpDown.Value = allocBounds.DefaultValueInUnits;
incremental_allocation_units.SelectedItem = previousUnitsValueInitAlloc = allocBounds.Unit;
SetNumUpDownIncrementAndDecimals(allocationQuantumNumericUpDown, allocBounds.Unit);
}
public override string PageTitle { get { return Messages.STORAGE_PROVISIONING_METHOD_TITLE; } }
public override string Text { get { return Messages.STORAGE_PROVISIONING_SETTINGS; } }
@ -170,13 +111,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
}
#endregion
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
UpdateControls();
}
public void DisableControls()
{
foreach (Control c in Controls)
@ -187,28 +122,16 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
{
foreach (Control c in Controls)
c.Enabled = true;
UpdateControls();
}
public void SetControlsUsingExistingSMConfig(Dictionary<string, string> smConfig)
{
long temp = 0;
if (smConfig.ContainsKey("allocation") && smConfig["allocation"] == "xlvhd")
{
radioButtonThickProvisioning.Checked = false;
radioButtonThinProvisioning.Checked = true;
if (smConfig.ContainsKey("initial_allocation") && long.TryParse(smConfig["initial_allocation"], out temp))
{
SetUpInitAllocationNumericUpDown(temp);
}
if (smConfig.ContainsKey("allocation_quantum") && long.TryParse(smConfig["allocation_quantum"], out temp))
{
SetUpIncrAllocationNumericUpDown(temp);
}
thinProvisioningAllocationsControl.SetControlsUsingExistingSMConfig(smConfig);
}
else
{
@ -217,54 +140,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
}
}
private void UpdateControls()
private void thinProvisioningAllocationsControl_Enter(object sender, EventArgs e)
{
labelAllocationQuantum.Enabled =
labelInitialAllocation.Enabled =
allocationQuantumNumericUpDown.Enabled =
initial_allocation_units.Enabled =
incremental_allocation_units.Enabled =
initialAllocationNumericUpDown.Enabled = radioButtonThinProvisioning.Checked;
}
private void initial_allocation_units_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateValuesWhenUnitsChanged(initialAllocationNumericUpDown,
previousUnitsValueInitAlloc,
initial_allocation_units.SelectedItem.ToString());
previousUnitsValueInitAlloc = initial_allocation_units.SelectedItem.ToString();
}
private void incremental_allocation_units_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateValuesWhenUnitsChanged(allocationQuantumNumericUpDown,
previousUnitsValueIncrAlloc,
incremental_allocation_units.SelectedItem.ToString());
previousUnitsValueIncrAlloc = incremental_allocation_units.SelectedItem.ToString();
}
public static void UpdateValuesWhenUnitsChanged(NumericUpDown upDown, string previousUnits, string newUnits)
{
if (previousUnits == newUnits)
return;
if (newUnits == Messages.VAL_MEGB)
{
upDown.Maximum *= Util.BINARY_KILO;
upDown.Value *= Util.BINARY_KILO;
upDown.Minimum *= Util.BINARY_KILO;
upDown.DecimalPlaces = DecimalPlacesMB;
upDown.Increment = IncrementMB;
}
else
{
upDown.Minimum /= Util.BINARY_KILO;
upDown.Value /= Util.BINARY_KILO;
upDown.Maximum /= Util.BINARY_KILO;
upDown.DecimalPlaces = DecimalPlacesGB;
upDown.Increment = IncrementGB;
}
}
radioButtonThickProvisioning.Checked = false;
radioButtonThinProvisioning.Checked = true;
}
}
}

View File

@ -162,36 +162,6 @@
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="initialAllocationNumericUpDown.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="initialAllocationNumericUpDown.Location" type="System.Drawing.Point, System.Drawing">
<value>174, 109</value>
</data>
<data name="initialAllocationNumericUpDown.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>105, 0</value>
</data>
<data name="initialAllocationNumericUpDown.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 20</value>
</data>
<data name="initialAllocationNumericUpDown.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="initialAllocationNumericUpDown.TextAlign" type="System.Windows.Forms.HorizontalAlignment, System.Windows.Forms">
<value>Right</value>
</data>
<data name="&gt;&gt;initialAllocationNumericUpDown.Name" xml:space="preserve">
<value>initialAllocationNumericUpDown</value>
</data>
<data name="&gt;&gt;initialAllocationNumericUpDown.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;initialAllocationNumericUpDown.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;initialAllocationNumericUpDown.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="radioButtonThickProvisioning.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -220,40 +190,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;radioButtonThickProvisioning.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="labelInitialAllocation.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="labelInitialAllocation.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelInitialAllocation.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="labelInitialAllocation.Location" type="System.Drawing.Point, System.Drawing">
<value>33, 113</value>
</data>
<data name="labelInitialAllocation.Size" type="System.Drawing.Size, System.Drawing">
<value>135, 13</value>
</data>
<data name="labelInitialAllocation.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="labelInitialAllocation.Text" xml:space="preserve">
<value>Virtual disk &amp;initial allocation:</value>
</data>
<data name="&gt;&gt;labelInitialAllocation.Name" xml:space="preserve">
<value>labelInitialAllocation</value>
</data>
<data name="&gt;&gt;labelInitialAllocation.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelInitialAllocation.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelInitialAllocation.ZOrder" xml:space="preserve">
<value>3</value>
<value>1</value>
</data>
<data name="radioButtonThinProvisioning.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -283,130 +220,34 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;radioButtonThinProvisioning.ZOrder" xml:space="preserve">
<value>4</value>
<value>2</value>
</data>
<data name="labelAllocationQuantum.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="labelAllocationQuantum.AutoSize" type="System.Boolean, mscorlib">
<data name="thinProvisioningAllocationsControl.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelAllocationQuantum.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
<data name="thinProvisioningAllocationsControl.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="labelAllocationQuantum.Location" type="System.Drawing.Point, System.Drawing">
<value>33, 142</value>
<data name="thinProvisioningAllocationsControl.Location" type="System.Drawing.Point, System.Drawing">
<value>33, 108</value>
</data>
<data name="labelAllocationQuantum.Size" type="System.Drawing.Size, System.Drawing">
<value>118, 13</value>
<data name="thinProvisioningAllocationsControl.Size" type="System.Drawing.Size, System.Drawing">
<value>308, 64</value>
</data>
<data name="labelAllocationQuantum.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
<data name="thinProvisioningAllocationsControl.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="labelAllocationQuantum.Text" xml:space="preserve">
<value>In&amp;cremental allocations:</value>
<data name="&gt;&gt;thinProvisioningAllocationsControl.Name" xml:space="preserve">
<value>thinProvisioningAllocationsControl</value>
</data>
<data name="&gt;&gt;labelAllocationQuantum.Name" xml:space="preserve">
<value>labelAllocationQuantum</value>
<data name="&gt;&gt;thinProvisioningAllocationsControl.Type" xml:space="preserve">
<value>XenAdmin.Controls.ThinProvisioningParametersControl, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;labelAllocationQuantum.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelAllocationQuantum.Parent" xml:space="preserve">
<data name="&gt;&gt;thinProvisioningAllocationsControl.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelAllocationQuantum.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="allocationQuantumNumericUpDown.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="allocationQuantumNumericUpDown.Location" type="System.Drawing.Point, System.Drawing">
<value>174, 138</value>
</data>
<data name="allocationQuantumNumericUpDown.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>105, 0</value>
</data>
<data name="allocationQuantumNumericUpDown.Size" type="System.Drawing.Size, System.Drawing">
<value>105, 20</value>
</data>
<data name="allocationQuantumNumericUpDown.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="allocationQuantumNumericUpDown.TextAlign" type="System.Windows.Forms.HorizontalAlignment, System.Windows.Forms">
<value>Right</value>
</data>
<data name="&gt;&gt;allocationQuantumNumericUpDown.Name" xml:space="preserve">
<value>allocationQuantumNumericUpDown</value>
</data>
<data name="&gt;&gt;allocationQuantumNumericUpDown.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;allocationQuantumNumericUpDown.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;allocationQuantumNumericUpDown.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="initial_allocation_units.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="initial_allocation_units.Items" xml:space="preserve">
<value>GB</value>
</data>
<data name="initial_allocation_units.Items1" xml:space="preserve">
<value>MB</value>
</data>
<data name="initial_allocation_units.Location" type="System.Drawing.Point, System.Drawing">
<value>285, 108</value>
</data>
<data name="initial_allocation_units.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 23</value>
</data>
<data name="initial_allocation_units.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="&gt;&gt;initial_allocation_units.Name" xml:space="preserve">
<value>initial_allocation_units</value>
</data>
<data name="&gt;&gt;initial_allocation_units.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;initial_allocation_units.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;initial_allocation_units.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="incremental_allocation_units.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="incremental_allocation_units.Items" xml:space="preserve">
<value>GB</value>
</data>
<data name="incremental_allocation_units.Items1" xml:space="preserve">
<value>MB</value>
</data>
<data name="incremental_allocation_units.Location" type="System.Drawing.Point, System.Drawing">
<value>285, 137</value>
</data>
<data name="incremental_allocation_units.Size" type="System.Drawing.Size, System.Drawing">
<value>46, 23</value>
</data>
<data name="incremental_allocation_units.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;incremental_allocation_units.Name" xml:space="preserve">
<value>incremental_allocation_units</value>
</data>
<data name="&gt;&gt;incremental_allocation_units.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;incremental_allocation_units.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;incremental_allocation_units.ZOrder" xml:space="preserve">
<value>8</value>
<data name="&gt;&gt;thinProvisioningAllocationsControl.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
@ -415,7 +256,7 @@
<value>0, 0</value>
</data>
<data name="tableLayoutPanel1.RowCount" type="System.Int32, mscorlib">
<value>7</value>
<value>6</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>531, 408</value>
@ -436,7 +277,7 @@
<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="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="initialAllocationNumericUpDown" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="radioButtonThickProvisioning" Row="2" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="labelInitialAllocation" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="radioButtonThinProvisioning" Row="3" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="labelAllocationQuantum" Row="5" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="allocationQuantumNumericUpDown" Row="5" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="initial_allocation_units" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="incremental_allocation_units" Row="5" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,30,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,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="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="radioButtonThickProvisioning" Row="2" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="radioButtonThinProvisioning" Row="3" RowSpan="1" Column="0" ColumnSpan="5" /&gt;&lt;Control Name="thinProvisioningAllocationsControl" Row="4" RowSpan="1" Column="1" ColumnSpan="3" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,30,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>

View File

@ -52,7 +52,7 @@ namespace XenAdmin.Core
private const long XLVHD_MIN_ALLOCATION_QUANTUM_DIVISOR = 50000;
private const long XLVHD_DEF_ALLOCATION_QUANTUM_DIVISOR = 10000;
private const long XLVHD_MAX_ALLOCATION_QUANTUM_DIVISOR = 4000;
private const long XLVHD_MAX_ALLOCATION_QUANTUM_DIVISOR = 4000;
private const long XLVHD_MIN_ALLOCATION_QUANTUM = 16777216; // 16 MB
public const int DEFAULT_NAME_TRIM_LENGTH = 50;
@ -563,6 +563,14 @@ namespace XenAdmin.Core
{
this.min = min;
this.max = max;
if (defaultValue < min)
{
defaultValue = min;
}
else if (defaultValue > max)
{
defaultValue = max;
}
this.defaultValue = defaultValue;
if (defaultValue >= Util.BINARY_GIGA)
unit = Messages.VAL_GIGB;
@ -571,10 +579,8 @@ namespace XenAdmin.Core
}
public AllocationBounds(decimal min, decimal max, decimal defaultValue, string unit)
: this(min, max, defaultValue)
{
this.min = min;
this.max = max;
this.defaultValue = defaultValue;
this.unit = unit;
}