mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
Merge pull request #532 from MihaelaStoica/CallHome
CP-12890: Allow user to specify XenServer credentials AND some other fixes
This commit is contained in:
commit
66c57c4fce
@ -39,13 +39,14 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
this.poolNameLabel = new System.Windows.Forms.Label();
|
||||
this.poolDetailsPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.healthCheckStatusPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.uploadRequestLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.scheduleLabel = new System.Windows.Forms.Label();
|
||||
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
|
||||
this.issuesLabel = new System.Windows.Forms.Label();
|
||||
this.lastUploadDateLabel = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.lastUploadLabel = new System.Windows.Forms.Label();
|
||||
this.ReportAnalysisLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.previousUploadPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
|
||||
@ -60,7 +61,6 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
this.policyStatementLabel = new System.Windows.Forms.Label();
|
||||
this.PolicyStatementLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.rubricLabel = new System.Windows.Forms.Label();
|
||||
this.uploadRequestLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
@ -151,11 +151,19 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
this.healthCheckStatusPanel.Controls.Add(this.lastUploadDateLabel, 1, 1);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.label4, 0, 5);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.label1, 0, 0);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.label2, 0, 1);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.lastUploadLabel, 0, 1);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.ReportAnalysisLinkLabel, 0, 3);
|
||||
this.healthCheckStatusPanel.Controls.Add(this.previousUploadPanel, 0, 4);
|
||||
this.healthCheckStatusPanel.Name = "healthCheckStatusPanel";
|
||||
//
|
||||
// uploadRequestLinkLabel
|
||||
//
|
||||
resources.ApplyResources(this.uploadRequestLinkLabel, "uploadRequestLinkLabel");
|
||||
this.healthCheckStatusPanel.SetColumnSpan(this.uploadRequestLinkLabel, 2);
|
||||
this.uploadRequestLinkLabel.Name = "uploadRequestLinkLabel";
|
||||
this.uploadRequestLinkLabel.TabStop = true;
|
||||
this.uploadRequestLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.uploadRequestLinkLabel_LinkClicked);
|
||||
//
|
||||
// scheduleLabel
|
||||
//
|
||||
resources.ApplyResources(this.scheduleLabel, "scheduleLabel");
|
||||
@ -193,10 +201,10 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
this.healthCheckStatusPanel.SetColumnSpan(this.label1, 2);
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// label2
|
||||
// lastUploadLabel
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.Name = "label2";
|
||||
resources.ApplyResources(this.lastUploadLabel, "lastUploadLabel");
|
||||
this.lastUploadLabel.Name = "lastUploadLabel";
|
||||
//
|
||||
// ReportAnalysisLinkLabel
|
||||
//
|
||||
@ -290,14 +298,6 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
resources.ApplyResources(this.rubricLabel, "rubricLabel");
|
||||
this.rubricLabel.Name = "rubricLabel";
|
||||
//
|
||||
// uploadRequestLinkLabel
|
||||
//
|
||||
resources.ApplyResources(this.uploadRequestLinkLabel, "uploadRequestLinkLabel");
|
||||
this.healthCheckStatusPanel.SetColumnSpan(this.uploadRequestLinkLabel, 2);
|
||||
this.uploadRequestLinkLabel.Name = "uploadRequestLinkLabel";
|
||||
this.uploadRequestLinkLabel.TabStop = true;
|
||||
this.uploadRequestLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.uploadRequestLinkLabel_LinkClicked);
|
||||
//
|
||||
// CallHomeOverviewDialog
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
@ -346,7 +346,7 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
private System.Windows.Forms.Label issuesLabel;
|
||||
private System.Windows.Forms.Label lastUploadDateLabel;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label lastUploadLabel;
|
||||
private System.Windows.Forms.LinkLabel ReportAnalysisLinkLabel;
|
||||
private System.Windows.Forms.TableLayoutPanel previousUploadPanel;
|
||||
private System.Windows.Forms.Label label3;
|
||||
|
@ -188,6 +188,8 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
||||
poolNameLabel.Text = poolRow.Pool.Name.Ellipsise(120);
|
||||
scheduleLabel.Text = GetScheduleDescription(poolRow.Pool.CallHomeSettings);
|
||||
lastUploadLabel.Visible = lastUploadDateLabel.Visible = !string.IsNullOrEmpty(poolRow.Pool.CallHomeSettings.LastSuccessfulUpload);
|
||||
lastUploadDateLabel.Text = GetLastUploadDescription(poolRow.Pool.CallHomeSettings);
|
||||
|
||||
healthCheckStatusPanel.Visible = poolRow.Pool.CallHomeSettings.Status == CallHomeStatus.Enabled;
|
||||
notEnrolledPanel.Visible = poolRow.Pool.CallHomeSettings.Status != CallHomeStatus.Enabled;
|
||||
@ -208,11 +210,11 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
public void UpdateUploadRequestDescription(CallHomeSettings callHomeSettings)
|
||||
{
|
||||
{
|
||||
double uploadRequest;
|
||||
if (!callHomeSettings.CanRequestNewUpload && double.TryParse(callHomeSettings.NewUploadRequest, out uploadRequest))
|
||||
if (!callHomeSettings.CanRequestNewUpload)
|
||||
{
|
||||
uploadRequestLinkLabel.Text = string.Format(Messages.HEALTHCHECK_ON_DEMAND_REQUESTED_AT,
|
||||
HelpersGUI.DateTimeToString(Util.FromUnixTime(uploadRequest), Messages.DATEFORMAT_HM, true));
|
||||
uploadRequestLinkLabel.Text = string.Format(Messages.HEALTHCHECK_ON_DEMAND_REQUESTED_AT,
|
||||
HelpersGUI.DateTimeToString(callHomeSettings.NewUploadRequestTime.ToLocalTime(),
|
||||
Messages.DATEFORMAT_HM, true));
|
||||
uploadRequestLinkLabel.LinkArea = new LinkArea(0, 0);
|
||||
return;
|
||||
}
|
||||
@ -221,6 +223,19 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
}
|
||||
}
|
||||
|
||||
public string GetLastUploadDescription(CallHomeSettings callHomeSettings)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(callHomeSettings.LastSuccessfulUpload))
|
||||
{
|
||||
DateTime lastSuccessfulUpload;
|
||||
if (CallHomeSettings.TryParseStringToDateTime(callHomeSettings.LastSuccessfulUpload, out lastSuccessfulUpload))
|
||||
{
|
||||
return HelpersGUI.DateTimeToString(lastSuccessfulUpload.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private void CallHomeOverview_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadPools();
|
||||
@ -255,7 +270,7 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
return;
|
||||
|
||||
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
||||
new CallHomeSettingsDialog(poolRow.Pool).ShowDialog(this);
|
||||
new CallHomeSettingsDialog(poolRow.Pool, false).ShowDialog(this);
|
||||
}
|
||||
|
||||
public DialogResult ShowDialog(IWin32Window parent, List<IXenObject> selectedItems)
|
||||
@ -283,25 +298,7 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
return;
|
||||
|
||||
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
||||
var callHomeSettings = poolRow.Pool.CallHomeSettings;
|
||||
if (callHomeSettings.Status != CallHomeStatus.Enabled)
|
||||
{
|
||||
// try to enroll into call home with the default settings, if authentication is not required
|
||||
var token = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET);
|
||||
var user = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET);
|
||||
var password = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
||||
if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password))
|
||||
{
|
||||
callHomeSettings.Status = CallHomeStatus.Enabled;
|
||||
new SaveCallHomeSettingsAction(poolRow.Pool, callHomeSettings, token, user, password, false).RunAsync();
|
||||
new TransferCallHomeSettingsAction(poolRow.Pool, callHomeSettings, user, password, true).RunAsync();
|
||||
return;
|
||||
}
|
||||
new CallHomeEnrollNowDialog(poolRow.Pool).ShowDialog(this);
|
||||
return;
|
||||
}
|
||||
|
||||
new CallHomeSettingsDialog(poolRow.Pool).ShowDialog(this);
|
||||
new CallHomeSettingsDialog(poolRow.Pool, true).ShowDialog(this);
|
||||
}
|
||||
|
||||
private void uploadRequestLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
@ -314,7 +311,10 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
if (callHomeSettings.CanRequestNewUpload)
|
||||
{
|
||||
callHomeSettings.NewUploadRequest = CallHomeSettings.DateTimeToString(DateTime.UtcNow);
|
||||
new SaveCallHomeSettingsAction(poolRow.Pool, callHomeSettings, null, null, null, false).RunAsync();
|
||||
var token = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET);
|
||||
var user = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET);
|
||||
var password = callHomeSettings.GetSecretyInfo(poolRow.Pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
||||
new SaveCallHomeSettingsAction(poolRow.Pool, callHomeSettings, token, user, password, false).RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -504,40 +504,40 @@
|
||||
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
|
||||
<data name="lastUploadLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="label2.Font" type="System.Drawing.Font, System.Drawing">
|
||||
<data name="lastUploadLabel.Font" type="System.Drawing.Font, System.Drawing">
|
||||
<value>Segoe UI, 9pt</value>
|
||||
</data>
|
||||
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<data name="lastUploadLabel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 24</value>
|
||||
</data>
|
||||
<data name="label2.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<data name="lastUploadLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<value>3, 3, 3, 3</value>
|
||||
</data>
|
||||
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="lastUploadLabel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>131, 15</value>
|
||||
</data>
|
||||
<data name="label2.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="lastUploadLabel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<data name="lastUploadLabel.Text" xml:space="preserve">
|
||||
<value>Last successful upload: </value>
|
||||
</data>
|
||||
<data name="label2.Visible" type="System.Boolean, mscorlib">
|
||||
<data name="lastUploadLabel.Visible" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
<data name=">>lastUploadLabel.Name" xml:space="preserve">
|
||||
<value>lastUploadLabel</value>
|
||||
</data>
|
||||
<data name=">>label2.Type" xml:space="preserve">
|
||||
<data name=">>lastUploadLabel.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>label2.Parent" xml:space="preserve">
|
||||
<data name=">>lastUploadLabel.Parent" xml:space="preserve">
|
||||
<value>healthCheckStatusPanel</value>
|
||||
</data>
|
||||
<data name=">>label2.ZOrder" xml:space="preserve">
|
||||
<data name=">>lastUploadLabel.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="ReportAnalysisLinkLabel.AutoSize" type="System.Boolean, mscorlib">
|
||||
@ -757,7 +757,7 @@
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="healthCheckStatusPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="uploadRequestLinkLabel" Row="8" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="scheduleLabel" Row="6" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="linkLabel2" Row="7" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="issuesLabel" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="lastUploadDateLabel" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label4" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="ReportAnalysisLinkLabel" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="previousUploadPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,50,AutoSize,50,AutoSize,20,AutoSize,20,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings></value>
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="uploadRequestLinkLabel" Row="8" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="scheduleLabel" Row="6" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="linkLabel2" Row="7" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="issuesLabel" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="lastUploadDateLabel" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label4" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="lastUploadLabel" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="ReportAnalysisLinkLabel" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="previousUploadPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,50,AutoSize,50,AutoSize,20,AutoSize,20,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings></value>
|
||||
</data>
|
||||
<data name="notEnrolledPanel.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -46,16 +46,18 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
private bool authenticationRequired;
|
||||
private bool authenticated;
|
||||
private string authenticationToken;
|
||||
private string usetName;
|
||||
private string password;
|
||||
private string xsUserName;
|
||||
private string xsPassword;
|
||||
|
||||
public CallHomeSettingsDialog(Pool pool)
|
||||
public CallHomeSettingsDialog(Pool pool, bool enrollNow)
|
||||
{
|
||||
this.pool = pool;
|
||||
callHomeSettings = pool.CallHomeSettings;
|
||||
if (enrollNow)
|
||||
callHomeSettings.Status = CallHomeStatus.Enabled;
|
||||
authenticationToken = callHomeSettings.GetExistingSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET);
|
||||
usetName = callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET);
|
||||
password = callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
||||
xsUserName = callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET);
|
||||
xsPassword = callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
||||
InitializeComponent();
|
||||
PopulateControls();
|
||||
InitializeControls();
|
||||
@ -113,10 +115,15 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
frequencyNumericBox.Value = callHomeSettings.IntervalInWeeks;
|
||||
dayOfWeekComboBox.SelectedValue = (int)callHomeSettings.DayOfWeek;
|
||||
timeOfDayComboBox.SelectedValue = callHomeSettings.TimeOfDay;
|
||||
|
||||
existingAuthenticationRadioButton.Enabled = existingAuthenticationRadioButton.Checked = !authenticationRequired;
|
||||
newAuthenticationRadioButton.Checked = authenticationRequired;
|
||||
callHomeAuthenticationPanel1.Enabled = newAuthenticationRadioButton.Checked;
|
||||
callHomeAuthenticationPanel1.Pool = pool;
|
||||
SetMyCitrixCredentials(existingAuthenticationRadioButton.Checked);
|
||||
|
||||
bool useCurrentXsCredentials = string.IsNullOrEmpty(xsUserName) || xsUserName == pool.Connection.Username;
|
||||
newXsCredentialsRadioButton.Checked = !useCurrentXsCredentials;
|
||||
currentXsCredentialsRadioButton.Checked = useCurrentXsCredentials;
|
||||
SetXSCredentials(currentXsCredentialsRadioButton.Checked);
|
||||
}
|
||||
|
||||
private bool ChangesMade()
|
||||
@ -133,35 +140,41 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
return true;
|
||||
if (authenticationToken != callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET))
|
||||
return true;
|
||||
if (usetName != callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET))
|
||||
if (textboxXSUserName.Text != xsUserName)
|
||||
return true;
|
||||
if (password != callHomeSettings.GetSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET))
|
||||
if (textboxXSPassword.Text != xsPassword)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UpdateButtons()
|
||||
{
|
||||
okButton.Enabled = !enrollmentCheckBox.Checked || authenticated;
|
||||
okButton.Text = callHomeSettings.Status == CallHomeStatus.Enabled || !enrollmentCheckBox.Checked
|
||||
? Messages.OK
|
||||
: Messages.CALLHOME_ENROLLMENT_CONFIRMATION_BUTTON_LABEL;
|
||||
okButton.Enabled = m_ctrlError.PerformCheck(CheckCredentialsEntered);
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
okButton.Enabled = false;
|
||||
if (enrollmentCheckBox.Checked && newAuthenticationRadioButton.Checked
|
||||
&& !m_ctrlError.PerformCheck(CheckUploadAuthentication))
|
||||
{
|
||||
okButton.Enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChangesMade())
|
||||
{
|
||||
var newCallHomeSettings = new CallHomeSettings(
|
||||
enrollmentCheckBox.Checked ? CallHomeStatus.Enabled : CallHomeStatus.Disabled,
|
||||
(int) (frequencyNumericBox.Value * 7),
|
||||
(DayOfWeek) dayOfWeekComboBox.SelectedValue,
|
||||
(int) timeOfDayComboBox.SelectedValue,
|
||||
(int)(frequencyNumericBox.Value * 7),
|
||||
(DayOfWeek)dayOfWeekComboBox.SelectedValue,
|
||||
(int)timeOfDayComboBox.SelectedValue,
|
||||
CallHomeSettings.DefaultRetryInterval);
|
||||
|
||||
new SaveCallHomeSettingsAction(pool, newCallHomeSettings, authenticationToken, usetName, password, false).RunAsync();
|
||||
new TransferCallHomeSettingsAction(pool, newCallHomeSettings, usetName, password, true).RunAsync();
|
||||
new SaveCallHomeSettingsAction(pool, newCallHomeSettings, authenticationToken, textboxXSUserName.Text, textboxXSPassword.Text, false).RunAsync();
|
||||
new TransferCallHomeSettingsAction(pool, newCallHomeSettings, textboxXSUserName.Text, textboxXSPassword.Text, true).RunAsync();
|
||||
}
|
||||
okButton.Enabled = true;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
@ -177,23 +190,105 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void callHomeAuthenticationPanel1_AuthenticationChanged(object sender, EventArgs e)
|
||||
{
|
||||
Program.Invoke(this, delegate
|
||||
{
|
||||
if (callHomeAuthenticationPanel1.Authenticated)
|
||||
{
|
||||
authenticated = true;
|
||||
authenticationToken = pool.CallHomeSettings.GetExistingSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET);
|
||||
}
|
||||
UpdateButtons();
|
||||
});
|
||||
}
|
||||
|
||||
private void newAuthenticationRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
callHomeAuthenticationPanel1.Enabled = newAuthenticationRadioButton.Checked;
|
||||
authenticated = existingAuthenticationRadioButton.Checked || callHomeAuthenticationPanel1.Authenticated;
|
||||
SetMyCitrixCredentials(existingAuthenticationRadioButton.Checked);
|
||||
}
|
||||
|
||||
private void radioButton2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetXSCredentials(currentXsCredentialsRadioButton.Checked);
|
||||
}
|
||||
|
||||
private void SetXSCredentials(bool useCurrent)
|
||||
{
|
||||
if (useCurrent)
|
||||
{
|
||||
textboxXSUserName.Text = pool.Connection.Username;
|
||||
textboxXSPassword.Text = pool.Connection.Password;
|
||||
textboxXSUserName.Enabled = false;
|
||||
textboxXSPassword.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
textboxXSUserName.Text = xsUserName;
|
||||
textboxXSPassword.Text = xsPassword;
|
||||
textboxXSUserName.Enabled = true;
|
||||
textboxXSPassword.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMyCitrixCredentials(bool useExisting)
|
||||
{
|
||||
if (useExisting)
|
||||
{
|
||||
//textBoxMyCitrixUsername.Text = String.Empty;
|
||||
//textBoxMyCitrixPassword.Text = String.Empty;
|
||||
textBoxMyCitrixUsername.Enabled = false;
|
||||
textBoxMyCitrixPassword.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//textBoxMyCitrixUsername.Text = String.Empty;
|
||||
//textBoxMyCitrixPassword.Text = String.Empty;
|
||||
textBoxMyCitrixUsername.Enabled = true;
|
||||
textBoxMyCitrixPassword.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckCredentialsEntered()
|
||||
{
|
||||
if (!enrollmentCheckBox.Checked || !newAuthenticationRadioButton.Checked)
|
||||
return true;
|
||||
|
||||
if (newAuthenticationRadioButton.Checked &&
|
||||
(string.IsNullOrEmpty(textBoxMyCitrixUsername.Text) || string.IsNullOrEmpty(textBoxMyCitrixPassword.Text)))
|
||||
return false;
|
||||
|
||||
if (newXsCredentialsRadioButton.Checked &&
|
||||
(string.IsNullOrEmpty(textboxXSUserName.Text) || string.IsNullOrEmpty(textboxXSPassword.Text)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckCredentialsEntered(out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
return CheckCredentialsEntered();
|
||||
}
|
||||
|
||||
private bool CheckUploadAuthentication(out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
|
||||
if (!CheckCredentialsEntered())
|
||||
return false;
|
||||
|
||||
var action = new CallHomeAuthenticationAction(pool, textBoxMyCitrixUsername.Text.Trim(), textBoxMyCitrixPassword.Text.Trim(),
|
||||
Registry.CallHomeIdentityTokenDomainName, Registry.CallHomeUploadGrantTokenDomainName, Registry.CallHomeUploadTokenDomainName,
|
||||
true, 0, false);
|
||||
|
||||
try
|
||||
{
|
||||
action.RunExternal(null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = action.Exception != null ? action.Exception.Message : Messages.ERROR_UNKNOWN;
|
||||
authenticationToken = null;
|
||||
authenticated = false;
|
||||
return authenticated;
|
||||
}
|
||||
|
||||
authenticationToken = action.UploadToken; // curent upload token
|
||||
authenticated = !string.IsNullOrEmpty(authenticationToken);
|
||||
authenticationToken = pool.CallHomeSettings.GetExistingSecretyInfo(pool.Connection, CallHomeSettings.UPLOAD_TOKEN_SECRET);
|
||||
return authenticated;
|
||||
}
|
||||
|
||||
private void credentials_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateButtons();
|
||||
}
|
||||
}
|
||||
|
@ -29,161 +29,92 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
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.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.decentGroupBox2 = new XenAdmin.Controls.DecentGroupBox();
|
||||
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.frequencyLabel = new System.Windows.Forms.Label();
|
||||
this.frequencyNumericBox = new System.Windows.Forms.NumericUpDown();
|
||||
this.weeksLabel = new System.Windows.Forms.Label();
|
||||
this.dayOfweekLabel = new System.Windows.Forms.Label();
|
||||
this.timeOfDayLabel = new System.Windows.Forms.Label();
|
||||
this.timeOfDayComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.dayOfWeekComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.decentGroupBox1 = new XenAdmin.Controls.DecentGroupBox();
|
||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.m_ctrlError = new XenAdmin.Controls.Common.PasswordFailure();
|
||||
this.authenticationRubricLabel = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBoxMyCitrixPassword = new System.Windows.Forms.TextBox();
|
||||
this.textBoxMyCitrixUsername = new System.Windows.Forms.TextBox();
|
||||
this.existingAuthenticationRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.newAuthenticationRadioButton = new System.Windows.Forms.RadioButton();
|
||||
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.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
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.callHomeAuthenticationPanel1 = new XenAdmin.Controls.CallHomeAuthenticationPanel();
|
||||
this.decentGroupBoxXSCredentials = new XenAdmin.Controls.DecentGroupBox();
|
||||
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.textboxXSPassword = new System.Windows.Forms.TextBox();
|
||||
this.textboxXSUserName = new System.Windows.Forms.TextBox();
|
||||
this.currentXsCredentialsRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.newXsCredentialsRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.decentGroupBox2.SuspendLayout();
|
||||
this.tableLayoutPanel4.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).BeginInit();
|
||||
this.decentGroupBox1.SuspendLayout();
|
||||
this.tableLayoutPanel2.SuspendLayout();
|
||||
this.flowLayoutPanel2.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).BeginInit();
|
||||
this.decentGroupBoxXSCredentials.SuspendLayout();
|
||||
this.tableLayoutPanel3.SuspendLayout();
|
||||
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.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.decentGroupBox2, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.decentGroupBox1, 0, 8);
|
||||
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.callHomeAuthenticationPanel1, 2, 17);
|
||||
this.tableLayoutPanel1.Controls.Add(this.m_ctrlError, 0, 9);
|
||||
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 10);
|
||||
this.tableLayoutPanel1.Controls.Add(this.enrollmentCheckBox, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.decentGroupBoxXSCredentials, 0, 7);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
//
|
||||
// authenticationRubricLabel
|
||||
// decentGroupBox2
|
||||
//
|
||||
resources.ApplyResources(this.authenticationRubricLabel, "authenticationRubricLabel");
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.authenticationRubricLabel, 4);
|
||||
this.authenticationRubricLabel.Name = "authenticationRubricLabel";
|
||||
resources.ApplyResources(this.decentGroupBox2, "decentGroupBox2");
|
||||
this.decentGroupBox2.Controls.Add(this.tableLayoutPanel4);
|
||||
this.decentGroupBox2.Name = "decentGroupBox2";
|
||||
this.decentGroupBox2.TabStop = false;
|
||||
//
|
||||
// authenticationLabel
|
||||
// tableLayoutPanel4
|
||||
//
|
||||
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";
|
||||
resources.ApplyResources(this.tableLayoutPanel4, "tableLayoutPanel4");
|
||||
this.tableLayoutPanel4.Controls.Add(this.frequencyLabel, 0, 0);
|
||||
this.tableLayoutPanel4.Controls.Add(this.frequencyNumericBox, 1, 0);
|
||||
this.tableLayoutPanel4.Controls.Add(this.weeksLabel, 2, 0);
|
||||
this.tableLayoutPanel4.Controls.Add(this.dayOfweekLabel, 0, 2);
|
||||
this.tableLayoutPanel4.Controls.Add(this.timeOfDayLabel, 0, 1);
|
||||
this.tableLayoutPanel4.Controls.Add(this.timeOfDayComboBox, 1, 1);
|
||||
this.tableLayoutPanel4.Controls.Add(this.dayOfWeekComboBox, 1, 2);
|
||||
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
|
||||
//
|
||||
// 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");
|
||||
@ -204,18 +135,95 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// weeksLabel
|
||||
//
|
||||
resources.ApplyResources(this.weeksLabel, "weeksLabel");
|
||||
this.weeksLabel.Name = "weeksLabel";
|
||||
//
|
||||
// dayOfweekLabel
|
||||
//
|
||||
resources.ApplyResources(this.dayOfweekLabel, "dayOfweekLabel");
|
||||
this.dayOfweekLabel.Name = "dayOfweekLabel";
|
||||
//
|
||||
// timeOfDayLabel
|
||||
//
|
||||
resources.ApplyResources(this.timeOfDayLabel, "timeOfDayLabel");
|
||||
this.timeOfDayLabel.Name = "timeOfDayLabel";
|
||||
//
|
||||
// timeOfDayComboBox
|
||||
//
|
||||
this.tableLayoutPanel4.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";
|
||||
//
|
||||
// dayOfWeekComboBox
|
||||
//
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.dayOfWeekComboBox, 2);
|
||||
this.tableLayoutPanel4.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";
|
||||
//
|
||||
// decentGroupBox1
|
||||
//
|
||||
resources.ApplyResources(this.decentGroupBox1, "decentGroupBox1");
|
||||
this.decentGroupBox1.Controls.Add(this.tableLayoutPanel2);
|
||||
this.decentGroupBox1.Name = "decentGroupBox1";
|
||||
this.decentGroupBox1.TabStop = false;
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
resources.ApplyResources(this.tableLayoutPanel2, "tableLayoutPanel2");
|
||||
this.tableLayoutPanel2.Controls.Add(this.authenticationRubricLabel, 0, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.label1, 0, 3);
|
||||
this.tableLayoutPanel2.Controls.Add(this.label2, 0, 4);
|
||||
this.tableLayoutPanel2.Controls.Add(this.textBoxMyCitrixPassword, 1, 4);
|
||||
this.tableLayoutPanel2.Controls.Add(this.textBoxMyCitrixUsername, 1, 3);
|
||||
this.tableLayoutPanel2.Controls.Add(this.existingAuthenticationRadioButton, 0, 1);
|
||||
this.tableLayoutPanel2.Controls.Add(this.newAuthenticationRadioButton, 0, 2);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
//
|
||||
// m_ctrlError
|
||||
//
|
||||
resources.ApplyResources(this.m_ctrlError, "m_ctrlError");
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.m_ctrlError, 3);
|
||||
this.m_ctrlError.Name = "m_ctrlError";
|
||||
//
|
||||
// authenticationRubricLabel
|
||||
//
|
||||
resources.ApplyResources(this.authenticationRubricLabel, "authenticationRubricLabel");
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.authenticationRubricLabel, 4);
|
||||
this.authenticationRubricLabel.Name = "authenticationRubricLabel";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// textBoxMyCitrixPassword
|
||||
//
|
||||
resources.ApplyResources(this.textBoxMyCitrixPassword, "textBoxMyCitrixPassword");
|
||||
this.textBoxMyCitrixPassword.Name = "textBoxMyCitrixPassword";
|
||||
this.textBoxMyCitrixPassword.UseSystemPasswordChar = true;
|
||||
this.textBoxMyCitrixPassword.TextChanged += new System.EventHandler(this.credentials_TextChanged);
|
||||
//
|
||||
// textBoxMyCitrixUsername
|
||||
//
|
||||
resources.ApplyResources(this.textBoxMyCitrixUsername, "textBoxMyCitrixUsername");
|
||||
this.textBoxMyCitrixUsername.Name = "textBoxMyCitrixUsername";
|
||||
this.textBoxMyCitrixUsername.TextChanged += new System.EventHandler(this.credentials_TextChanged);
|
||||
//
|
||||
// existingAuthenticationRadioButton
|
||||
//
|
||||
resources.ApplyResources(this.existingAuthenticationRadioButton, "existingAuthenticationRadioButton");
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.existingAuthenticationRadioButton, 4);
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.existingAuthenticationRadioButton, 2);
|
||||
this.existingAuthenticationRadioButton.Name = "existingAuthenticationRadioButton";
|
||||
this.existingAuthenticationRadioButton.TabStop = true;
|
||||
this.existingAuthenticationRadioButton.UseVisualStyleBackColor = true;
|
||||
@ -223,20 +231,128 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
// newAuthenticationRadioButton
|
||||
//
|
||||
resources.ApplyResources(this.newAuthenticationRadioButton, "newAuthenticationRadioButton");
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.newAuthenticationRadioButton, 4);
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.newAuthenticationRadioButton, 2);
|
||||
this.newAuthenticationRadioButton.Name = "newAuthenticationRadioButton";
|
||||
this.newAuthenticationRadioButton.TabStop = true;
|
||||
this.newAuthenticationRadioButton.UseVisualStyleBackColor = true;
|
||||
this.newAuthenticationRadioButton.CheckedChanged += new System.EventHandler(this.newAuthenticationRadioButton_CheckedChanged);
|
||||
//
|
||||
// callHomeAuthenticationPanel1
|
||||
// flowLayoutPanel2
|
||||
//
|
||||
resources.ApplyResources(this.callHomeAuthenticationPanel1, "callHomeAuthenticationPanel1");
|
||||
this.callHomeAuthenticationPanel1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.callHomeAuthenticationPanel1, 3);
|
||||
this.callHomeAuthenticationPanel1.Name = "callHomeAuthenticationPanel1";
|
||||
this.callHomeAuthenticationPanel1.Pool = null;
|
||||
this.callHomeAuthenticationPanel1.AuthenticationChanged += new System.EventHandler(this.callHomeAuthenticationPanel1_AuthenticationChanged);
|
||||
resources.ApplyResources(this.flowLayoutPanel2, "flowLayoutPanel2");
|
||||
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;
|
||||
//
|
||||
// rubricLabel
|
||||
//
|
||||
resources.ApplyResources(this.rubricLabel, "rubricLabel");
|
||||
this.rubricLabel.Name = "rubricLabel";
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
resources.ApplyResources(this.flowLayoutPanel1, "flowLayoutPanel1");
|
||||
this.flowLayoutPanel1.Controls.Add(this.cancelButton);
|
||||
this.flowLayoutPanel1.Controls.Add(this.okButton);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// enrollmentCheckBox
|
||||
//
|
||||
resources.ApplyResources(this.enrollmentCheckBox, "enrollmentCheckBox");
|
||||
this.enrollmentCheckBox.Name = "enrollmentCheckBox";
|
||||
this.enrollmentCheckBox.UseVisualStyleBackColor = true;
|
||||
this.enrollmentCheckBox.CheckedChanged += new System.EventHandler(this.enrollmentCheckBox_CheckedChanged);
|
||||
//
|
||||
// decentGroupBoxXSCredentials
|
||||
//
|
||||
resources.ApplyResources(this.decentGroupBoxXSCredentials, "decentGroupBoxXSCredentials");
|
||||
this.decentGroupBoxXSCredentials.Controls.Add(this.tableLayoutPanel3);
|
||||
this.decentGroupBoxXSCredentials.Name = "decentGroupBoxXSCredentials";
|
||||
this.decentGroupBoxXSCredentials.TabStop = false;
|
||||
//
|
||||
// tableLayoutPanel3
|
||||
//
|
||||
resources.ApplyResources(this.tableLayoutPanel3, "tableLayoutPanel3");
|
||||
this.tableLayoutPanel3.Controls.Add(this.label3, 0, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label4, 0, 3);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label5, 0, 4);
|
||||
this.tableLayoutPanel3.Controls.Add(this.textboxXSPassword, 1, 4);
|
||||
this.tableLayoutPanel3.Controls.Add(this.textboxXSUserName, 1, 3);
|
||||
this.tableLayoutPanel3.Controls.Add(this.currentXsCredentialsRadioButton, 0, 1);
|
||||
this.tableLayoutPanel3.Controls.Add(this.newXsCredentialsRadioButton, 0, 2);
|
||||
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
resources.ApplyResources(this.label3, "label3");
|
||||
this.tableLayoutPanel3.SetColumnSpan(this.label3, 4);
|
||||
this.label3.Name = "label3";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
resources.ApplyResources(this.label4, "label4");
|
||||
this.label4.Name = "label4";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
resources.ApplyResources(this.label5, "label5");
|
||||
this.label5.Name = "label5";
|
||||
//
|
||||
// textboxXSPassword
|
||||
//
|
||||
resources.ApplyResources(this.textboxXSPassword, "textboxXSPassword");
|
||||
this.textboxXSPassword.Name = "textboxXSPassword";
|
||||
this.textboxXSPassword.UseSystemPasswordChar = true;
|
||||
this.textboxXSPassword.TextChanged += new System.EventHandler(this.credentials_TextChanged);
|
||||
//
|
||||
// textboxXSUserName
|
||||
//
|
||||
resources.ApplyResources(this.textboxXSUserName, "textboxXSUserName");
|
||||
this.textboxXSUserName.Name = "textboxXSUserName";
|
||||
this.textboxXSUserName.TextChanged += new System.EventHandler(this.credentials_TextChanged);
|
||||
//
|
||||
// currentXsCredentialsRadioButton
|
||||
//
|
||||
resources.ApplyResources(this.currentXsCredentialsRadioButton, "currentXsCredentialsRadioButton");
|
||||
this.currentXsCredentialsRadioButton.Checked = true;
|
||||
this.tableLayoutPanel3.SetColumnSpan(this.currentXsCredentialsRadioButton, 2);
|
||||
this.currentXsCredentialsRadioButton.Name = "currentXsCredentialsRadioButton";
|
||||
this.currentXsCredentialsRadioButton.TabStop = true;
|
||||
this.currentXsCredentialsRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// newXsCredentialsRadioButton
|
||||
//
|
||||
resources.ApplyResources(this.newXsCredentialsRadioButton, "newXsCredentialsRadioButton");
|
||||
this.tableLayoutPanel3.SetColumnSpan(this.newXsCredentialsRadioButton, 2);
|
||||
this.newXsCredentialsRadioButton.Name = "newXsCredentialsRadioButton";
|
||||
this.newXsCredentialsRadioButton.UseVisualStyleBackColor = true;
|
||||
this.newXsCredentialsRadioButton.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
|
||||
//
|
||||
// CallHomeSettingsDialog
|
||||
//
|
||||
@ -248,11 +364,23 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
this.Name = "CallHomeSettingsDialog";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.decentGroupBox2.ResumeLayout(false);
|
||||
this.decentGroupBox2.PerformLayout();
|
||||
this.tableLayoutPanel4.ResumeLayout(false);
|
||||
this.tableLayoutPanel4.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).EndInit();
|
||||
this.decentGroupBox1.ResumeLayout(false);
|
||||
this.decentGroupBox1.PerformLayout();
|
||||
this.tableLayoutPanel2.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.PerformLayout();
|
||||
this.flowLayoutPanel2.ResumeLayout(false);
|
||||
this.flowLayoutPanel2.PerformLayout();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.frequencyNumericBox)).EndInit();
|
||||
this.decentGroupBoxXSCredentials.ResumeLayout(false);
|
||||
this.decentGroupBoxXSCredentials.PerformLayout();
|
||||
this.tableLayoutPanel3.ResumeLayout(false);
|
||||
this.tableLayoutPanel3.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -260,27 +388,42 @@ namespace XenAdmin.Dialogs.CallHome
|
||||
|
||||
#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 Controls.DecentGroupBox decentGroupBox2;
|
||||
protected System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
|
||||
private System.Windows.Forms.Label frequencyLabel;
|
||||
private System.Windows.Forms.NumericUpDown frequencyNumericBox;
|
||||
private System.Windows.Forms.Label weeksLabel;
|
||||
private System.Windows.Forms.Label dayOfweekLabel;
|
||||
private System.Windows.Forms.Label timeOfDayLabel;
|
||||
private System.Windows.Forms.ComboBox timeOfDayComboBox;
|
||||
private System.Windows.Forms.ComboBox dayOfWeekComboBox;
|
||||
private Controls.DecentGroupBox decentGroupBox1;
|
||||
protected System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||
private System.Windows.Forms.Label authenticationRubricLabel;
|
||||
protected System.Windows.Forms.Label label1;
|
||||
protected System.Windows.Forms.Label label2;
|
||||
protected System.Windows.Forms.TextBox textBoxMyCitrixPassword;
|
||||
protected System.Windows.Forms.TextBox textBoxMyCitrixUsername;
|
||||
private System.Windows.Forms.RadioButton existingAuthenticationRadioButton;
|
||||
private System.Windows.Forms.RadioButton newAuthenticationRadioButton;
|
||||
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.RadioButton existingAuthenticationRadioButton;
|
||||
private System.Windows.Forms.RadioButton newAuthenticationRadioButton;
|
||||
private Controls.CallHomeAuthenticationPanel callHomeAuthenticationPanel1;
|
||||
private System.Windows.Forms.Label rubricLabel;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.CheckBox enrollmentCheckBox;
|
||||
private Controls.DecentGroupBox decentGroupBoxXSCredentials;
|
||||
protected System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
||||
private System.Windows.Forms.Label label3;
|
||||
protected System.Windows.Forms.Label label4;
|
||||
protected System.Windows.Forms.Label label5;
|
||||
protected System.Windows.Forms.TextBox textboxXSPassword;
|
||||
protected System.Windows.Forms.TextBox textboxXSUserName;
|
||||
private System.Windows.Forms.RadioButton currentXsCredentialsRadioButton;
|
||||
private System.Windows.Forms.RadioButton newXsCredentialsRadioButton;
|
||||
private Controls.Common.PasswordFailure m_ctrlError;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -102,7 +102,11 @@ namespace XenAdmin.Actions
|
||||
|
||||
if (infoValue == null)
|
||||
{
|
||||
config.Remove(infoKey);
|
||||
if (config.ContainsKey(infoKey))
|
||||
{
|
||||
TryToDestroySecret(connection, config[infoKey]);
|
||||
config.Remove(infoKey);
|
||||
}
|
||||
}
|
||||
else if (config.ContainsKey(infoKey))
|
||||
{
|
||||
@ -126,6 +130,20 @@ namespace XenAdmin.Actions
|
||||
}
|
||||
}
|
||||
|
||||
private static void TryToDestroySecret(IXenConnection connection, string secret_uuid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var secret = Secret.get_by_uuid(connection.Session, secret_uuid);
|
||||
Secret.destroy(connection.Session, secret.opaque_ref);
|
||||
log.DebugFormat("Successfully destroyed secret {0}", secret_uuid);
|
||||
}
|
||||
catch (Exception exn)
|
||||
{
|
||||
log.Error(string.Format("Failed to destroy secret {0}", secret_uuid), exn);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetIdentityToken()
|
||||
{
|
||||
var json = new JavaScriptSerializer().Serialize(new
|
||||
|
@ -17,8 +17,8 @@ namespace XenAdmin.Actions
|
||||
this.pool = pool;
|
||||
this.callHomeSettings = callHomeSettings;
|
||||
this.authenticationToken = authenticationToken;
|
||||
this.username = userName;
|
||||
this.password = passWord;
|
||||
this.username = callHomeSettings.Status == CallHomeStatus.Enabled ? userName : null;
|
||||
this.password = callHomeSettings.Status == CallHomeStatus.Enabled ? passWord : null;
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
@ -26,11 +26,8 @@ namespace XenAdmin.Actions
|
||||
Dictionary<string, string> newConfig = callHomeSettings.ToDictionary(pool.health_check_config);
|
||||
if (!string.IsNullOrEmpty(authenticationToken))
|
||||
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_TOKEN_SECRET, authenticationToken);
|
||||
if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
|
||||
{
|
||||
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET, username);
|
||||
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET, password);
|
||||
}
|
||||
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET, username);
|
||||
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET, password);
|
||||
Pool.set_health_check_config(Connection.Session, pool.opaque_ref, newConfig);
|
||||
}
|
||||
}
|
||||
|
@ -443,6 +443,7 @@ namespace XenAPI
|
||||
public string NewUploadRequest;
|
||||
public string UserNameSecretUuid;
|
||||
public string PasswordSecretUuid;
|
||||
public string LastSuccessfulUpload;
|
||||
|
||||
public const int DefaultRetryInterval = 7; // in days
|
||||
public const int UploadRequestValidityInterval = 30; // in minutes
|
||||
@ -488,6 +489,7 @@ namespace XenAPI
|
||||
NewUploadRequest = Get(config, NEW_UPLOAD_REQUEST);
|
||||
UserNameSecretUuid = Get(config, UPLOAD_CREDENTIAL_USER_SECRET);
|
||||
PasswordSecretUuid = Get(config, UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
||||
LastSuccessfulUpload = Get(config, LAST_SUCCESSFUL_UPLOAD);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> ToDictionary(Dictionary<string, string> baseDictionary)
|
||||
@ -522,13 +524,27 @@ namespace XenAPI
|
||||
{
|
||||
if (Status != CallHomeStatus.Enabled)
|
||||
return false;
|
||||
double uploadRequest;
|
||||
if (double.TryParse(NewUploadRequest, out uploadRequest))
|
||||
var uploadRequestExpiryTime = NewUploadRequestTime.AddMinutes(UploadRequestValidityInterval);
|
||||
return DateTime.Compare(uploadRequestExpiryTime, DateTime.UtcNow) < 0;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime NewUploadRequestTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(NewUploadRequest))
|
||||
{
|
||||
var uploadRequestExpiryTime = Util.FromUnixTime(uploadRequest).AddMinutes(UploadRequestValidityInterval);
|
||||
return DateTime.Compare(uploadRequestExpiryTime, DateTime.UtcNow) < 0;
|
||||
try
|
||||
{
|
||||
return StringToDateTime(NewUploadRequest);
|
||||
}
|
||||
catch (Exception exn)
|
||||
{
|
||||
log.Error("Exception while parsing NewUploadRequest", exn);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,6 +591,12 @@ namespace XenAPI
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static bool TryParseStringToDateTime(string dateTimeString, out DateTime dateTime)
|
||||
{
|
||||
// Round-trip format time
|
||||
return DateTime.TryParseExact(dateTimeString, "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTime);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public string GetSecretyInfo(IXenConnection connection, string secretType)
|
||||
|
@ -60,7 +60,7 @@ namespace XenServerHealthCheck
|
||||
private static double DueAfterHour = 24;
|
||||
private static bool CanLock(string UploadLock, bool onDemand)
|
||||
{
|
||||
if (UploadLock.Length == 0)
|
||||
if (string.IsNullOrEmpty(UploadLock))
|
||||
return true;
|
||||
|
||||
List<string> currentLock = new List<string>(UploadLock.Split('|'));
|
||||
@ -209,17 +209,29 @@ namespace XenServerHealthCheck
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.ContainsKey(CallHomeSettings.NEW_UPLOAD_REQUEST))
|
||||
var newUploadRequest = Get(config, CallHomeSettings.NEW_UPLOAD_REQUEST);
|
||||
if (!string.IsNullOrEmpty(newUploadRequest))
|
||||
{
|
||||
|
||||
DateTime newUploadRequestDueTime = CallHomeSettings.StringToDateTime(Get(config, CallHomeSettings.NEW_UPLOAD_REQUEST)).AddMinutes(DemandTimeOutMinutes);;
|
||||
if (DateTime.Compare(newUploadRequestDueTime, DateTime.UtcNow) >= 0)
|
||||
DateTime newUploadRequestTime;
|
||||
try
|
||||
{
|
||||
newUploadRequestTime = CallHomeSettings.StringToDateTime(newUploadRequest);
|
||||
}
|
||||
catch (Exception exn)
|
||||
{
|
||||
log.Error("Exception while parsing NEW_UPLOAD_REQUEST", exn);
|
||||
return false;
|
||||
}
|
||||
DateTime newUploadRequestDueTime = newUploadRequestTime.AddMinutes(DemandTimeOutMinutes);
|
||||
if (DateTime.Compare(newUploadRequestDueTime, DateTime.UtcNow) >= 1)
|
||||
{
|
||||
log.InfoFormat("Will report on demand for XenServer {0} since the demand was requested on {1} (UTC time)", connection.Hostname, newUploadRequestTime);
|
||||
return getLock(connection, session);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.InfoFormat("Will not report on demand for XenServer {0} since the demand due", connection.Hostname);
|
||||
log.InfoFormat("Will not report on demand for XenServer {0} since the demand requested on {1} (UTC time) expired after {2} minutes",
|
||||
connection.Hostname, newUploadRequestTime, DemandTimeOutMinutes);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -202,6 +202,13 @@ namespace XenServerHealthCheck
|
||||
{
|
||||
config[CallHomeSettings.LAST_SUCCESSFUL_UPLOAD] = stime;
|
||||
config[CallHomeSettings.UPLOAD_UUID] = uploadUuid;
|
||||
// reset the NEW_UPLOAD_REQUEST field, if the current successful upload was started after the request
|
||||
DateTime newUploadRequestTime;
|
||||
if (CallHomeSettings.TryParseStringToDateTime(config[CallHomeSettings.NEW_UPLOAD_REQUEST], out newUploadRequestTime))
|
||||
{
|
||||
if (rtime > newUploadRequestTime)
|
||||
config[CallHomeSettings.NEW_UPLOAD_REQUEST] = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
config[CallHomeSettings.LAST_FAILED_UPLOAD] = stime;
|
||||
|
Loading…
Reference in New Issue
Block a user