CP-12152: Call Home enrollment

This commit is contained in:
Mihaela Stoica 2015-05-18 15:23:32 +01:00
parent 49db08d3a9
commit 9783c6dc7e
12 changed files with 6016 additions and 2 deletions

View File

@ -0,0 +1,222 @@
/* 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.Threading;
using System.Windows.Forms;
using XenAdmin.Actions;
using XenAdmin.Core;
using XenAPI;
namespace XenAdmin.Dialogs.CallHome
{
public partial class CallHomeSettingsDialog : XenDialogBase
{
private readonly Pool pool;
private CallHomeSettings callHomeSettings;
private bool authenticationRequired;
private bool authenticated;
private string authenticationToken;
public CallHomeSettingsDialog(Pool pool): this(pool, null)
{
}
public CallHomeSettingsDialog(Pool pool, string authenticationToken)
{
this.pool = pool;
callHomeSettings = pool.CallHomeSettings;
this.authenticationToken = callHomeSettings.AuthenticationToken ?? authenticationToken;
InitializeComponent();
PopulateControls();
InitializeControls();
UpdateButtons();
}
private void PopulateControls()
{
var list = BuildDays();
var ds = new BindingSource(list, null);
dayOfWeekComboBox.DataSource = ds;
dayOfWeekComboBox.ValueMember = "key";
dayOfWeekComboBox.DisplayMember = "value";
var list1 = BuildHours();
var ds1 = new BindingSource(list1, null);
timeOfDayComboBox.DataSource = ds1;
timeOfDayComboBox.ValueMember = "key";
timeOfDayComboBox.DisplayMember = "value";
}
private Dictionary<int, string> BuildDays()
{
Dictionary<int, string> days = new Dictionary<int, string>();
foreach (var dayOfWeek in Enum.GetValues(typeof(DayOfWeek)))
{
days.Add((int)dayOfWeek, dayOfWeek.ToString());
}
return days;
}
private SortedDictionary<int, string> BuildHours()
{
SortedDictionary<int, string> hours = new SortedDictionary<int, string>();
for (int hour = 0; hour <= 23; hour++)
{
DateTime time = new DateTime(1900, 1, 1, hour, 0, 0);
hours.Add(hour, HelpersGUI.DateTimeToString(time, Messages.DATEFORMAT_HM, true));
}
return hours;
}
private void InitializeControls()
{
authenticationRequired = string.IsNullOrEmpty(authenticationToken);
authenticated = !authenticationRequired;
Text = String.Format(Messages.CALLHOME_ENROLLMENT_TITLE, pool.Name);
authenticationRubricLabel.Text = authenticationRequired
? Messages.CALLHOME_AUTHENTICATION_RUBRIC_NO_TOKEN
: Messages.CALLHOME_AUTHENTICATION_RUBRIC_EXISTING_TOKEN;
enrollmentCheckBox.Checked = callHomeSettings.Status != CallHomeStatus.Disabled;
frequencyNumericBox.Value = callHomeSettings.IntervalInWeeks;
dayOfWeekComboBox.SelectedValue = (int)callHomeSettings.DayOfWeek;
timeOfDayComboBox.SelectedValue = callHomeSettings.TimeOfDay;
existingAuthenticationRadioButton.Enabled = existingAuthenticationRadioButton.Checked = !authenticationRequired;
newAuthenticationRadioButton.Checked = authenticationRequired;
authenticateButton.Enabled = false;
}
private bool ChangesMade()
{
if (enrollmentCheckBox.Checked && callHomeSettings.Status != CallHomeStatus.Enabled)
return true;
if (!enrollmentCheckBox.Checked && callHomeSettings.Status != CallHomeStatus.Disabled)
return true;
if (frequencyNumericBox.Value != callHomeSettings.IntervalInWeeks)
return true;
if (dayOfWeekComboBox.SelectedIndex != (int)callHomeSettings.DayOfWeek)
return true;
if (timeOfDayComboBox.SelectedIndex != callHomeSettings.TimeOfDay)
return true;
return false;
}
private void UpdateButtons()
{
okButton.Enabled = !enrollmentCheckBox.Checked || !authenticationRequired || authenticated;
okButton.Text = callHomeSettings.Status == CallHomeStatus.Enabled || !enrollmentCheckBox.Checked
? Messages.OK
: Messages.CALLHOME_ENROLLMENT_CONFIRMATION_BUTTON_LABEL;
}
private void credentials_TextChanged(object sender, EventArgs e)
{
authenticateButton.Enabled = !string.IsNullOrEmpty(usernameTextBox.Text.Trim()) &&
!string.IsNullOrEmpty(passwordTextBox.Text.Trim());
newAuthenticationRadioButton.Checked = !string.IsNullOrEmpty(usernameTextBox.Text) ||
!string.IsNullOrEmpty(passwordTextBox.Text);
}
private void authenticateButton_Click(object sender, EventArgs e)
{
HideAuthenticationStatusControls();
spinnerIcon.StartSpinning();
var action = new CallHomeAuthenticationAction(pool, usernameTextBox.Text.Trim(), passwordTextBox.Text.Trim(), false);
action.Completed += CallHomeAuthenticationAction_Completed;
authenticateButton.Enabled = false;
action.RunAsync();
}
private void CallHomeAuthenticationAction_Completed(ActionBase action)
{
Program.Invoke(this, delegate
{
if (action.Succeeded)
{
spinnerIcon.DisplaySucceededImage();
authenticated = true;
}
else
{
spinnerIcon.Visible = false;
statusPictureBox.Visible = statusLabel.Visible = true;
statusLabel.Text = action.Exception != null
? action.Exception.Message
: Messages.ERROR_UNKNOWN;
}
authenticateButton.Enabled = true;
UpdateButtons();
});
}
private void HideAuthenticationStatusControls()
{
statusPictureBox.Visible = statusLabel.Visible = false;
}
private void okButton_Click(object sender, EventArgs e)
{
if (ChangesMade())
{
var newCallHomeSettings = new CallHomeSettings(
enrollmentCheckBox.Checked ? CallHomeStatus.Enabled : CallHomeStatus.Disabled,
(int) (frequencyNumericBox.Value * 7),
(DayOfWeek) dayOfWeekComboBox.SelectedValue,
(int) timeOfDayComboBox.SelectedValue,
CallHomeSettings.DefaultRetryInterval,
authenticationToken);
new SaveCallHomeSettingsAction(pool, newCallHomeSettings, false).RunAsync();
}
DialogResult = DialogResult.OK;
Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void enrollmentCheckBox_CheckedChanged(object sender, EventArgs e)
{
UpdateButtons();
}
}
}

View File

@ -0,0 +1,374 @@
namespace XenAdmin.Dialogs.CallHome
{
partial class CallHomeSettingsDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CallHomeSettingsDialog));
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel3 = new System.Windows.Forms.FlowLayoutPanel();
this.passwordTextBox = new System.Windows.Forms.TextBox();
this.usernameTextBox = new System.Windows.Forms.TextBox();
this.passwordLabel = new System.Windows.Forms.Label();
this.usernameLabel = new System.Windows.Forms.Label();
this.authenticationRubricLabel = new System.Windows.Forms.Label();
this.authenticationLabel = new System.Windows.Forms.Label();
this.timeOfDayComboBox = new System.Windows.Forms.ComboBox();
this.timeOfDayLabel = new System.Windows.Forms.Label();
this.dayOfweekLabel = new System.Windows.Forms.Label();
this.weeksLabel = new System.Windows.Forms.Label();
this.frequencyLabel = new System.Windows.Forms.Label();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
this.policyStatementLabel = new System.Windows.Forms.Label();
this.PolicyStatementLinkLabel = new System.Windows.Forms.LinkLabel();
this.scheduleLabel = new System.Windows.Forms.Label();
this.rubricLabel = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.enrollmentCheckBox = new System.Windows.Forms.CheckBox();
this.frequencyNumericBox = new System.Windows.Forms.NumericUpDown();
this.dayOfWeekComboBox = new System.Windows.Forms.ComboBox();
this.existingAuthenticationRadioButton = new System.Windows.Forms.RadioButton();
this.newAuthenticationRadioButton = new System.Windows.Forms.RadioButton();
this.authenticationStatusTable = new System.Windows.Forms.TableLayoutPanel();
this.spinnerIcon = new XenAdmin.Controls.SpinnerIcon();
this.authenticateButton = new System.Windows.Forms.Button();
this.statusPictureBox = new System.Windows.Forms.PictureBox();
this.statusLabel = new XenAdmin.Controls.Common.AutoHeightLabel();
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).BeginInit();
this.authenticationStatusTable.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.spinnerIcon)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusPictureBox)).BeginInit();
this.SuspendLayout();
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// tableLayoutPanel1
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel3, 2, 15);
this.tableLayoutPanel1.Controls.Add(this.passwordTextBox, 3, 14);
this.tableLayoutPanel1.Controls.Add(this.usernameTextBox, 3, 13);
this.tableLayoutPanel1.Controls.Add(this.passwordLabel, 2, 14);
this.tableLayoutPanel1.Controls.Add(this.usernameLabel, 2, 13);
this.tableLayoutPanel1.Controls.Add(this.authenticationRubricLabel, 1, 10);
this.tableLayoutPanel1.Controls.Add(this.authenticationLabel, 0, 9);
this.tableLayoutPanel1.Controls.Add(this.timeOfDayComboBox, 3, 8);
this.tableLayoutPanel1.Controls.Add(this.timeOfDayLabel, 1, 8);
this.tableLayoutPanel1.Controls.Add(this.dayOfweekLabel, 1, 7);
this.tableLayoutPanel1.Controls.Add(this.weeksLabel, 4, 6);
this.tableLayoutPanel1.Controls.Add(this.frequencyLabel, 1, 6);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.scheduleLabel, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.rubricLabel, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 18);
this.tableLayoutPanel1.Controls.Add(this.enrollmentCheckBox, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.frequencyNumericBox, 3, 6);
this.tableLayoutPanel1.Controls.Add(this.dayOfWeekComboBox, 3, 7);
this.tableLayoutPanel1.Controls.Add(this.existingAuthenticationRadioButton, 1, 11);
this.tableLayoutPanel1.Controls.Add(this.newAuthenticationRadioButton, 1, 12);
this.tableLayoutPanel1.Controls.Add(this.authenticationStatusTable, 2, 16);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// flowLayoutPanel3
//
resources.ApplyResources(this.flowLayoutPanel3, "flowLayoutPanel3");
this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel3, 3);
this.flowLayoutPanel3.Name = "flowLayoutPanel3";
//
// passwordTextBox
//
this.tableLayoutPanel1.SetColumnSpan(this.passwordTextBox, 2);
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
this.passwordTextBox.Name = "passwordTextBox";
this.passwordTextBox.UseSystemPasswordChar = true;
this.passwordTextBox.TextChanged += new System.EventHandler(this.credentials_TextChanged);
//
// usernameTextBox
//
this.tableLayoutPanel1.SetColumnSpan(this.usernameTextBox, 2);
resources.ApplyResources(this.usernameTextBox, "usernameTextBox");
this.usernameTextBox.Name = "usernameTextBox";
this.usernameTextBox.TextChanged += new System.EventHandler(this.credentials_TextChanged);
//
// passwordLabel
//
resources.ApplyResources(this.passwordLabel, "passwordLabel");
this.passwordLabel.Name = "passwordLabel";
//
// usernameLabel
//
resources.ApplyResources(this.usernameLabel, "usernameLabel");
this.usernameLabel.Name = "usernameLabel";
//
// authenticationRubricLabel
//
resources.ApplyResources(this.authenticationRubricLabel, "authenticationRubricLabel");
this.tableLayoutPanel1.SetColumnSpan(this.authenticationRubricLabel, 4);
this.authenticationRubricLabel.Name = "authenticationRubricLabel";
//
// authenticationLabel
//
resources.ApplyResources(this.authenticationLabel, "authenticationLabel");
this.tableLayoutPanel1.SetColumnSpan(this.authenticationLabel, 5);
this.authenticationLabel.Name = "authenticationLabel";
//
// timeOfDayComboBox
//
this.tableLayoutPanel1.SetColumnSpan(this.timeOfDayComboBox, 2);
this.timeOfDayComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.timeOfDayComboBox, "timeOfDayComboBox");
this.timeOfDayComboBox.FormattingEnabled = true;
this.timeOfDayComboBox.Name = "timeOfDayComboBox";
//
// timeOfDayLabel
//
resources.ApplyResources(this.timeOfDayLabel, "timeOfDayLabel");
this.tableLayoutPanel1.SetColumnSpan(this.timeOfDayLabel, 2);
this.timeOfDayLabel.Name = "timeOfDayLabel";
//
// dayOfweekLabel
//
resources.ApplyResources(this.dayOfweekLabel, "dayOfweekLabel");
this.tableLayoutPanel1.SetColumnSpan(this.dayOfweekLabel, 2);
this.dayOfweekLabel.Name = "dayOfweekLabel";
//
// weeksLabel
//
resources.ApplyResources(this.weeksLabel, "weeksLabel");
this.weeksLabel.Name = "weeksLabel";
//
// frequencyLabel
//
resources.ApplyResources(this.frequencyLabel, "frequencyLabel");
this.tableLayoutPanel1.SetColumnSpan(this.frequencyLabel, 2);
this.frequencyLabel.Name = "frequencyLabel";
//
// flowLayoutPanel2
//
resources.ApplyResources(this.flowLayoutPanel2, "flowLayoutPanel2");
this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel2, 5);
this.flowLayoutPanel2.Controls.Add(this.policyStatementLabel);
this.flowLayoutPanel2.Controls.Add(this.PolicyStatementLinkLabel);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
//
// policyStatementLabel
//
resources.ApplyResources(this.policyStatementLabel, "policyStatementLabel");
this.policyStatementLabel.Name = "policyStatementLabel";
//
// PolicyStatementLinkLabel
//
resources.ApplyResources(this.PolicyStatementLinkLabel, "PolicyStatementLinkLabel");
this.PolicyStatementLinkLabel.Name = "PolicyStatementLinkLabel";
this.PolicyStatementLinkLabel.TabStop = true;
//
// scheduleLabel
//
resources.ApplyResources(this.scheduleLabel, "scheduleLabel");
this.tableLayoutPanel1.SetColumnSpan(this.scheduleLabel, 5);
this.scheduleLabel.Name = "scheduleLabel";
//
// rubricLabel
//
resources.ApplyResources(this.rubricLabel, "rubricLabel");
this.tableLayoutPanel1.SetColumnSpan(this.rubricLabel, 5);
this.rubricLabel.Name = "rubricLabel";
//
// flowLayoutPanel1
//
resources.ApplyResources(this.flowLayoutPanel1, "flowLayoutPanel1");
this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel1, 5);
this.flowLayoutPanel1.Controls.Add(this.cancelButton);
this.flowLayoutPanel1.Controls.Add(this.okButton);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
//
// enrollmentCheckBox
//
resources.ApplyResources(this.enrollmentCheckBox, "enrollmentCheckBox");
this.tableLayoutPanel1.SetColumnSpan(this.enrollmentCheckBox, 5);
this.enrollmentCheckBox.Name = "enrollmentCheckBox";
this.enrollmentCheckBox.UseVisualStyleBackColor = true;
this.enrollmentCheckBox.CheckedChanged += new System.EventHandler(this.enrollmentCheckBox_CheckedChanged);
//
// frequencyNumericBox
//
resources.ApplyResources(this.frequencyNumericBox, "frequencyNumericBox");
this.frequencyNumericBox.Maximum = new decimal(new int[] {
52,
0,
0,
0});
this.frequencyNumericBox.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.frequencyNumericBox.Name = "frequencyNumericBox";
this.frequencyNumericBox.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// dayOfWeekComboBox
//
this.tableLayoutPanel1.SetColumnSpan(this.dayOfWeekComboBox, 2);
this.dayOfWeekComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.dayOfWeekComboBox, "dayOfWeekComboBox");
this.dayOfWeekComboBox.FormattingEnabled = true;
this.dayOfWeekComboBox.Name = "dayOfWeekComboBox";
//
// existingAuthenticationRadioButton
//
resources.ApplyResources(this.existingAuthenticationRadioButton, "existingAuthenticationRadioButton");
this.tableLayoutPanel1.SetColumnSpan(this.existingAuthenticationRadioButton, 4);
this.existingAuthenticationRadioButton.Name = "existingAuthenticationRadioButton";
this.existingAuthenticationRadioButton.TabStop = true;
this.existingAuthenticationRadioButton.UseVisualStyleBackColor = true;
//
// newAuthenticationRadioButton
//
resources.ApplyResources(this.newAuthenticationRadioButton, "newAuthenticationRadioButton");
this.tableLayoutPanel1.SetColumnSpan(this.newAuthenticationRadioButton, 4);
this.newAuthenticationRadioButton.Name = "newAuthenticationRadioButton";
this.newAuthenticationRadioButton.TabStop = true;
this.newAuthenticationRadioButton.UseVisualStyleBackColor = true;
//
// authenticationStatusTable
//
resources.ApplyResources(this.authenticationStatusTable, "authenticationStatusTable");
this.tableLayoutPanel1.SetColumnSpan(this.authenticationStatusTable, 3);
this.authenticationStatusTable.Controls.Add(this.spinnerIcon, 0, 0);
this.authenticationStatusTable.Controls.Add(this.authenticateButton, 0, 0);
this.authenticationStatusTable.Controls.Add(this.statusPictureBox, 2, 0);
this.authenticationStatusTable.Controls.Add(this.statusLabel, 3, 0);
this.authenticationStatusTable.Name = "authenticationStatusTable";
//
// spinnerIcon
//
resources.ApplyResources(this.spinnerIcon, "spinnerIcon");
this.spinnerIcon.Name = "spinnerIcon";
this.spinnerIcon.SucceededImage = global::XenAdmin.Properties.Resources._000_Tick_h32bit_16;
this.spinnerIcon.TabStop = false;
//
// authenticateButton
//
resources.ApplyResources(this.authenticateButton, "authenticateButton");
this.authenticateButton.Name = "authenticateButton";
this.authenticateButton.UseVisualStyleBackColor = true;
this.authenticateButton.Click += new System.EventHandler(this.authenticateButton_Click);
//
// statusPictureBox
//
resources.ApplyResources(this.statusPictureBox, "statusPictureBox");
this.statusPictureBox.Image = global::XenAdmin.Properties.Resources._000_error_h32bit_16;
this.statusPictureBox.Name = "statusPictureBox";
this.statusPictureBox.TabStop = false;
//
// statusLabel
//
resources.ApplyResources(this.statusLabel, "statusLabel");
this.statusLabel.ForeColor = System.Drawing.Color.Red;
this.statusLabel.Name = "statusLabel";
//
// CallHomeEnrollmentDialog
//
this.AcceptButton = this.okButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.cancelButton;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "CallHomeEnrollmentDialog";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.flowLayoutPanel2.ResumeLayout(false);
this.flowLayoutPanel2.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).EndInit();
this.authenticationStatusTable.ResumeLayout(false);
this.authenticationStatusTable.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.spinnerIcon)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusPictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label rubricLabel;
private System.Windows.Forms.Label scheduleLabel;
private System.Windows.Forms.CheckBox enrollmentCheckBox;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.Label policyStatementLabel;
private System.Windows.Forms.LinkLabel PolicyStatementLinkLabel;
private System.Windows.Forms.Label frequencyLabel;
private System.Windows.Forms.Label weeksLabel;
private System.Windows.Forms.NumericUpDown frequencyNumericBox;
private System.Windows.Forms.Label authenticationLabel;
private System.Windows.Forms.ComboBox timeOfDayComboBox;
private System.Windows.Forms.Label timeOfDayLabel;
private System.Windows.Forms.Label dayOfweekLabel;
private System.Windows.Forms.ComboBox dayOfWeekComboBox;
private System.Windows.Forms.Label authenticationRubricLabel;
private System.Windows.Forms.Label passwordLabel;
private System.Windows.Forms.Label usernameLabel;
private System.Windows.Forms.RadioButton existingAuthenticationRadioButton;
private System.Windows.Forms.RadioButton newAuthenticationRadioButton;
private System.Windows.Forms.TextBox passwordTextBox;
private System.Windows.Forms.TextBox usernameTextBox;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel3;
private System.Windows.Forms.Button authenticateButton;
private System.Windows.Forms.TableLayoutPanel authenticationStatusTable;
private System.Windows.Forms.PictureBox statusPictureBox;
private Controls.Common.AutoHeightLabel statusLabel;
private Controls.SpinnerIcon spinnerIcon;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -201,6 +201,12 @@
<Compile Include="Diagnostics\Problems\ProblemWithInformationUrl.cs" />
<Compile Include="Diagnostics\Problems\SRProblem\UnsupportedStorageLinkSrIsPresentProblem.cs" />
<Compile Include="Diagnostics\Problems\VMProblem\InvalidVCPUConfiguration.cs" />
<Compile Include="Dialogs\CallHome\CallHomeSettingsDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Dialogs\CallHome\CallHomeSettingsDialog.designer.cs">
<DependentUpon>CallHomeSettingsDialog.cs</DependentUpon>
</Compile>
<Compile Include="Dialogs\ExportVMDialog.cs">
</Compile>
<Compile Include="Dialogs\ResolvingSubjectsDialog.cs">
@ -1340,6 +1346,15 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Dialogs\CallHome\CallHomeSettingsDialog.ja.resx">
<DependentUpon>CallHomeSettingsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CallHome\CallHomeSettingsDialog.resx">
<DependentUpon>CallHomeSettingsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CallHome\CallHomeSettingsDialog.zh-CN.resx">
<DependentUpon>CallHomeSettingsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CommandErrorDialog.resx">
<SubType>Designer</SubType>
<DependentUpon>CommandErrorDialog.cs</DependentUpon>

View File

@ -0,0 +1,26 @@
using System.Collections.Generic;
using XenAPI;
namespace XenAdmin.Actions
{
public class CallHomeAuthenticationAction : PureAsyncAction
{
private readonly Pool pool;
public CallHomeAuthenticationAction(Pool pool, string username, string password, bool suppressHistory)
: base(pool.Connection, Messages.ACTION_CALLHOME_AUTHENTICATION, Messages.ACTION_CALLHOME_AUTHENTICATION_PROGRESS, suppressHistory)
{
this.pool = pool;
}
protected override void Run()
{
Dictionary<string, string> newConfig = pool.gui_config;
var authenticationToken = "testToken";
System.Threading.Thread.Sleep(2000);
newConfig[CallHomeSettings.AUTHENTICATION_TOKEN] = authenticationToken;
Pool.set_gui_config(Connection.Session, pool.opaque_ref, newConfig);
}
}
}

View File

@ -0,0 +1,25 @@
using System.Collections.Generic;
using XenAPI;
namespace XenAdmin.Actions
{
public class SaveCallHomeSettingsAction : PureAsyncAction
{
private readonly Pool pool;
CallHomeSettings callHomeSettings;
public SaveCallHomeSettingsAction(Pool pool, CallHomeSettings callHomeSettings, bool suppressHistory)
: base(pool.Connection, Messages.ACTION_SAVE_CALLHOME_SETTINGS, string.Format(Messages.ACTION_SAVING_CALLHOME_SETTINGS, pool.Name), suppressHistory)
{
this.pool = pool;
this.callHomeSettings = callHomeSettings;
}
protected override void Run()
{
Dictionary<string, string> newConfig = callHomeSettings.ToDictionary(pool.gui_config);
Pool.set_gui_config(Connection.Session, pool.opaque_ref, newConfig);
}
}
}

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -78,6 +78,24 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Authentication with Citrix upload server.
/// </summary>
public static string ACTION_CALLHOME_AUTHENTICATION {
get {
return ResourceManager.GetString("ACTION_CALLHOME_AUTHENTICATION", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Authenticating with Citrix upload server.
/// </summary>
public static string ACTION_CALLHOME_AUTHENTICATION_PROGRESS {
get {
return ResourceManager.GetString("ACTION_CALLHOME_AUTHENTICATION_PROGRESS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change disk size.
/// </summary>
@ -1527,6 +1545,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Save Health Check settings.
/// </summary>
public static string ACTION_SAVE_CALLHOME_SETTINGS {
get {
return ResourceManager.GetString("ACTION_SAVE_CALLHOME_SETTINGS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Saving settings....
/// </summary>
@ -1599,6 +1626,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Saving Health Check settings for &apos;{0}&apos;....
/// </summary>
public static string ACTION_SAVING_CALLHOME_SETTINGS {
get {
return ResourceManager.GetString("ACTION_SAVING_CALLHOME_SETTINGS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Saving Custom Fields for &apos;{0}&apos;....
/// </summary>
@ -5733,6 +5769,87 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Authentication with Citrix upload server is required in order to enable this feature. XenCenter detected a previous successful authentication for one of other connected pools. You can choose to re-use it or authenticate again..
/// </summary>
public static string CALLHOME_AUTHENTICATION_RUBRIC_EXISTING_TOKEN {
get {
return ResourceManager.GetString("CALLHOME_AUTHENTICATION_RUBRIC_EXISTING_TOKEN", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Authentication with Citrix upload server is required in order to enable this feature. Please register by providing MyCitrix credentials. These credentials will only be used to obtain a Call Home upload grant token and will not be stored on this machine or on your server..
/// </summary>
public static string CALLHOME_AUTHENTICATION_RUBRIC_NO_TOKEN {
get {
return ResourceManager.GetString("CALLHOME_AUTHENTICATION_RUBRIC_NO_TOKEN", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to OK, Enable Health Check.
/// </summary>
public static string CALLHOME_ENROLLMENT_CONFIRMATION_BUTTON_LABEL {
get {
return ResourceManager.GetString("CALLHOME_ENROLLMENT_CONFIRMATION_BUTTON_LABEL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Health Check Enrollment - {0}.
/// </summary>
public static string CALLHOME_ENROLLMENT_TITLE {
get {
return ResourceManager.GetString("CALLHOME_ENROLLMENT_TITLE", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Upload a Health Check report every {0} weeks on {1} starting at {2}.
/// </summary>
public static string CALLHOME_SCHEDULE_DESCRIPTION {
get {
return ResourceManager.GetString("CALLHOME_SCHEDULE_DESCRIPTION", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Issues found.
/// </summary>
public static string CALLHOME_STATUS_ISSUES_FOUND {
get {
return ResourceManager.GetString("CALLHOME_STATUS_ISSUES_FOUND", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No issues found.
/// </summary>
public static string CALLHOME_STATUS_NO_ISSUES_FOUND {
get {
return ResourceManager.GetString("CALLHOME_STATUS_NO_ISSUES_FOUND", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Analysis not yet available.
/// </summary>
public static string CALLHOME_STATUS_NOT_AVAILABLE_YET {
get {
return ResourceManager.GetString("CALLHOME_STATUS_NOT_AVAILABLE_YET", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Health Check not enabled.
/// </summary>
public static string CALLHOME_STATUS_NOT_ENROLLED {
get {
return ResourceManager.GetString("CALLHOME_STATUS_NOT_ENROLLED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>

View File

@ -123,6 +123,12 @@
<data name="ACTION_ACTIVATING_MULTIPLE_VDIS_TITLE" xml:space="preserve">
<value>Activating Multiple Virtual Disks</value>
</data>
<data name="ACTION_CALLHOME_AUTHENTICATION" xml:space="preserve">
<value>Authentication with Citrix upload server</value>
</data>
<data name="ACTION_CALLHOME_AUTHENTICATION_PROGRESS" xml:space="preserve">
<value>Authenticating with Citrix upload server</value>
</data>
<data name="ACTION_CHANGED_DISK_SIZE_FOR" xml:space="preserve">
<value>Disk size changed for '{0}'.</value>
</data>
@ -606,6 +612,9 @@
<data name="ACTION_SAVE_ALERTS" xml:space="preserve">
<value>Save alerts</value>
</data>
<data name="ACTION_SAVE_CALLHOME_SETTINGS" xml:space="preserve">
<value>Save Health Check settings</value>
</data>
<data name="ACTION_SAVE_CHANGES_IN_PROGRESS" xml:space="preserve">
<value>Saving settings...</value>
</data>
@ -630,6 +639,9 @@
<data name="ACTION_SAVING_ALERTS_FOR" xml:space="preserve">
<value>Saving alerts for '{0}'...</value>
</data>
<data name="ACTION_SAVING_CALLHOME_SETTINGS" xml:space="preserve">
<value>Saving Health Check settings for '{0}'...</value>
</data>
<data name="ACTION_SAVING_CUSTOM_FIELDS_FOR" xml:space="preserve">
<value>Saving Custom Fields for '{0}'...</value>
</data>
@ -2088,6 +2100,33 @@ Deleting this bond will disrupt traffic through the secondary interface on the b
<data name="CACHE_NOT_YET_POPULATED" xml:space="preserve">
<value>Cache not yet populated</value>
</data>
<data name="CALLHOME_AUTHENTICATION_RUBRIC_EXISTING_TOKEN" xml:space="preserve">
<value>Authentication with Citrix upload server is required in order to enable this feature. XenCenter detected a previous successful authentication for one of other connected pools. You can choose to re-use it or authenticate again.</value>
</data>
<data name="CALLHOME_AUTHENTICATION_RUBRIC_NO_TOKEN" xml:space="preserve">
<value>Authentication with Citrix upload server is required in order to enable this feature. Please register by providing MyCitrix credentials. These credentials will only be used to obtain a Call Home upload grant token and will not be stored on this machine or on your server.</value>
</data>
<data name="CALLHOME_ENROLLMENT_CONFIRMATION_BUTTON_LABEL" xml:space="preserve">
<value>OK, Enable Health Check</value>
</data>
<data name="CALLHOME_ENROLLMENT_TITLE" xml:space="preserve">
<value>Health Check Enrollment - {0}</value>
</data>
<data name="CALLHOME_SCHEDULE_DESCRIPTION" xml:space="preserve">
<value>Upload a Health Check report every {0} weeks on {1} starting at {2}</value>
</data>
<data name="CALLHOME_STATUS_ISSUES_FOUND" xml:space="preserve">
<value>Issues found</value>
</data>
<data name="CALLHOME_STATUS_NOT_AVAILABLE_YET" xml:space="preserve">
<value>Analysis not yet available</value>
</data>
<data name="CALLHOME_STATUS_NOT_ENROLLED" xml:space="preserve">
<value>Health Check not enabled</value>
</data>
<data name="CALLHOME_STATUS_NO_ISSUES_FOUND" xml:space="preserve">
<value>No issues found</value>
</data>
<data name="CANCEL" xml:space="preserve">
<value>Cancel</value>
</data>

View File

@ -389,7 +389,7 @@ namespace XenAPI
{
get { return Connection.Cache.Hosts.Sum(h => h.CpuSockets); }
}
public bool HasGpu
{
get { return Connection.Cache.PGPUs.Length > 0; }
@ -400,6 +400,16 @@ namespace XenAPI
get { return HasGpu && Connection.Cache.PGPUs.Any(pGpu => pGpu.HasVGpu); }
}
#region CallHome settings
public CallHomeSettings CallHomeSettings
{
get
{
return new CallHomeSettings(gui_config);
}
}
#endregion
#region IEquatable<Pool> Members
/// <summary>
@ -413,4 +423,106 @@ namespace XenAPI
#endregion
}
public enum CallHomeStatus
{
Disabled, Enabled, Undefined
}
public struct CallHomeSettings
{
public CallHomeStatus Status;
public int IntervalInDays, TimeOfDay, RetryInterval;
public DayOfWeek DayOfWeek;
public string AuthenticationToken;
public const int DefaultRetryInterval = 7;
public const string STATUS = "CallHome.Enrollment";
public const string INTERVAL_IN_DAYS = "CallHome.Schedule.IntervalInDays";
public const string DAY_OF_WEEK = "CallHome.Schedule.DayOfWeek";
public const string TIME_OF_DAY = "CallHome.Schedule.TimeOfDay";
public const string RETRY_INTERVAL = "CallHome.Schedule.RetryInterval";
public const string AUTHENTICATION_TOKEN = "CallHome.AuthenticationToken";
public CallHomeSettings(CallHomeStatus status, int intervalInDays, DayOfWeek dayOfWeek, int timeOfDay, int retryInterval, string authenticationToken)
{
Status = status;
IntervalInDays = intervalInDays;
DayOfWeek = dayOfWeek;
TimeOfDay = timeOfDay;
RetryInterval = retryInterval;
AuthenticationToken = authenticationToken;
}
public CallHomeSettings(Dictionary<string, string> config)
{
Status = config == null || !config.ContainsKey(STATUS)
? CallHomeStatus.Undefined
: (BoolKey(config, STATUS) ? CallHomeStatus.Enabled : CallHomeStatus.Disabled);
IntervalInDays = IntKey(config, INTERVAL_IN_DAYS, 14);
if (!Enum.TryParse(Get(config, DAY_OF_WEEK), out DayOfWeek))
DayOfWeek = (DayOfWeek) GetDefaultDay();
TimeOfDay = IntKey(config, TIME_OF_DAY, GetDefaultTime());
RetryInterval = IntKey(config, RETRY_INTERVAL, 7);
AuthenticationToken = Get(config, AUTHENTICATION_TOKEN);
}
public Dictionary<string, string> ToDictionary(Dictionary<string, string> baseDictionary)
{
var newConfig = baseDictionary == null ? new Dictionary<string, string>() : new Dictionary<string, string>(baseDictionary);
newConfig[STATUS] = Status == CallHomeStatus.Enabled ? "true" : "false";
newConfig[INTERVAL_IN_DAYS] = IntervalInDays.ToString();
var day = (int) DayOfWeek;
newConfig[DAY_OF_WEEK] = day.ToString();
newConfig[TIME_OF_DAY] = TimeOfDay.ToString();
newConfig[RETRY_INTERVAL] = RetryInterval.ToString();
newConfig[AUTHENTICATION_TOKEN] = AuthenticationToken;
return newConfig;
}
public int IntervalInWeeks { get { return IntervalInDays / 7; } }
public string StatusDescription
{
get
{
return Status == CallHomeStatus.Enabled
? Messages.CALLHOME_STATUS_NOT_AVAILABLE_YET
: Messages.CALLHOME_STATUS_NOT_ENROLLED;
}
}
#region Helper functions
private static T Get<T>(Dictionary<string, T> d, string k) where T : class
{
return d != null && d.ContainsKey(k) ? d[k] : null;
}
private static bool BoolKey(Dictionary<string, string> d, string k)
{
string v = Get(d, k);
return v == null ? false : v == "true";
}
private static int IntKey(Dictionary<string, string> d, string k, int def)
{
int result;
string s = Get(d, k);
return s != null && int.TryParse(s, out result) ? result : def;
}
private static int GetDefaultDay()
{
return new Random().Next(1, 7);
}
private static int GetDefaultTime()
{
return new Random().Next(0, 23);
}
#endregion
}
}

View File

@ -55,6 +55,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Actions\Action.cs" />
<Compile Include="Actions\CallHome\CallHomeAuthenticationAction.cs" />
<Compile Include="Actions\CallHome\SaveCallHomeSettingsAction.cs" />
<Compile Include="Actions\CancellingAction.cs" />
<Compile Include="Actions\DockerContainer\DockerContainerLifetimeAction.cs" />
<Compile Include="Actions\DockerContainer\ExecuteContainerPluginAction.cs" />