2013-06-24 13:41:48 +02:00
|
|
|
|
/* 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.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Wizards.NewPolicyWizard;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Dialogs.VMProtectionRecovery;
|
|
|
|
|
using XenCenterLib;
|
2016-02-15 05:35:26 +01:00
|
|
|
|
using XenAdmin.Alerts;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Dialogs.VMProtection_Recovery
|
|
|
|
|
{
|
2016-01-29 12:34:44 +01:00
|
|
|
|
public partial class VMProtectionPoliciesDialog: XenDialogBase
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
public readonly Pool Pool;
|
|
|
|
|
public VMProtectionPoliciesDialog(Pool pool)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
: base(pool.Connection)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
Pool = pool;
|
2016-02-15 05:35:26 +01:00
|
|
|
|
InitializeComponent();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
localServerTime1.Pool = pool;
|
|
|
|
|
chevronButton1.Text = Messages.SHOW_RUN_HISTORY;
|
|
|
|
|
chevronButton1.Image = Properties.Resources.PDChevronDown;
|
|
|
|
|
policyHistory1.Visible = false;
|
2016-02-15 05:35:26 +01:00
|
|
|
|
policyHistory1.pool = pool;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-02-15 05:35:26 +01:00
|
|
|
|
public VMProtectionPoliciesDialog() { }
|
|
|
|
|
|
|
|
|
|
protected virtual void chevronButton1_KeyDown(object sender, KeyEventArgs e) {}
|
|
|
|
|
protected virtual void chevronButton1_ButtonClick(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void buttonProperties_Click(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void button1_Click(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void buttonEnable_Click(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void VMProtectionPoliciesDialog_FormClosed(object sender, FormClosedEventArgs e) { }
|
|
|
|
|
protected virtual void dataGridView1_SelectionChanged(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void VMProtectionPoliciesDialog_Load(object sender, EventArgs e) { }
|
|
|
|
|
protected virtual void buttonCancel_Click(object sender, System.EventArgs e) { }
|
|
|
|
|
protected virtual void buttonNew_Click(object sender, System.EventArgs e) { }
|
|
|
|
|
protected virtual void buttonDelete_Click(object sender, EventArgs e) { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class PolicyRow : DataGridViewRow
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
private DataGridViewTextBoxCell _name = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _numVMs = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _nextRunTime = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _status = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _nextArchiveRuntime = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextAndImageCell _lastResult = new DataGridViewTextAndImageCell();
|
2016-02-15 05:35:26 +01:00
|
|
|
|
public readonly IVMPolicy _Policy;
|
|
|
|
|
public PolicyRow(IVMPolicy policy)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
Cells.Add(_name);
|
|
|
|
|
Cells.Add(_status);
|
|
|
|
|
Cells.Add(_numVMs);
|
|
|
|
|
Cells.Add(_nextRunTime);
|
2016-01-29 12:34:44 +01:00
|
|
|
|
Cells.Add(_nextArchiveRuntime);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
Cells.Add(_lastResult);
|
2016-02-15 05:35:26 +01:00
|
|
|
|
_Policy = policy;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
RefreshRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DateTime? GetVMPPDateTime(Func<DateTime> getDateTimeFunc)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return getDateTimeFunc();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.Error("An error occurred while obtaining VMPP date time: ", e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshRow()
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
_name.Value = _Policy.Name;
|
|
|
|
|
_numVMs.Value = _Policy.VMs.FindAll(vm => _Policy.Connection.Resolve(vm).is_a_real_vm).Count;
|
2016-02-16 10:49:39 +01:00
|
|
|
|
_status.Value = _Policy.is_enabled ? Messages.ENABLED : Messages.DISABLED;
|
|
|
|
|
if (_Policy.is_running)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_status.Value = Messages.RUNNING_SNAPSHOTS;
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (this._Policy.hasArchive)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-16 10:49:39 +01:00
|
|
|
|
if (_Policy.is_archiving)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
_status.Value = Messages.RUNNING_ARCHIVE;
|
|
|
|
|
}
|
|
|
|
|
_lastResult.Value = _Policy.LastResult;
|
|
|
|
|
if (_Policy.LastResult == Messages.FAILED)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_lastResult.Image = Properties.Resources._075_WarningRound_h32bit_16;
|
2016-02-15 05:35:26 +01:00
|
|
|
|
else if (_Policy.LastResult == Messages.NOT_YET_RUN)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_lastResult.Image = null;
|
|
|
|
|
else
|
|
|
|
|
_lastResult.Image = Properties.Resources._075_TickRound_h32bit_16;
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
DateTime? nextRunTime = GetVMPPDateTime(() => _Policy._GetNextRunTime());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_nextRunTime.Value = nextRunTime.HasValue
|
|
|
|
|
? HelpersGUI.DateTimeToString(nextRunTime.Value, Messages.DATEFORMAT_DMY_HM,
|
|
|
|
|
true)
|
|
|
|
|
: Messages.VM_PROTECTION_POLICY_HOST_NOT_LIVE;
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (this._Policy.hasArchive)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
|
|
|
|
DateTime? nextArchiveRuntime = GetVMPPDateTime(() => _Policy._GetNextArchiveRunTime());
|
|
|
|
|
_nextArchiveRuntime.Value = nextArchiveRuntime.HasValue
|
|
|
|
|
? nextArchiveRuntime == DateTime.MinValue
|
|
|
|
|
? Messages.NEVER
|
|
|
|
|
: HelpersGUI.DateTimeToString(nextArchiveRuntime.Value,
|
|
|
|
|
Messages.DATEFORMAT_DMY_HM, true)
|
|
|
|
|
: Messages.VM_PROTECTION_POLICY_HOST_NOT_LIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Dialogs.VMPolicies
|
|
|
|
|
{
|
|
|
|
|
public class VMPoliciesDialogSpecific<T> : XenAdmin.Dialogs.VMProtection_Recovery.VMProtectionPoliciesDialog where T : XenObject<T>
|
|
|
|
|
{
|
|
|
|
|
public VMPoliciesDialogSpecific() { }
|
|
|
|
|
public VMPoliciesDialogSpecific(Pool pool)
|
|
|
|
|
: base(pool)
|
|
|
|
|
{
|
|
|
|
|
RefreshPoolTitle(pool);
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (VMGroup<T>.isVMPolicyVMPP)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
SetupDeprecationBanner();
|
2016-02-17 09:02:24 +01:00
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
|
|
|
|
private void RefreshPoolTitle(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
int protectedVMs = 0;
|
|
|
|
|
int realVMs = 0;
|
|
|
|
|
|
2016-02-17 09:02:24 +01:00
|
|
|
|
foreach (var vm in pool.Connection.Cache.VMs)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (vm.is_a_real_vm && vm.Show(Properties.Settings.Default.ShowHiddenVMs))
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
realVMs++;
|
|
|
|
|
if (vm.Connection.Resolve(VMGroup<T>.VmToGroup(vm)) != null)
|
|
|
|
|
protectedVMs++;
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-17 09:02:24 +01:00
|
|
|
|
this.Text = VMGroup<T>.VMPolicyDialogTitle;
|
|
|
|
|
label2.Text = VMGroup<T>.VMPolicyDialogText;
|
|
|
|
|
labelPolicyTitle.Text = string.Format(Helpers.IsPool(pool.Connection)
|
|
|
|
|
? VMGroup<T>.VMPolicyDialogSchedulesInPool
|
|
|
|
|
: VMGroup<T>.VMPolicyDialogSchedulesInServer,
|
|
|
|
|
pool.Name.Ellipsise(45), protectedVMs, realVMs);
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VMPPCollectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadPolicies();
|
|
|
|
|
}
|
2016-01-29 12:34:44 +01:00
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
private void LoadPolicies()
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.SuspendLayout();
|
|
|
|
|
var selectedPolicy = currentSelected;
|
|
|
|
|
dataGridView1.Rows.Clear();
|
2016-02-17 09:02:24 +01:00
|
|
|
|
|
|
|
|
|
foreach (var policy in VMGroup<T>.VMPolicies(Pool.Connection.Cache))
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (!VMGroup<T>.isVMPolicyVMPP)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
/*for VMSS: Populate the alerts from Messages by filtering out the alerts for this schedule
|
|
|
|
|
This is not required in VMPP as the VMPP record itself has the recentAlerts */
|
2016-02-15 05:35:26 +01:00
|
|
|
|
foreach (var message in Pool.Connection.Cache.Messages)
|
|
|
|
|
{
|
|
|
|
|
if (message.cls == cls.VMSS && message.obj_uuid == policy.uuid)
|
|
|
|
|
{
|
2016-02-16 10:49:39 +01:00
|
|
|
|
if (message.Type == XenAPI.Message.MessageType.VMSS_SNAPSHOT_SUCCEEDED)
|
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
policy.PolicyAlerts.Add(new PolicyAlert(Pool.Connection, message.body));
|
2016-02-16 10:49:39 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
policy.PolicyAlerts.Add(new PolicyAlert(message.name, message.timestamp));
|
2016-02-16 10:49:39 +01:00
|
|
|
|
}
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-17 09:02:24 +01:00
|
|
|
|
|
|
|
|
|
if (dataGridView1.ColumnCount > 0)
|
|
|
|
|
dataGridView1.Rows.Add(new PolicyRow(policy));
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
|
|
|
|
RefreshButtons();
|
|
|
|
|
if (selectedPolicy != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (PolicyRow row in dataGridView1.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row._Policy.uuid == selectedPolicy.uuid)
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.ClearSelection();
|
|
|
|
|
row.Selected = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-02-15 05:35:26 +01:00
|
|
|
|
RefreshPoolTitle(Pool);
|
|
|
|
|
dataGridView1.ResumeLayout();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void buttonNew_Click(object sender, System.EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
new NewPolicyWizardSpecific<T>(Pool).Show(this);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void buttonCancel_Click(object sender, System.EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void VMProtectionPoliciesDialog_Load(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
if (!VMGroup<T>.isVMPolicyVMPP)
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
|
|
|
|
this.dataGridView1.Columns["ColumnNextArchive"].Visible = false;
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
LoadPolicies();
|
|
|
|
|
localServerTime1.GetServerTime();
|
2016-02-15 05:35:26 +01:00
|
|
|
|
Pool.Connection.Cache.RegisterBatchCollectionChanged<T>(VMPPCollectionChanged);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void buttonDelete_Click(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
var selectedPolicies = new List<IVMPolicy>();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
int numberOfProtectedVMs = 0;
|
|
|
|
|
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
var policy = (((PolicyRow)row)._Policy);
|
2016-02-17 09:02:24 +01:00
|
|
|
|
selectedPolicies.Add(policy);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
numberOfProtectedVMs += policy.VMs.Count;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
string text = "";
|
|
|
|
|
if (selectedPolicies.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
text = String.Format(numberOfProtectedVMs == 0 ? Messages.CONFIRM_DELETE_POLICY_0 : Messages.CONFIRM_DELETE_POLICY, selectedPolicies[0].Name, numberOfProtectedVMs);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text = string.Format(numberOfProtectedVMs == 0 ? Messages.CONFIRM_DELETE_POLICIES_0 : Messages.CONFIRM_DELETE_POLICIES, numberOfProtectedVMs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new ThreeButtonDialog(
|
|
|
|
|
new ThreeButtonDialog.Details(SystemIcons.Warning, text, Messages.DELETE_VM_PROTECTION_TITLE),
|
|
|
|
|
ThreeButtonDialog.ButtonYes,
|
|
|
|
|
ThreeButtonDialog.ButtonNo).ShowDialog(this) == DialogResult.Yes)
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
new DestroyPolicyAction<T>(Pool.Connection, selectedPolicies).RunAsync();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
private IVMPolicy currentSelected = null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
RefreshButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshButtons()
|
|
|
|
|
{
|
|
|
|
|
if (dataGridView1.SelectedRows.Count == 1)
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
currentSelected = ((PolicyRow)dataGridView1.SelectedRows[0])._Policy;
|
2016-02-16 10:49:39 +01:00
|
|
|
|
buttonEnable.Text = currentSelected.is_enabled? Messages.DISABLE : Messages.ENABLE;
|
|
|
|
|
buttonEnable.Enabled = currentSelected.VMs.Count == 0 && !currentSelected.is_enabled? false : true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
buttonProperties.Enabled = true;
|
2016-02-16 10:49:39 +01:00
|
|
|
|
buttonRunNow.Enabled = currentSelected.is_enabled && !currentSelected.is_archiving && !currentSelected.is_running;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentSelected = null;
|
|
|
|
|
buttonProperties.Enabled = buttonEnable.Enabled = buttonRunNow.Enabled = false;
|
|
|
|
|
policyHistory1.Clear();
|
|
|
|
|
}
|
2016-02-16 10:49:39 +01:00
|
|
|
|
|
|
|
|
|
policyHistory1.RefreshTab(currentSelected);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
buttonDelete.Enabled = (dataGridView1.SelectedRows.Count != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void VMProtectionPoliciesDialog_FormClosed(object sender, FormClosedEventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
Pool.Connection.Cache.DeregisterBatchCollectionChanged<T>(VMPPCollectionChanged);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void buttonEnable_Click(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (currentSelected != null)
|
|
|
|
|
{
|
2016-02-17 09:02:24 +01:00
|
|
|
|
var action = new ChangePolicyEnabledAction<T>(currentSelected);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
action.RunAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-15 05:35:26 +01:00
|
|
|
|
|
|
|
|
|
protected override void button1_Click(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (dataGridView1.SelectedRows.Count == 1)
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
var policy = ((PolicyRow)dataGridView1.SelectedRows[0])._Policy;
|
2016-02-17 09:02:24 +01:00
|
|
|
|
var action = new RunPolicyNowAction<T>(policy);
|
2013-08-05 15:28:21 +02:00
|
|
|
|
action.Completed += action_Completed;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
buttonRunNow.Enabled = false;
|
|
|
|
|
action.RunAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 15:28:21 +02:00
|
|
|
|
void action_Completed(ActionBase sender)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-08-05 15:28:21 +02:00
|
|
|
|
Program.Invoke(Program.MainWindow, RefreshButtons);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetupDeprecationBanner()
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
if (deprecationBanner != null && !Helpers.ClearwaterOrGreater(Pool.Connection))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
deprecationBanner.AppliesToVersion = Messages.XENSERVER_6_2;
|
|
|
|
|
deprecationBanner.BannerType = DeprecationBanner.Type.Removal;
|
|
|
|
|
deprecationBanner.FeatureName = Messages.VMPP;
|
2016-01-28 22:43:15 +01:00
|
|
|
|
deprecationBanner.LinkUri = HiddenFeatures.LinkLabelHidden ? null : new Uri(InvisibleMessages.VMPR_DEPRECATION_URL);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
deprecationBanner.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void buttonProperties_Click(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-02-16 10:49:39 +01:00
|
|
|
|
using (PropertiesDialog propertiesDialog = new PropertiesDialog((T)currentSelected))
|
2016-02-15 05:35:26 +01:00
|
|
|
|
{
|
2016-02-16 10:49:39 +01:00
|
|
|
|
propertiesDialog.ShowDialog(this);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void chevronButton1_ButtonClick(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (chevronButton1.Text == Messages.HIDE_RUN_HISTORY)
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
chevronButton1.Text = Messages.SHOW_RUN_HISTORY;
|
|
|
|
|
chevronButton1.Image = Properties.Resources.PDChevronDown;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
policyHistory1.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-02-15 05:35:26 +01:00
|
|
|
|
chevronButton1.Text = Messages.HIDE_RUN_HISTORY;
|
|
|
|
|
chevronButton1.Image = Properties.Resources.PDChevronUp;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
policyHistory1.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
protected override void chevronButton1_KeyDown(object sender, KeyEventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space)
|
|
|
|
|
chevronButton1_ButtonClick(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 05:35:26 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|