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.Controls;
|
|
|
|
|
using XenAdmin.Controls.DataGridViewEx;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
|
using XenAdmin.Network;
|
|
|
|
|
using XenAdmin.Properties;
|
|
|
|
|
using XenAPI;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
using XenAdmin.Alerts;
|
2016-07-19 10:12:30 +02:00
|
|
|
|
using System.Linq;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class PatchingWizard_SelectServers : XenTabPage
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
private const int PLUS_MINUS_COL = 0;
|
|
|
|
|
private const int POOL_CHECKBOX_COL = 1;
|
|
|
|
|
private const int POOL_ICON_HOST_CHECKBOX_COL = 2;
|
|
|
|
|
|
|
|
|
|
private const int UNCHECKED = 0;
|
|
|
|
|
private const int CHECKED = 1;
|
|
|
|
|
private const int INDETERMINATE = 2;
|
|
|
|
|
|
2015-07-20 15:28:44 +02:00
|
|
|
|
public XenServerPatchAlert SelectedUpdateAlert { private get; set; }
|
|
|
|
|
|
2015-07-20 16:27:41 +02:00
|
|
|
|
public XenServerPatchAlert FileFromDiskAlert { private get; set; }
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_SelectServers()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
dataGridViewHosts.CheckBoxClicked += dataGridViewHosts_CheckBoxClicked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_SELECTSERVERPAGE_TEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_SELECTSERVERPAGE_TITLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "SelectServers"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PageLoaded(PageLoadedDirection direction)
|
|
|
|
|
{
|
|
|
|
|
base.PageLoaded(direction);
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-07-19 10:12:30 +02:00
|
|
|
|
label1.Text = IsInAutomaticMode ? Messages.PATCHINGWIZARD_SELECTSERVERPAGGE_RUBRIC_AUTOMATIC_MODE : Messages.PATCHINGWIZARD_SELECTSERVERPAGGE_RUBRIC_DEFAULT;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
// catch selected servers, in order to restore selection after the dataGrid is reloaded
|
|
|
|
|
List<Host> selectedServers = SelectedServers;
|
|
|
|
|
|
|
|
|
|
dataGridViewHosts.Rows.Clear();
|
2016-07-01 18:41:49 +02:00
|
|
|
|
|
|
|
|
|
if (IsInAutomaticMode)
|
|
|
|
|
{
|
|
|
|
|
//hides expand column
|
|
|
|
|
dataGridViewHosts.Columns[0].Visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dataGridViewHosts.Columns[0].Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
List<IXenConnection> xenConnections = ConnectionsManager.XenConnectionsCopy;
|
|
|
|
|
xenConnections.Sort();
|
|
|
|
|
foreach (IXenConnection xenConnection in xenConnections)
|
|
|
|
|
{
|
2016-06-17 15:15:59 +02:00
|
|
|
|
if (IsInAutomaticMode)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-06-17 15:15:59 +02:00
|
|
|
|
if (!xenConnection.IsConnected)
|
|
|
|
|
continue;
|
|
|
|
|
|
2016-07-01 18:41:49 +02:00
|
|
|
|
var pool = Helpers.GetPoolOfOne(xenConnection);
|
|
|
|
|
Host master = pool.Connection.Resolve(pool.master);
|
2016-07-05 11:42:49 +02:00
|
|
|
|
|
|
|
|
|
int index = -1;
|
|
|
|
|
if (Helpers.GetPool(xenConnection) != null) //pools
|
|
|
|
|
{
|
2016-07-05 12:00:40 +02:00
|
|
|
|
index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(pool));
|
2016-07-05 11:42:49 +02:00
|
|
|
|
}
|
|
|
|
|
else //standalone hosts
|
|
|
|
|
{
|
|
|
|
|
index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(master, false));
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-01 18:41:49 +02:00
|
|
|
|
EnabledRow(master, SelectedUpdateType, index);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-06-17 15:15:59 +02:00
|
|
|
|
Pool pool = Helpers.GetPool(xenConnection);
|
|
|
|
|
bool hasPool = pool != null;
|
|
|
|
|
if (hasPool)
|
|
|
|
|
{
|
|
|
|
|
int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(pool));
|
|
|
|
|
Host master = pool.Connection.Resolve(pool.master);
|
|
|
|
|
EnabledRow(master, SelectedUpdateType, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Host[] hosts = xenConnection.Cache.Hosts;
|
|
|
|
|
Array.Sort(hosts);
|
|
|
|
|
foreach (Host host in hosts)
|
|
|
|
|
{
|
|
|
|
|
int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(host, hasPool));
|
|
|
|
|
EnabledRow(host, SelectedUpdateType, index);
|
|
|
|
|
}
|
2016-03-31 16:40:23 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// restore server selection
|
|
|
|
|
SelectServers(selectedServers);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.Error(e, e);
|
|
|
|
|
throw;//better throw an exception rather than closing the wizard suddenly and silently
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
|
|
|
|
public bool IsInAutomaticMode { set; get; }
|
|
|
|
|
|
2016-08-09 17:53:02 +02:00
|
|
|
|
public List<XenServerVersion> AutoDownloadedXenServerVersions { private get; set; }
|
2016-08-18 13:22:40 +02:00
|
|
|
|
|
2016-08-19 18:27:24 +02:00
|
|
|
|
private bool PoolForbidsAutomaticUpdates(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
var poolForbidsAutomaticKey = "XenCenter.CustomFields.hci-forbid-update-auto-restart";
|
|
|
|
|
var poolOtherConfig = Helpers.GetOtherConfig(pool);
|
|
|
|
|
if (poolOtherConfig.ContainsKey(poolForbidsAutomaticKey) &&
|
|
|
|
|
poolOtherConfig[poolForbidsAutomaticKey].ToLowerInvariant().Equals(bool.TrueString.ToLowerInvariant()))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void EnabledRow(Host host, UpdateType type, int index)
|
|
|
|
|
{
|
|
|
|
|
var row = (PatchingHostsDataGridViewRow)dataGridViewHosts.Rows[index];
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
|
|
|
|
if (IsInAutomaticMode)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-08-11 12:14:32 +02:00
|
|
|
|
var pool = Helpers.GetPool(host.Connection);
|
|
|
|
|
if (pool != null && !pool.IsPoolFullyUpgraded) //partially upgraded pool is not supported
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 19:30:54 +02:00
|
|
|
|
//check updgrade sequences
|
2016-08-09 17:53:02 +02:00
|
|
|
|
Updates.UpgradeSequence us = Updates.GetUpgradeSequence(host.Connection, AutoDownloadedXenServerVersions);
|
2016-08-08 19:30:54 +02:00
|
|
|
|
|
|
|
|
|
if (us == null) //version not supported
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_HOST_VERSION;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-04 11:27:10 +02:00
|
|
|
|
//unlicensed servers are not enabled
|
|
|
|
|
if (Host.RestrictBatchHotfixApply(host))
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_BATCH_UPDATING;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
2016-07-19 10:12:30 +02:00
|
|
|
|
//if there is a host missing from the upgrade sequence
|
|
|
|
|
if (host.Connection.Cache.Hosts.Any(h => !us.Keys.Contains(h)))
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2016-07-19 10:12:30 +02:00
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;
|
|
|
|
|
|
2016-08-09 17:53:02 +02:00
|
|
|
|
return;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
2016-07-19 10:12:30 +02:00
|
|
|
|
|
|
|
|
|
//if all hosts are up-to-date
|
|
|
|
|
if (us.AllHostsUpToDate)
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
2016-07-19 10:12:30 +02:00
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
|
|
|
|
|
|
|
|
|
|
return;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
2016-03-16 13:59:20 +01:00
|
|
|
|
|
2016-08-26 15:24:24 +02:00
|
|
|
|
// if pool forbids automatic updates with other_config key (Neptune project)
|
|
|
|
|
// TODO: can poolOfOne have these keys?
|
|
|
|
|
if (pool != null && PoolForbidsAutomaticUpdates(pool))
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = "This pool forbids automatic updates. (TODO: Neptune message)";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:59:20 +01:00
|
|
|
|
return;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
2016-03-16 13:59:20 +01:00
|
|
|
|
|
|
|
|
|
List<Host> selectedHosts = null;
|
|
|
|
|
if (SelectedUpdateAlert != null)
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2016-03-16 13:59:20 +01:00
|
|
|
|
selectedHosts = SelectedUpdateAlert.DistinctHosts;
|
|
|
|
|
}
|
2016-06-20 15:10:00 +02:00
|
|
|
|
else if (FileFromDiskAlert != null)
|
2016-03-16 13:59:20 +01:00
|
|
|
|
{
|
|
|
|
|
selectedHosts = FileFromDiskAlert.DistinctHosts;
|
|
|
|
|
}
|
2016-06-20 15:10:00 +02:00
|
|
|
|
|
2016-08-18 13:22:40 +02:00
|
|
|
|
Pool poolOfOne = Helpers.GetPoolOfOne(host.Connection);
|
|
|
|
|
if (poolOfOne != null && poolOfOne.IsPatchingForbidden)
|
2016-06-20 15:10:00 +02:00
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCHING_FORBIDDEN;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:59:20 +01:00
|
|
|
|
if (type != UpdateType.NewSuppPack && !host.CanApplyHotfixes)
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
2016-03-16 13:59:20 +01:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case UpdateType.NewRetail:
|
|
|
|
|
case UpdateType.Existing:
|
|
|
|
|
disableNotApplicableHosts(row, selectedHosts, host);
|
|
|
|
|
break;
|
|
|
|
|
case UpdateType.NewSuppPack:
|
|
|
|
|
if (!host.CanInstallSuppPack)
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_SUPP_PACKS;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 15:28:44 +02:00
|
|
|
|
private void disableNotApplicableHosts(PatchingHostsDataGridViewRow row, List<Host> selectedHosts, Host host)
|
|
|
|
|
{
|
|
|
|
|
if (selectedHosts != null && !selectedHosts.Contains(host))
|
|
|
|
|
{
|
2015-07-21 12:03:34 +02:00
|
|
|
|
string alertUuid = null;
|
2015-07-20 16:27:41 +02:00
|
|
|
|
if (SelectedUpdateAlert != null)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
2015-07-21 12:03:34 +02:00
|
|
|
|
alertUuid = SelectedUpdateAlert.uuid;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
}
|
2015-07-20 16:27:41 +02:00
|
|
|
|
else if (FileFromDiskAlert != null)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
2015-07-21 12:03:34 +02:00
|
|
|
|
alertUuid = FileFromDiskAlert.uuid;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-21 12:03:34 +02:00
|
|
|
|
if (alertUuid != null)
|
2015-07-20 16:27:41 +02:00
|
|
|
|
{
|
2015-07-21 12:03:34 +02:00
|
|
|
|
if (isPatchApplied(alertUuid, host))
|
2015-07-20 16:27:41 +02:00
|
|
|
|
{
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCH_ALREADY_APPLIED;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCH_NOT_APPLICABLE;
|
|
|
|
|
}
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
}
|
2015-07-20 15:28:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-21 12:03:34 +02:00
|
|
|
|
private bool isPatchApplied(string uuid, Host host)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
|
|
|
|
List<Pool_patch> hostPatches = host.AppliedPatches();
|
|
|
|
|
foreach (Pool_patch patch in hostPatches)
|
|
|
|
|
{
|
2016-02-08 11:14:05 +01:00
|
|
|
|
if (string.Equals(patch.uuid, uuid, StringComparison.OrdinalIgnoreCase))
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
|
|
|
|
{
|
|
|
|
|
if (!AllSelectedHostsConnected())
|
|
|
|
|
{
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
row.UpdateIcon();
|
|
|
|
|
dataGridViewHosts.Invalidate();
|
|
|
|
|
cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Upload the patches to the masters if it is necessary
|
|
|
|
|
List<Host> masters = SelectedMasters;
|
|
|
|
|
|
|
|
|
|
//Do RBAC check
|
|
|
|
|
foreach (Host master in masters)
|
|
|
|
|
{
|
2015-10-26 17:01:55 +01:00
|
|
|
|
if (!(Role.CanPerform(new RbacMethodList("pool_patch.apply"), master.Connection)))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
string nameLabel = master.Name;
|
|
|
|
|
Pool pool = Helpers.GetPoolOfOne(master.Connection);
|
|
|
|
|
if (pool != null)
|
|
|
|
|
nameLabel = pool.Name;
|
|
|
|
|
|
2016-06-20 11:49:12 +02:00
|
|
|
|
using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPDATES_WIZARD, master.Connection.Username, nameLabel), Messages.UPDATES_WIZARD)))
|
|
|
|
|
{
|
|
|
|
|
dlg.ShowDialog(this);
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
cancel = true;
|
|
|
|
|
base.PageLeave(direction, ref cancel);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
base.PageLeave(direction, ref cancel);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.Debug(e);
|
|
|
|
|
throw;//better throw an exception rather than closing the wizard suddenly and silently
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool AllSelectedHostsConnected()
|
|
|
|
|
{
|
|
|
|
|
var disconnectedServerNames = new List<string>();
|
|
|
|
|
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if ((int)row.Cells[POOL_CHECKBOX_COL].Value > UNCHECKED && ((row.Tag is Host && !row.HasPool) || row.Tag is Pool))
|
|
|
|
|
{
|
|
|
|
|
IXenConnection connection = ((IXenObject) row.Tag).Connection;
|
|
|
|
|
if (connection == null || !connection.IsConnected)
|
|
|
|
|
disconnectedServerNames.Add(((IXenObject) row.Tag).Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (disconnectedServerNames.Count > 0)
|
|
|
|
|
{
|
2016-06-20 11:49:12 +02:00
|
|
|
|
using (var dlg = new ThreeButtonDialog(
|
2013-06-24 13:41:48 +02:00
|
|
|
|
new ThreeButtonDialog.Details(SystemIcons.Warning,
|
|
|
|
|
string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER, Helpers.StringifyList(disconnectedServerNames)),
|
2016-06-20 11:49:12 +02:00
|
|
|
|
Messages.UPDATES_WIZARD)))
|
|
|
|
|
{
|
|
|
|
|
dlg.ShowDialog(this);
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
|
|
|
|
bool clearAllButtonEnabled = false;
|
|
|
|
|
bool selectAllButtonEnabled = false;
|
|
|
|
|
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if ((row.Tag is Host && !row.HasPool) || row.Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
int val = (int)row.Cells[POOL_CHECKBOX_COL].Value;
|
|
|
|
|
if (val > UNCHECKED)
|
|
|
|
|
{
|
|
|
|
|
clearAllButtonEnabled = true;
|
|
|
|
|
if (val == INDETERMINATE)
|
|
|
|
|
selectAllButtonEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
selectAllButtonEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buttonClearAll.Enabled = clearAllButtonEnabled;
|
|
|
|
|
buttonSelectAll.Enabled = selectAllButtonEnabled;
|
|
|
|
|
return clearAllButtonEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
2015-01-09 13:54:12 +01:00
|
|
|
|
public Pool_patch Patch { private get; set; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public List<Host> SelectedMasters
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
List<Host> result = new List<Host>();
|
|
|
|
|
foreach (Host selectedServer in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
Host master = Helpers.GetMaster(selectedServer.Connection);
|
|
|
|
|
if (!result.Contains(master))
|
|
|
|
|
result.Add(master);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Host> SelectedServers
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-08-08 19:05:42 +02:00
|
|
|
|
if (IsInAutomaticMode)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-08-08 19:05:42 +02:00
|
|
|
|
return SelectedPools.SelectMany(p => p.Connection.Cache.Hosts).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<Host> hosts = new List<Host>();
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-08-08 19:05:42 +02:00
|
|
|
|
if (row.Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
if ((row.HasPool && ((int)row.Cells[POOL_ICON_HOST_CHECKBOX_COL].Value) == CHECKED) || (!row.HasPool && ((int)row.Cells[POOL_CHECKBOX_COL].Value) == CHECKED))
|
|
|
|
|
hosts.Add((Host)row.Tag);
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-08-08 19:05:42 +02:00
|
|
|
|
return hosts;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Pool> SelectedPools
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
List<Pool> pools = new List<Pool>();
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row.Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
if (((int)row.Cells[POOL_CHECKBOX_COL].Value) != UNCHECKED)
|
|
|
|
|
pools.Add((Pool)row.Tag);
|
|
|
|
|
}
|
|
|
|
|
else if (row.Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
if (((int)row.Cells[POOL_CHECKBOX_COL].Value) != UNCHECKED)
|
|
|
|
|
{
|
|
|
|
|
Host host = (Host)row.Tag;
|
|
|
|
|
Pool pool = Helpers.GetPoolOfOne(host.Connection);
|
|
|
|
|
if (pool != null)
|
|
|
|
|
pools.Add(pool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pools;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UpdateType SelectedUpdateType { private get; set; }
|
|
|
|
|
|
|
|
|
|
public void SelectServers(List<Host> selectedServers)
|
|
|
|
|
{
|
|
|
|
|
if (selectedServers.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row.Enabled && row.Tag != null && row.Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
var host = (Host) row.Tag;
|
|
|
|
|
if (selectedServers.Contains(host))
|
|
|
|
|
dataGridViewHosts.CheckBoxChange(row.Index,
|
|
|
|
|
Helpers.GetPool(host.Connection) != null
|
|
|
|
|
? POOL_ICON_HOST_CHECKBOX_COL
|
|
|
|
|
: POOL_CHECKBOX_COL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 13:52:14 +02:00
|
|
|
|
public void DisableUnselectedServers()
|
|
|
|
|
{
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row.Enabled && row.CheckValue == UNCHECKED)
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void buttonSelectAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckAllCheckBoxes(CHECKED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckAllCheckBoxes(int value)
|
|
|
|
|
{
|
|
|
|
|
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row.Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
if (row.HasPool && (int)row.Cells[POOL_ICON_HOST_CHECKBOX_COL].Value != value)
|
|
|
|
|
dataGridViewHosts.CheckBoxChange(row.Index, POOL_ICON_HOST_CHECKBOX_COL);
|
|
|
|
|
else if ((int)row.Cells[POOL_CHECKBOX_COL].Value != value)
|
|
|
|
|
dataGridViewHosts.CheckBoxChange(row.Index, POOL_CHECKBOX_COL);
|
|
|
|
|
}
|
2016-07-01 18:41:49 +02:00
|
|
|
|
if (IsInAutomaticMode && row.Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
dataGridViewHosts.CheckBoxChange(row.Index, POOL_CHECKBOX_COL);
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonClearAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckAllCheckBoxes(UNCHECKED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewHosts_CheckBoxClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Nested items
|
|
|
|
|
|
|
|
|
|
private class PatchingHostsDataGridView : CollapsingPoolHostDataGridView
|
|
|
|
|
{
|
|
|
|
|
protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnCellPainting(e);
|
|
|
|
|
|
|
|
|
|
if (e.RowIndex >= 0 && Rows[e.RowIndex].Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)Rows[e.RowIndex];
|
|
|
|
|
if (row.HasPool && (e.ColumnIndex == POOL_CHECKBOX_COL || e.ColumnIndex == PLUS_MINUS_COL))
|
|
|
|
|
{
|
|
|
|
|
e.PaintBackground(e.ClipBounds, true);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
else if (!row.HasPool && e.ColumnIndex == PLUS_MINUS_COL)
|
|
|
|
|
{
|
|
|
|
|
e.PaintBackground(e.ClipBounds, true);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
else if (row.HasPool && !row.Enabled && e.ColumnIndex == POOL_ICON_HOST_CHECKBOX_COL)
|
|
|
|
|
{
|
|
|
|
|
e.PaintBackground(e.ClipBounds, true);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
else if (!row.HasPool && !row.Enabled && e.ColumnIndex == POOL_CHECKBOX_COL)
|
|
|
|
|
{
|
|
|
|
|
e.PaintBackground(e.ClipBounds, true);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.RowIndex >= 0 && Rows[e.RowIndex].Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)Rows[e.RowIndex];
|
|
|
|
|
if (!row.Enabled && e.ColumnIndex == POOL_CHECKBOX_COL)
|
|
|
|
|
{
|
|
|
|
|
e.PaintBackground(e.ClipBounds, true);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CheckBoxChange(int RowIndex, int ColumnIndex)
|
|
|
|
|
{
|
|
|
|
|
if (RowIndex >= 0 && !((PatchingHostsDataGridViewRow)Rows[RowIndex]).Enabled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (RowIndex >= 0 && Rows[RowIndex].Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
if (ColumnIndex == POOL_ICON_HOST_CHECKBOX_COL && Rows[RowIndex].Cells[ColumnIndex].Value is int) //Checkbox
|
|
|
|
|
{
|
|
|
|
|
int hostNewValue = ClickCheckBox(RowIndex, ColumnIndex);
|
|
|
|
|
|
|
|
|
|
PatchingHostsDataGridViewRow poolRow = FindPoolRow(RowIndex);
|
|
|
|
|
bool allHostSameValue = true;
|
|
|
|
|
bool atLeastOneHostChecked = false;
|
|
|
|
|
for (int i = poolRow.Index + 1; i < Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Rows[i].Tag is Host &&
|
|
|
|
|
((PatchingHostsDataGridViewRow)Rows[i]).HasPool)
|
|
|
|
|
{
|
|
|
|
|
if (((int)Rows[i].Cells[POOL_ICON_HOST_CHECKBOX_COL].Value) == CHECKED)
|
|
|
|
|
{
|
|
|
|
|
atLeastOneHostChecked = true;
|
|
|
|
|
}
|
|
|
|
|
if (((PatchingHostsDataGridViewRow)Rows[i]).Enabled && ((int)Rows[i].Cells[POOL_ICON_HOST_CHECKBOX_COL].Value) != hostNewValue)
|
|
|
|
|
{
|
|
|
|
|
allHostSameValue = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (allHostSameValue)
|
|
|
|
|
{
|
|
|
|
|
poolRow.Cells[POOL_CHECKBOX_COL].Value = hostNewValue;
|
|
|
|
|
}
|
|
|
|
|
else if (atLeastOneHostChecked)
|
|
|
|
|
{
|
|
|
|
|
poolRow.Cells[POOL_CHECKBOX_COL].Value = INDETERMINATE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ColumnIndex == POOL_CHECKBOX_COL)
|
|
|
|
|
{
|
|
|
|
|
ClickCheckBox(RowIndex, ColumnIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (RowIndex >= 0 && Rows[RowIndex].Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
if (ColumnIndex == POOL_CHECKBOX_COL)
|
|
|
|
|
{
|
|
|
|
|
ClickCheckBox(RowIndex, ColumnIndex);
|
|
|
|
|
for (int i = RowIndex + 1; i < Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Rows[i].Tag is Host && ((PatchingHostsDataGridViewRow)Rows[i]).HasPool)
|
|
|
|
|
{
|
|
|
|
|
var value = (int)Rows[RowIndex].Cells[ColumnIndex].Value;
|
|
|
|
|
|
|
|
|
|
if (value == UNCHECKED || value == CHECKED)
|
|
|
|
|
Rows[i].Cells[POOL_ICON_HOST_CHECKBOX_COL].Value = value;
|
|
|
|
|
}
|
|
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OnCheckBoxClicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PatchingHostsDataGridViewRow FindPoolRow(int rowIndex)
|
|
|
|
|
{
|
|
|
|
|
for (int i = rowIndex; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (Rows[i].Tag is Pool)
|
|
|
|
|
return (PatchingHostsDataGridViewRow)Rows[i];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int ClickCheckBox(int rowIndex, int columnIndex)
|
|
|
|
|
{
|
|
|
|
|
int value = (int)Rows[rowIndex].Cells[columnIndex].Value;
|
|
|
|
|
if (value == CHECKED)
|
|
|
|
|
{
|
|
|
|
|
Rows[rowIndex].Cells[columnIndex].Value = UNCHECKED;
|
|
|
|
|
return UNCHECKED;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Rows[rowIndex].Cells[columnIndex].Value = CHECKED;
|
|
|
|
|
return CHECKED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class PatchingHostsDataGridViewRow : CollapsingPoolHostDataGridViewRow
|
|
|
|
|
{
|
|
|
|
|
private class DataGridViewNameCell : DataGridViewExNameCell
|
|
|
|
|
{
|
|
|
|
|
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
|
|
|
|
|
{
|
|
|
|
|
Pool pool = value as Pool;
|
|
|
|
|
|
|
|
|
|
if (pool != null)
|
|
|
|
|
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Host host = value as Host;
|
|
|
|
|
if (host != null)
|
|
|
|
|
{
|
|
|
|
|
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)this.DataGridView.Rows[this.RowIndex];
|
|
|
|
|
if (row.HasPool)
|
|
|
|
|
{
|
|
|
|
|
Image hostIcon = Images.GetImage16For(host);
|
|
|
|
|
base.Paint(graphics, clipBounds,
|
|
|
|
|
new Rectangle(cellBounds.X + 16, cellBounds.Y, cellBounds.Width - 16,
|
|
|
|
|
cellBounds.Height), rowIndex, cellState, value, formattedValue,
|
|
|
|
|
errorText, cellStyle, advancedBorderStyle, paintParts);
|
|
|
|
|
|
|
|
|
|
if ((cellState & DataGridViewElementStates.Selected) != 0 && row.Enabled)
|
|
|
|
|
{
|
2013-08-16 18:43:57 +02:00
|
|
|
|
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.SelectionBackColor))
|
|
|
|
|
graphics.FillRectangle(
|
|
|
|
|
brush, cellBounds.X,
|
|
|
|
|
cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-16 18:43:57 +02:00
|
|
|
|
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.BackColor))
|
|
|
|
|
graphics.FillRectangle(brush,
|
|
|
|
|
cellBounds.X, cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (row.Enabled)
|
|
|
|
|
graphics.DrawImage(hostIcon, cellBounds.X, cellBounds.Y + 3, hostIcon.Width,
|
|
|
|
|
hostIcon.Height);
|
|
|
|
|
else
|
|
|
|
|
graphics.DrawImage(hostIcon,
|
|
|
|
|
new Rectangle(cellBounds.X, cellBounds.Y + 3,
|
|
|
|
|
hostIcon.Width, hostIcon.Height),
|
|
|
|
|
0, 0, hostIcon.Width, hostIcon.Height, GraphicsUnit.Pixel,
|
|
|
|
|
Drawing.GreyScaleAttributes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue,
|
|
|
|
|
errorText, cellStyle, advancedBorderStyle, paintParts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class DataGridViewIconCell : DataGridViewImageCell
|
|
|
|
|
{
|
|
|
|
|
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
|
|
|
|
|
{
|
|
|
|
|
Image icon = value as Image;
|
|
|
|
|
if (icon == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)DataGridView.Rows[RowIndex];
|
|
|
|
|
if ((cellState & DataGridViewElementStates.Selected) != 0 && row.Enabled)
|
|
|
|
|
{
|
2013-08-16 18:43:57 +02:00
|
|
|
|
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.SelectionBackColor))
|
|
|
|
|
graphics.FillRectangle(
|
|
|
|
|
brush, cellBounds.X,
|
|
|
|
|
cellBounds.Y, cellBounds.Width, cellBounds.Height);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-16 18:43:57 +02:00
|
|
|
|
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.BackColor))
|
|
|
|
|
graphics.FillRectangle(brush, cellBounds.X,
|
|
|
|
|
cellBounds.Y, cellBounds.Width, cellBounds.Height);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (row.Enabled)
|
|
|
|
|
graphics.DrawImage(icon, cellBounds.X, cellBounds.Y + 3, icon.Width, icon.Height);
|
|
|
|
|
else
|
|
|
|
|
graphics.DrawImage(icon, new Rectangle(cellBounds.X, cellBounds.Y + 3, icon.Width, icon.Height),
|
|
|
|
|
0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel,
|
|
|
|
|
Drawing.GreyScaleAttributes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DataGridViewCell _poolIconHostCheckCell;
|
|
|
|
|
private DataGridViewTextBoxCell _versionCell;
|
|
|
|
|
|
2016-07-05 12:00:40 +02:00
|
|
|
|
public PatchingHostsDataGridViewRow(Pool pool)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
: base(pool)
|
|
|
|
|
{
|
|
|
|
|
SetupCells();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PatchingHostsDataGridViewRow(Host host, bool hasPool)
|
|
|
|
|
: base(host, hasPool)
|
|
|
|
|
{
|
|
|
|
|
SetupCells();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsCheckable
|
|
|
|
|
{
|
|
|
|
|
get { return !HasPool; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Enabled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return base.Enabled;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
base.Enabled = value;
|
|
|
|
|
UpdateDetails();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 13:52:14 +02:00
|
|
|
|
public int CheckValue
|
|
|
|
|
{
|
|
|
|
|
get {
|
|
|
|
|
return Tag is Pool || (Tag is Host && !_hasPool)
|
|
|
|
|
? (int) Cells[POOL_CHECKBOX_COL].Value
|
|
|
|
|
: (int) Cells[POOL_ICON_HOST_CHECKBOX_COL].Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void SetupCells()
|
|
|
|
|
{
|
|
|
|
|
_poolCheckBoxCell = new DataGridViewCheckBoxCell { ThreeState = true };
|
|
|
|
|
|
|
|
|
|
_expansionCell = new DataGridViewImageCell();
|
|
|
|
|
|
|
|
|
|
if (Tag is Pool || (Tag is Host && !_hasPool))
|
|
|
|
|
_poolIconHostCheckCell = new DataGridViewIconCell();
|
|
|
|
|
else
|
|
|
|
|
_poolIconHostCheckCell = new DataGridViewCheckBoxCell();
|
|
|
|
|
|
2014-04-29 16:46:15 +02:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_nameCell = new DataGridViewNameCell();
|
|
|
|
|
_versionCell = new DataGridViewTextBoxCell();
|
|
|
|
|
|
2014-04-29 16:46:15 +02:00
|
|
|
|
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
Cells.AddRange(new[] { _expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _versionCell });
|
|
|
|
|
|
|
|
|
|
this.UpdateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateDetails()
|
|
|
|
|
{
|
|
|
|
|
if (Tag is Pool)
|
|
|
|
|
{
|
|
|
|
|
Pool pool = (Pool)Tag;
|
|
|
|
|
Host master = pool.Connection.Resolve(pool.master);
|
|
|
|
|
_poolCheckBoxCell.Value = 0;
|
|
|
|
|
_expansionCell.Value = Resources.tree_minus;
|
|
|
|
|
_poolIconHostCheckCell.Value = Images.GetImage16For(pool);
|
|
|
|
|
_nameCell.Value = pool;
|
|
|
|
|
_versionCell.Value = master.ProductVersionTextShort;
|
|
|
|
|
}
|
|
|
|
|
else if (Tag is Host)
|
|
|
|
|
{
|
|
|
|
|
Host host = (Host)Tag;
|
|
|
|
|
_poolCheckBoxCell.Value = 0;
|
|
|
|
|
_expansionCell.Value = Resources.tree_plus;
|
|
|
|
|
if (_hasPool)
|
|
|
|
|
_poolIconHostCheckCell.Value = 0;
|
|
|
|
|
else
|
|
|
|
|
_poolIconHostCheckCell.Value = Images.GetImage16For(host);
|
|
|
|
|
_nameCell.Value = host;
|
|
|
|
|
_versionCell.Value = host.ProductVersionTextShort;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void UpdateIcon()
|
|
|
|
|
{
|
|
|
|
|
if (_poolIconHostCheckCell is DataGridViewImageCell)
|
|
|
|
|
{
|
|
|
|
|
_poolIconHostCheckCell.Value = Images.GetImage16For((IXenObject)Tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|