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.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using XenAdmin.Actions;
|
2018-10-04 15:38:07 +02:00
|
|
|
|
using XenAdmin.Actions.HostActions;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Properties;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.RollingUpgradeWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class RollingUpgradeWizardInstallMethodPage : XenTabPage
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
2018-10-04 15:38:07 +02:00
|
|
|
|
private TestLocationInstallerAction testingAction;
|
2019-01-28 03:00:28 +01:00
|
|
|
|
private bool testingUrl;
|
|
|
|
|
private RollingUpgradeInstallMethod _installMethod = RollingUpgradeInstallMethod.http;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public RollingUpgradeWizardInstallMethodPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
comboBoxUpgradeMethod.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
public IEnumerable<Host> SelectedMasters { private get; set; }
|
|
|
|
|
public Dictionary<string, string> InstallMethodConfig;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#region XenTabPage overrides
|
|
|
|
|
|
CP-30335: Rearrange the RPU wizard pages
- Moved Install Location (RollingUpgradeWizard_SelectInstallMethod) page immediatelly after the Upgrade Mode page (and before the Prechecks page)
- Added a new page, called Extras, which contains the updates and supp pack installation options. These options have been moved here from the "Upgrade Mode" and "Ready To Upgrade" pages. This page is also inserted before the Prechecks
- There is no "Ready To Upgrade" page anymore. So the wizard pages are:
- when automatic mode is selected: Before You Start, Select Pools, Upgrade Mode, Installer Location, Extras, Prechecks, Apply Upgrade.
- when manual mode is selected: Before You Start, Select Pools, Upgrade Mode, Extras, Prechecks, Apply Upgrade.
Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
2019-01-17 15:01:49 +01:00
|
|
|
|
public override string Text => Messages.ROLLING_UPGRADE_METHOD_PAGE_TEXT;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
CP-30335: Rearrange the RPU wizard pages
- Moved Install Location (RollingUpgradeWizard_SelectInstallMethod) page immediatelly after the Upgrade Mode page (and before the Prechecks page)
- Added a new page, called Extras, which contains the updates and supp pack installation options. These options have been moved here from the "Upgrade Mode" and "Ready To Upgrade" pages. This page is also inserted before the Prechecks
- There is no "Ready To Upgrade" page anymore. So the wizard pages are:
- when automatic mode is selected: Before You Start, Select Pools, Upgrade Mode, Installer Location, Extras, Prechecks, Apply Upgrade.
- when manual mode is selected: Before You Start, Select Pools, Upgrade Mode, Extras, Prechecks, Apply Upgrade.
Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
2019-01-17 15:01:49 +01:00
|
|
|
|
public override string PageTitle => Messages.ROLLING_UPGRADE_METHOD_PAGE_TITLE;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
public override string HelpID => "upgrademethod";
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
if (testingUrl)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return testingAction != null && testingAction.IsCompleted && testingAction.Succeeded;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
|
|
|
|
{
|
|
|
|
|
ResetCheckControls();
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
2017-12-06 13:06:36 +01:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
StopUrlTesting();
|
2017-12-06 13:06:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 13:33:26 +01:00
|
|
|
|
public override void PageCancelled(ref bool cancel)
|
2017-12-06 13:06:36 +01:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
StopUrlTesting();
|
2017-12-06 13:06:36 +01:00
|
|
|
|
}
|
2019-01-28 03:00:28 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void ShowBottomError(string msg)
|
|
|
|
|
{
|
|
|
|
|
pictureBox2.Visible = true;
|
|
|
|
|
labelErrors.Visible = true;
|
|
|
|
|
labelErrors.Text = msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
private void ShowSideIcon(Image img)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
pictureBox1.Visible = true;
|
2019-01-28 03:00:28 +01:00
|
|
|
|
pictureBox1.Image = img;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HideBottomError()
|
|
|
|
|
{
|
|
|
|
|
pictureBox2.Visible = false;
|
|
|
|
|
labelErrors.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HideSideIcon()
|
|
|
|
|
{
|
|
|
|
|
pictureBox1.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResetCheckControls()
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
testingAction = null;
|
|
|
|
|
buttonTest.Enabled = !string.IsNullOrWhiteSpace(watermarkTextBox1.Text);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
HideSideIcon();
|
|
|
|
|
HideBottomError();
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
switch (comboBoxUpgradeMethod.SelectedIndex)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
case 0:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.http;
|
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "www.example.com/");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.nfs;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "server:path/");
|
|
|
|
|
break;
|
2019-01-28 03:00:28 +01:00
|
|
|
|
case 2:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.ftp;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "ftp.example.com/");
|
|
|
|
|
break;
|
2019-01-28 03:00:28 +01:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
labelUser.Visible = textBoxUser.Visible =
|
|
|
|
|
labelPassword.Visible = textBoxPassword.Visible = _installMethod != RollingUpgradeInstallMethod.nfs;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
ResetCheckControls();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
private string AutoCorrectUrl(out Dictionary<string, string> config)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
var url = watermarkTextBox1.Text.Trim().Replace(" ", "");
|
|
|
|
|
if (!url.EndsWith("/"))
|
|
|
|
|
url = $"{url}/";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
foreach (string method in Enum.GetNames(typeof(RollingUpgradeInstallMethod)))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
string prefix = method.ToLower() + @"://";
|
|
|
|
|
if (url.ToLower().StartsWith(prefix))
|
|
|
|
|
url = url.Substring(prefix.Length);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
config = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
if (_installMethod != RollingUpgradeInstallMethod.nfs &&
|
|
|
|
|
!string.IsNullOrWhiteSpace(textBoxUser.Text) && !string.IsNullOrWhiteSpace(textBoxPassword.Text))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
config["url"]= $"{_installMethod}://{textBoxUser.Text.UrlEncode()}:{textBoxPassword.Text.UrlEncode()}@{url}";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2019-01-28 03:00:28 +01:00
|
|
|
|
else
|
|
|
|
|
config["url"]= $"{_installMethod}://{url}";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
return url;
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
private void buttonTest_Click(object sender, EventArgs e)
|
2017-12-06 13:06:36 +01:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
if (testingUrl)
|
|
|
|
|
StopUrlTesting();
|
2017-12-06 13:06:36 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
watermarkTextBox1.Text = AutoCorrectUrl(out InstallMethodConfig);
|
|
|
|
|
StartUrlTesting();
|
2017-12-06 13:06:36 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StartUrlTesting()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
var host = SelectedMasters.First();
|
|
|
|
|
Pool pool = host != null ? Helpers.GetPoolOfOne(host.Connection) : null;
|
2017-09-03 04:33:29 +02:00
|
|
|
|
host = pool != null ? pool.HostsToUpgrade().First() : null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (host == null)
|
|
|
|
|
{
|
|
|
|
|
ShowBottomError(Messages.UPDATES_WIZARD_CONNECTION_LOST);
|
|
|
|
|
ShowSideIcon(Resources._000_Abort_h32bit_16);
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
testingAction = new TestLocationInstallerAction(host, InstallMethodConfig);
|
|
|
|
|
testingAction.Completed += action_Completed;
|
|
|
|
|
testingUrl = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
ShowSideIcon(Resources.ajax_loader);
|
2019-01-28 03:00:28 +01:00
|
|
|
|
ChangeInputEnablement();
|
|
|
|
|
testingAction.RunAsync();
|
|
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The TestLocationInstallerAction cannot be cancelled because it is implemented as a plug-in
|
|
|
|
|
/// on the server side. What we do is:
|
|
|
|
|
/// 1. Ignore the Completed event of the action, and
|
|
|
|
|
/// 2. Recover the button text and side icon.
|
|
|
|
|
/// </summary>
|
2017-12-06 13:06:36 +01:00
|
|
|
|
private void StopUrlTesting()
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
if (testingAction != null)
|
|
|
|
|
{
|
|
|
|
|
testingAction.Completed -= action_Completed;
|
|
|
|
|
testingUrl = false;
|
|
|
|
|
ChangeInputEnablement();
|
|
|
|
|
HideSideIcon();
|
|
|
|
|
}
|
2017-12-06 13:06:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
private void action_Completed(ActionBase action)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
action.Completed -= action_Completed;
|
|
|
|
|
if (action != testingAction)
|
|
|
|
|
return;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
Program.Invoke(this, () =>
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
testingUrl = false;
|
|
|
|
|
ChangeInputEnablement();
|
|
|
|
|
|
|
|
|
|
if (action.Succeeded)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
ShowSideIcon(Images.StaticImages._000_Tick_h32bit_16);
|
|
|
|
|
HideBottomError();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
ShowSideIcon(Images.StaticImages._000_Abort_h32bit_16);
|
|
|
|
|
ShowBottomError(action.Exception.Message);
|
|
|
|
|
}
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 03:00:28 +01:00
|
|
|
|
private void ChangeInputEnablement()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-28 03:00:28 +01:00
|
|
|
|
textBoxUser.Enabled = textBoxPassword.Enabled = watermarkTextBox1.Enabled = comboBoxUpgradeMethod.Enabled = !testingUrl;
|
|
|
|
|
buttonTest.Text = testingUrl ? Messages.ROLLING_UPGRADE_BUTTON_LABEL_STOP : Messages.ROLLING_UPGRADE_BUTTON_LABEL_TEST;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watermarkTextBox1_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ResetCheckControls();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void textBoxUser_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ResetCheckControls();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void textBoxPassword_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ResetCheckControls();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum RollingUpgradeInstallMethod
|
|
|
|
|
{
|
|
|
|
|
http,
|
|
|
|
|
nfs,
|
|
|
|
|
ftp
|
|
|
|
|
}
|
|
|
|
|
}
|