2023-01-24 15:29:31 +01:00
|
|
|
|
/* Copyright (c) Cloud Software Group, Inc.
|
2013-06-24 13:41:48 +02:00
|
|
|
|
*
|
|
|
|
|
* 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.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
|
using XenAdmin.Wlb;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.SettingsPanels
|
|
|
|
|
{
|
|
|
|
|
public partial class WlbMetricWeightingPage : UserControl, IEditPage
|
|
|
|
|
{
|
|
|
|
|
private const int TRACKBAR_INTERVAL = 10;
|
|
|
|
|
|
|
|
|
|
private WlbPoolConfiguration _poolConfiguration;
|
|
|
|
|
private bool _loading = false;
|
|
|
|
|
private bool _hasChanged = false;
|
2016-01-04 12:04:29 +01:00
|
|
|
|
private XenAdmin.Network.IXenConnection _connection;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public WlbMetricWeightingPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
Text = Messages.WLB_METRIC_WEIGHTING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WlbPoolConfiguration PoolConfiguration
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (null != value)
|
|
|
|
|
{
|
|
|
|
|
_poolConfiguration = value;
|
|
|
|
|
InitializeControls();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-04 12:04:29 +01:00
|
|
|
|
public XenAdmin.Network.IXenConnection Connection
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (null != value)
|
|
|
|
|
{
|
|
|
|
|
_connection = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void InitializeControls()
|
|
|
|
|
{
|
|
|
|
|
_loading = true;
|
2023-05-10 15:50:52 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
trackbarCPUPriority.Value = GetSafeTrackbarValue(trackbarCPUPriority, _poolConfiguration.VmCpuUtilizationWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
trackbarMemoryPriority.Value = GetSafeTrackbarValue(trackbarMemoryPriority, _poolConfiguration.VmMemoryWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
trackbarNetReadPriority.Value = GetSafeTrackbarValue(trackbarNetReadPriority, _poolConfiguration.VmNetworkReadWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
trackbarNetWritePriority.Value = GetSafeTrackbarValue(trackbarNetWritePriority, _poolConfiguration.VmNetworkWriteWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
trackbarDiskReadPriority.Value = GetSafeTrackbarValue(trackbarDiskReadPriority, _poolConfiguration.VmDiskReadWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
trackbarDiskWritePriority.Value = GetSafeTrackbarValue(trackbarDiskWritePriority, _poolConfiguration.VmDiskWriteWeightHigh / TRACKBAR_INTERVAL);
|
|
|
|
|
}
|
|
|
|
|
finally
|
2016-01-04 12:04:29 +01:00
|
|
|
|
{
|
2023-05-10 15:50:52 +02:00
|
|
|
|
_loading = false;
|
2016-01-04 12:04:29 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void trackbarValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!_loading)
|
|
|
|
|
{
|
|
|
|
|
_hasChanged = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetSafeTrackbarValue(TrackBar thisControl, int value)
|
|
|
|
|
{
|
|
|
|
|
if (value < thisControl.Minimum)
|
|
|
|
|
{
|
|
|
|
|
value = thisControl.Minimum;
|
|
|
|
|
}
|
|
|
|
|
if (value > thisControl.Maximum)
|
|
|
|
|
{
|
|
|
|
|
value = thisControl.Maximum;
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region IEditPage Members
|
|
|
|
|
|
|
|
|
|
public AsyncAction SaveSettings()
|
|
|
|
|
{
|
|
|
|
|
_poolConfiguration.VmCpuUtilizationWeightHigh = trackbarCPUPriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
_poolConfiguration.VmMemoryWeightHigh = trackbarMemoryPriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
_poolConfiguration.VmNetworkReadWeightHigh = trackbarNetReadPriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
_poolConfiguration.VmNetworkWriteWeightHigh = trackbarNetWritePriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
_poolConfiguration.VmDiskReadWeightHigh = trackbarDiskReadPriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
_poolConfiguration.VmDiskWriteWeightHigh = trackbarDiskWritePriority.Value * TRACKBAR_INTERVAL;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetXenObjects(IXenObject orig, IXenObject clone)
|
|
|
|
|
{
|
2019-09-24 14:59:49 +02:00
|
|
|
|
throw new NotImplementedException();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-24 14:59:49 +02:00
|
|
|
|
public bool ValidToSave => throw new NotImplementedException();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public void ShowLocalValidationMessages()
|
|
|
|
|
{
|
2019-09-24 14:59:49 +02:00
|
|
|
|
throw new NotImplementedException();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 11:34:46 +02:00
|
|
|
|
public void HideLocalValidationMessages()
|
|
|
|
|
{ }
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public void Cleanup()
|
|
|
|
|
{
|
2019-09-24 14:59:49 +02:00
|
|
|
|
throw new NotImplementedException();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-24 14:59:49 +02:00
|
|
|
|
public bool HasChanged => _hasChanged;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2018-03-20 18:02:45 +01:00
|
|
|
|
#region IVerticalTab Members
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-09-24 14:59:49 +02:00
|
|
|
|
public string SubText => Messages.WLB_METRIC_WEIGHTING_SUBTEXT;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2020-06-18 02:20:29 +02:00
|
|
|
|
public Image Image => Images.StaticImages._000_weighting_h32bit_16;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|