mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
CP-41573: Add helper function to fetch host EUA
Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
parent
34eb5ff9b0
commit
e265a1f23e
@ -28,6 +28,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
@ -1580,5 +1581,33 @@ namespace XenAdmin.Core
|
||||
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public static bool TryLoadHostEua(Host host, Uri targetUri, out string eua)
|
||||
{
|
||||
eua = null;
|
||||
if (host == null || targetUri == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var args = new Dictionary<string, string>
|
||||
{
|
||||
{ "url", targetUri.ToString()}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var result = Host.call_plugin(host.Connection.Session, host.opaque_ref, "prepare_host_upgrade.py", "getEUA", args);
|
||||
var jsonPayloadDefinition = new { eua = string.Empty };
|
||||
var parsedPayload = JsonConvert.DeserializeAnonymousType(result, jsonPayloadDefinition);
|
||||
|
||||
eua = parsedPayload.eua;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
}
|
||||
|
||||
return eua != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user