2015-05-18 16:23:32 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Actions
|
|
|
|
|
{
|
|
|
|
|
public class SaveCallHomeSettingsAction : PureAsyncAction
|
|
|
|
|
{
|
|
|
|
|
private readonly Pool pool;
|
|
|
|
|
CallHomeSettings callHomeSettings;
|
2015-06-02 15:48:59 +02:00
|
|
|
|
private string authenticationToken;
|
2015-05-18 16:23:32 +02:00
|
|
|
|
|
2015-06-02 15:48:59 +02:00
|
|
|
|
public SaveCallHomeSettingsAction(Pool pool, CallHomeSettings callHomeSettings, string authenticationToken, bool suppressHistory)
|
2015-05-18 16:23:32 +02:00
|
|
|
|
: 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-06-02 15:48:59 +02:00
|
|
|
|
this.authenticationToken = authenticationToken;
|
2015-05-18 16:23:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Run()
|
|
|
|
|
{
|
2015-06-16 15:47:33 +02:00
|
|
|
|
Dictionary<string, string> newConfig = callHomeSettings.ToDictionary(pool.health_check_config);
|
2015-06-02 15:48:59 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(authenticationToken))
|
|
|
|
|
CallHomeAuthenticationAction.SetUploadTokenSecret(Connection, newConfig, authenticationToken);
|
2015-06-16 15:47:33 +02:00
|
|
|
|
Pool.set_health_check_config(Connection.Session, pool.opaque_ref, newConfig);
|
2015-05-18 16:23:32 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|