2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2013-06-24 13:41:48 +02:00
|
|
|
|
* 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.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAPI;
|
2015-07-20 15:34:58 +02:00
|
|
|
|
using XenAdmin.Alerts;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class PatchingWizard_ModePage : XenTabPage
|
|
|
|
|
{
|
2016-11-04 18:07:56 +01:00
|
|
|
|
private bool _tooltipShowing;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_ModePage()
|
|
|
|
|
{
|
2016-09-09 16:45:38 +02:00
|
|
|
|
InitializeComponent();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get { return Messages.PATCHINGWIZARD_MODEPAGE_TEXT; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get { return Messages.PATCHINGWIZARD_MODEPAGE_TITLE; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "UpdateMode"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool EnablePrevious()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string NextText(bool isLastPage)
|
|
|
|
|
{
|
|
|
|
|
return Messages.UPDATES_WIZARD_APPLY_UPDATE;
|
|
|
|
|
}
|
2016-08-23 19:16:33 +02:00
|
|
|
|
|
2016-10-20 18:19:42 +02:00
|
|
|
|
public Dictionary<string, livepatch_status> LivePatchCodesByHost
|
2016-08-23 19:16:33 +02:00
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
|
|
|
|
public Pool_update PoolUpdate
|
|
|
|
|
{
|
|
|
|
|
private get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2016-11-04 18:07:56 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override void PageLoaded(PageLoadedDirection direction)
|
|
|
|
|
{
|
|
|
|
|
base.PageLoaded(direction);
|
|
|
|
|
|
|
|
|
|
textBoxLog.Clear();
|
|
|
|
|
|
2016-09-09 16:45:38 +02:00
|
|
|
|
var unknownType = false;
|
2016-08-19 18:27:24 +02:00
|
|
|
|
|
2016-09-15 18:19:47 +02:00
|
|
|
|
var someHostMayRequireRestart = false; // If a host has restartHost guidance, even if is a live patch, we want this true (as live patch may fail)
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
switch (SelectedUpdateType)
|
|
|
|
|
{
|
|
|
|
|
case UpdateType.NewRetail:
|
|
|
|
|
case UpdateType.Existing:
|
2016-10-20 20:12:57 +02:00
|
|
|
|
textBoxLog.Text = PatchingWizardModeGuidanceBuilder.ModeRetailPatch(SelectedServers, Patch, out someHostMayRequireRestart);
|
2016-11-04 18:07:56 +01:00
|
|
|
|
break;
|
2016-08-31 11:42:09 +02:00
|
|
|
|
case UpdateType.ISO:
|
2015-01-20 15:22:29 +01:00
|
|
|
|
AutomaticRadioButton.Enabled = true;
|
|
|
|
|
AutomaticRadioButton.Checked = true;
|
2016-10-05 00:26:35 +02:00
|
|
|
|
textBoxLog.Text = PoolUpdate != null
|
2016-10-20 20:12:57 +02:00
|
|
|
|
? PatchingWizardModeGuidanceBuilder.ModeRetailPatch(SelectedServers, PoolUpdate, LivePatchCodesByHost, out someHostMayRequireRestart)
|
|
|
|
|
: PatchingWizardModeGuidanceBuilder.ModeSuppPack(SelectedServers, out someHostMayRequireRestart);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
break;
|
2016-08-26 15:45:24 +02:00
|
|
|
|
default:
|
2016-09-09 16:45:38 +02:00
|
|
|
|
unknownType = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-20 20:12:57 +02:00
|
|
|
|
|
2016-09-15 18:19:47 +02:00
|
|
|
|
var automaticDisabled = unknownType || (AnyPoolForbidsAutoRestart() && someHostMayRequireRestart);
|
2016-09-09 16:45:38 +02:00
|
|
|
|
|
2016-09-15 17:37:37 +02:00
|
|
|
|
AutomaticRadioButton.Enabled = !automaticDisabled;
|
|
|
|
|
AutomaticRadioButton.Checked = !automaticDisabled;
|
|
|
|
|
ManualRadioButton.Checked = automaticDisabled;
|
2016-09-09 16:45:38 +02:00
|
|
|
|
|
2016-09-15 17:37:37 +02:00
|
|
|
|
if (automaticDisabled)
|
2016-11-04 18:07:56 +01:00
|
|
|
|
{
|
|
|
|
|
tableLayoutPanel1.MouseMove += tableLayoutPanel1_MouseMove;
|
|
|
|
|
}
|
2015-07-20 15:34:58 +02:00
|
|
|
|
|
2017-05-05 15:43:59 +02:00
|
|
|
|
if (SelectedUpdateType == UpdateType.ISO)
|
2015-07-20 15:34:58 +02:00
|
|
|
|
{
|
2015-09-30 13:57:08 +02:00
|
|
|
|
removeUpdateFileCheckBox.Checked = false;
|
2015-07-23 12:30:18 +02:00
|
|
|
|
removeUpdateFileCheckBox.Visible = false;
|
2015-07-20 15:34:58 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 18:07:56 +01:00
|
|
|
|
public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
|
|
|
|
|
{
|
|
|
|
|
tableLayoutPanel1.MouseMove -= tableLayoutPanel1_MouseMove;
|
|
|
|
|
base.PageLeave(direction, ref cancel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Display the tooltip over the automatic radio button only if it is disabled
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var control = tableLayoutPanel1.GetChildAtPoint(e.Location);
|
|
|
|
|
if (control != null && !control.Enabled && control is RadioButton)
|
|
|
|
|
{
|
|
|
|
|
if (_tooltipShowing) return;
|
|
|
|
|
|
|
|
|
|
automaticRadioButtonTooltip.Show(Messages.POOL_FORBIDS_AUTOMATIC_RESTARTS,
|
|
|
|
|
AutomaticRadioButton,
|
|
|
|
|
e.Location.X, control.Height/2);
|
|
|
|
|
_tooltipShowing = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
automaticRadioButtonTooltip.Hide(AutomaticRadioButton);
|
|
|
|
|
_tooltipShowing = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
|
|
|
|
return AutomaticRadioButton.Checked || ManualRadioButton.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateEnablement()
|
|
|
|
|
{
|
|
|
|
|
textBoxLog.Enabled = ManualRadioButton.Checked;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
|
|
|
public string ManualTextInstructions
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return textBoxLog.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsAutomaticMode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return AutomaticRadioButton.Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 18:35:50 +02:00
|
|
|
|
public bool RemoveUpdateFile
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return removeUpdateFileCheckBox.Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public List<Host> SelectedServers { private get; set; }
|
|
|
|
|
public Pool_patch Patch { private get; set; }
|
|
|
|
|
public UpdateType SelectedUpdateType { private get; set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void AutomaticRadioButton_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ManualRadioButton_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 18:27:24 +02:00
|
|
|
|
private bool AnyPoolForbidsAutoRestart()
|
|
|
|
|
{
|
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
var pool = Helpers.GetPoolOfOne(server.Connection);
|
2017-09-03 04:33:29 +02:00
|
|
|
|
if (pool.IsAutoUpdateRestartsForbidden())
|
2016-08-19 18:27:24 +02:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string filePath = Path.GetTempFileName();
|
|
|
|
|
FileStream fileStream = File.Create(filePath);
|
|
|
|
|
StreamWriter sw = new StreamWriter(fileStream);
|
|
|
|
|
sw.Write(textBoxLog.Text);
|
|
|
|
|
sw.Close();
|
|
|
|
|
fileStream.Close();
|
|
|
|
|
Process.Start("notepad.exe", filePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|