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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-29 15:17:42 +01:00
|
|
|
|
using System;
|
2018-06-14 15:53:48 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Controls;
|
2019-01-29 15:17:42 +01:00
|
|
|
|
using XenAdmin.Core;
|
2018-06-14 15:53:48 +02:00
|
|
|
|
using XenAPI;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.RollingUpgradeWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class RollingUpgradeWizardUpgradeModePage : XenTabPage
|
|
|
|
|
{
|
2019-01-29 15:17:42 +01:00
|
|
|
|
private enum RollingUpgradeInstallMethod
|
|
|
|
|
{
|
|
|
|
|
http,
|
|
|
|
|
nfs,
|
|
|
|
|
ftp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RollingUpgradeInstallMethod _installMethod = RollingUpgradeInstallMethod.http;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public RollingUpgradeWizardUpgradeModePage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-01-29 15:17:42 +01:00
|
|
|
|
comboBoxUpgradeMethod.SelectedIndex = 0;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2019-01-29 15:17:42 +01:00
|
|
|
|
|
2018-06-14 15:53:48 +02:00
|
|
|
|
#region XenTabPage overrides
|
2019-01-29 15:17:42 +01:00
|
|
|
|
|
|
|
|
|
public override string Text => Messages.ROLLING_UPGRADE_TITLE_MODE;
|
|
|
|
|
|
|
|
|
|
public override string PageTitle => Messages.ROLLING_UPGRADE_MODE_PAGE;
|
|
|
|
|
|
|
|
|
|
public override string HelpID => "Upgrademode";
|
|
|
|
|
|
|
|
|
|
public override bool EnableNext()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-29 15:17:42 +01:00
|
|
|
|
if (radioButtonAutomatic.Checked)
|
|
|
|
|
return !string.IsNullOrWhiteSpace(watermarkTextBox1.Text);
|
|
|
|
|
|
|
|
|
|
return true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-29 15:17:42 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-29 15:17:42 +01:00
|
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-29 15:17:42 +01:00
|
|
|
|
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-29 15:17:42 +01:00
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
|
|
|
|
InstallMethodConfig = radioButtonAutomatic.Checked ? CalculateInstallMethodConfig() : null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2019-01-29 15:17:42 +01:00
|
|
|
|
|
2018-06-14 15:53:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
2019-01-29 15:17:42 +01:00
|
|
|
|
|
2018-06-14 15:53:48 +02:00
|
|
|
|
#region Accessors
|
|
|
|
|
|
2019-01-29 15:17:42 +01:00
|
|
|
|
public Dictionary<string, string> InstallMethodConfig;
|
|
|
|
|
|
|
|
|
|
public bool ManualModeSelected => radioButtonManual.Checked;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private Dictionary<string, string> CalculateInstallMethodConfig()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-01-29 15:17:42 +01:00
|
|
|
|
if (string.IsNullOrWhiteSpace(watermarkTextBox1.Text))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var url = watermarkTextBox1.Text.Trim().Replace(" ", "");
|
|
|
|
|
if (!url.EndsWith("/"))
|
|
|
|
|
url = $"{url}/";
|
|
|
|
|
|
|
|
|
|
foreach (string method in Enum.GetNames(typeof(RollingUpgradeInstallMethod)))
|
|
|
|
|
{
|
|
|
|
|
string prefix = method.ToLower() + @"://";
|
|
|
|
|
if (url.ToLower().StartsWith(prefix))
|
|
|
|
|
{
|
|
|
|
|
url = url.Substring(prefix.Length);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watermarkTextBox1.Text = url;
|
|
|
|
|
|
|
|
|
|
var config = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
if (_installMethod != RollingUpgradeInstallMethod.nfs &&
|
|
|
|
|
!string.IsNullOrWhiteSpace(textBoxUser.Text) && !string.IsNullOrWhiteSpace(textBoxPassword.Text))
|
|
|
|
|
{
|
|
|
|
|
config["url"] = $"{_installMethod}://{textBoxUser.Text.UrlEncode()}:{textBoxPassword.Text.UrlEncode()}@{url}";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
config["url"] = $"{_installMethod}://{url}";
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Control event handlers
|
|
|
|
|
|
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
radioButtonAutomatic.Checked = true;
|
|
|
|
|
|
|
|
|
|
switch (comboBoxUpgradeMethod.SelectedIndex)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.http;
|
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "www.example.com/");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.nfs;
|
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "server:path/");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
_installMethod = RollingUpgradeInstallMethod.ftp;
|
|
|
|
|
CueBannersManager.SetWatermark(watermarkTextBox1, "ftp.example.com/");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
labelUser.Visible = textBoxUser.Visible =
|
|
|
|
|
labelPassword.Visible = textBoxPassword.Visible = _installMethod != RollingUpgradeInstallMethod.nfs;
|
|
|
|
|
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watermarkTextBox1_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
radioButtonAutomatic.Checked = true;
|
|
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2019-01-29 15:17:42 +01:00
|
|
|
|
|
|
|
|
|
private void textBoxUser_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
radioButtonAutomatic.Checked = true;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void textBoxPassword_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
radioButtonAutomatic.Checked = true;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void radioButtonAutomatic_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (radioButtonAutomatic.Checked)
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void radioButtonManual_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (radioButtonManual.Checked)
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 15:53:48 +02:00
|
|
|
|
#endregion
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|