2015-07-01 13:06:19 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Actions
|
|
|
|
|
{
|
|
|
|
|
public class SaveCallHomeSettingsAction : PureAsyncAction
|
|
|
|
|
{
|
|
|
|
|
private readonly Pool pool;
|
|
|
|
|
CallHomeSettings callHomeSettings;
|
|
|
|
|
private string authenticationToken;
|
2015-07-01 04:35:59 +02:00
|
|
|
|
private string username;
|
2015-07-01 13:06:19 +02:00
|
|
|
|
private string password;
|
|
|
|
|
|
|
|
|
|
public SaveCallHomeSettingsAction(Pool pool, CallHomeSettings callHomeSettings, string authenticationToken, string userName, string passWord, 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;
|
2015-07-01 04:35:59 +02:00
|
|
|
|
this.authenticationToken = authenticationToken;
|
2015-07-06 18:02:55 +02:00
|
|
|
|
this.username = callHomeSettings.Status == CallHomeStatus.Enabled ? userName : null;
|
|
|
|
|
this.password = callHomeSettings.Status == CallHomeStatus.Enabled ? passWord : null;
|
2015-07-01 13:06:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Run()
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> newConfig = callHomeSettings.ToDictionary(pool.health_check_config);
|
2015-07-01 04:35:59 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(authenticationToken))
|
|
|
|
|
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_TOKEN_SECRET, authenticationToken);
|
2015-07-06 18:02:55 +02:00
|
|
|
|
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET, username);
|
|
|
|
|
CallHomeAuthenticationAction.SetSecretInfo(Connection, newConfig, CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET, password);
|
2015-07-01 13:06:19 +02:00
|
|
|
|
Pool.set_health_check_config(Connection.Session, pool.opaque_ref, newConfig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|