diff --git a/XenAdmin/Controls/ThinProvisioningParametersControl.Designer.cs b/XenAdmin/Controls/ThinProvisioningParametersControl.Designer.cs index 66d8a1c68..3542ac396 100644 --- a/XenAdmin/Controls/ThinProvisioningParametersControl.Designer.cs +++ b/XenAdmin/Controls/ThinProvisioningParametersControl.Designer.cs @@ -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; } diff --git a/XenAdmin/Controls/ThinProvisioningParametersControl.cs b/XenAdmin/Controls/ThinProvisioningParametersControl.cs index e695bcb33..25c51a0f7 100644 --- a/XenAdmin/Controls/ThinProvisioningParametersControl.cs +++ b/XenAdmin/Controls/ThinProvisioningParametersControl.cs @@ -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 SMConfig diff --git a/XenAdmin/Controls/ThinProvisioningParametersControl.resx b/XenAdmin/Controls/ThinProvisioningParametersControl.resx index 9a6e2ca88..54c2d78f1 100644 --- a/XenAdmin/Controls/ThinProvisioningParametersControl.resx +++ b/XenAdmin/Controls/ThinProvisioningParametersControl.resx @@ -145,7 +145,7 @@ 49, 23 - 24 + 6 incremental_allocation_units @@ -159,40 +159,40 @@ 0 - + Left - + True - + Segoe UI, 9pt - + NoControl - + 3, 7 - + 94, 15 - - 11 + + 1 - + &Initial allocation: - - label1 + + initial_allocation_label - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tableLayoutPanel1 - + 1 @@ -211,7 +211,7 @@ 105, 23 - 12 + 2 Right @@ -244,7 +244,7 @@ 49, 23 - 23 + 3 initial_allocation_units @@ -258,40 +258,40 @@ 3 - + Left - + True - + Segoe UI, 9pt - + NoControl - + 3, 36 - + 133, 15 - - 13 + + 4 - + In&cremental allocations: - - label2 + + incremental_allocation_label - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tableLayoutPanel1 - + 4 @@ -310,7 +310,7 @@ 105, 23 - 14 + 5 Right @@ -352,7 +352,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="incremental_allocation_units" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="initialAllocationNumericUpDown" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="initial_allocation_units" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="allocationQuantumNumericUpDown" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="incremental_allocation_units" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="initial_allocation_label" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="initialAllocationNumericUpDown" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="initial_allocation_units" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="incremental_allocation_label" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="allocationQuantumNumericUpDown" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0" /></TableLayoutSettings> True diff --git a/XenAdmin/Dialogs/NewDiskDialog.cs b/XenAdmin/Dialogs/NewDiskDialog.cs index ca9c5620a..d51a7faa6 100644 --- a/XenAdmin/Dialogs/NewDiskDialog.cs +++ b/XenAdmin/Dialogs/NewDiskDialog.cs @@ -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(); } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.Designer.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.Designer.cs index 2d8a366ec..0eff840c9 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.Designer.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.Designer.cs @@ -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; } } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.cs index ced65339f..e4909a65e 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.cs @@ -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(); - 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(); } } - 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 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; + } } } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.resx b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.resx index 578b75ed8..fcc2c203a 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.resx +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/StorageProvisioning.resx @@ -162,36 +162,6 @@ 0 - - Left - - - 174, 109 - - - 105, 0 - - - 105, 20 - - - 4 - - - Right - - - initialAllocationNumericUpDown - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - True @@ -220,40 +190,7 @@ tableLayoutPanel1 - 2 - - - Left - - - True - - - NoControl - - - 33, 113 - - - 135, 13 - - - 3 - - - Virtual disk &initial allocation: - - - labelInitialAllocation - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 3 + 1 True @@ -283,130 +220,34 @@ tableLayoutPanel1 - 4 + 2 - - Left - - + True - - NoControl + + GrowAndShrink - - 33, 142 + + 33, 108 - - 118, 13 + + 308, 64 - - 6 + + 3 - - In&cremental allocations: + + thinProvisioningAllocationsControl - - labelAllocationQuantum + + XenAdmin.Controls.ThinProvisioningParametersControl, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - - 5 - - - Left - - - 174, 138 - - - 105, 0 - - - 105, 20 - - - 7 - - - Right - - - allocationQuantumNumericUpDown - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 6 - - - Segoe UI, 9pt - - - GB - - - MB - - - 285, 108 - - - 46, 23 - - - 5 - - - initial_allocation_units - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 7 - - - Segoe UI, 9pt - - - GB - - - MB - - - 285, 137 - - - 46, 23 - - - 8 - - - incremental_allocation_units - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 8 + + 3 Fill @@ -415,7 +256,7 @@ 0, 0 - 7 + 6 531, 408 @@ -436,7 +277,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="initialAllocationNumericUpDown" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="radioButtonThickProvisioning" Row="2" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="labelInitialAllocation" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="radioButtonThinProvisioning" Row="3" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="labelAllocationQuantum" Row="5" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="allocationQuantumNumericUpDown" Row="5" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="initial_allocation_units" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="incremental_allocation_units" Row="5" RowSpan="1" Column="3" ColumnSpan="1" /></Controls><Columns Styles="Absolute,30,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="radioButtonThickProvisioning" Row="2" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="radioButtonThinProvisioning" Row="3" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="thinProvisioningAllocationsControl" Row="4" RowSpan="1" Column="1" ColumnSpan="3" /></Controls><Columns Styles="Absolute,30,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20,Absolute,20" /></TableLayoutSettings> True diff --git a/XenModel/Utils/Helpers.cs b/XenModel/Utils/Helpers.cs index e34665257..7d1a0219c 100755 --- a/XenModel/Utils/Helpers.cs +++ b/XenModel/Utils/Helpers.cs @@ -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; }