Skip to content

Commit 4fba6ab

Browse files
authored
SDK updates and fixes (#6988)
There is a minor change in the datamodel, the rest are SDK files. These changes will need porting to `26.1-lcm` afterwards.
2 parents ae29bef + d0c3101 commit 4fba6ab

28 files changed

Lines changed: 368 additions & 554 deletions

ocaml/idl/datamodel.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11037,7 +11037,7 @@ let http_actions =
1103711037
; ( "get_vm_rrds"
1103811038
, ( Get
1103911039
, "/vm_rrds"
11040-
, true
11040+
, false
1104111041
, [String_query_arg "uuid"; Bool_query_arg "json"]
1104211042
, _R_READ_ONLY
1104311043
, []
@@ -11054,7 +11054,7 @@ let http_actions =
1105411054
)
1105511055
(* For XC < 8460 compatibility, remove when out of support *)
1105611056
; ( "get_host_rrds"
11057-
, (Get, "/host_rrds", true, [Bool_query_arg "json"], _R_READ_ONLY, [])
11057+
, (Get, "/host_rrds", false, [Bool_query_arg "json"], _R_READ_ONLY, [])
1105811058
)
1105911059
; ( Constants.get_sr_rrd
1106011060
, ( Get

ocaml/sdk-gen/c/README.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
libxenserver
22
============
33

4-
Copyright (c) 2007-2025 Cloud Software Group, Inc. All Rights Reserved.
4+
Copyright (c) 2007-2026 Cloud Software Group, Inc. All Rights Reserved.
55

66
libxenserver is a complete SDK for XenServer exposing the XenServer API to
77
C developers.
@@ -20,10 +20,10 @@ Reference
2020
For XenServer documentation see https://docs.xenserver.com
2121

2222
The XenServer Management API Reference is available at
23-
https://docs.xenserver.com/en-us/xenserver/8/developer/management-api
23+
https://docs.xenserver.com/en-us/xenserver/developer/api-reference
2424

2525
The XenServer Software Development Kit Guide is available at
26-
https://docs.xenserver.com/en-us/xenserver/8/developer/sdk-guide
26+
https://docs.xenserver.com/en-us/xenserver/developer/sdk-guide
2727

2828
A number of examples to help you get started with the SDK is available at
2929
https://github.com/xenserver/xenserver-samples
@@ -32,7 +32,7 @@ For community content, blogs, and downloads, visit
3232
https://www.xenserver.com/blogs and https://www.citrix.com/community/
3333

3434
To network with other developers using XenServer visit
35-
https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver/
35+
https://community.citrix.com/forums/forum/1118-xenserver-sdk/
3636

3737

3838
Dependencies

ocaml/sdk-gen/csharp/FriendlyErrorNames.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<value>The GPU group contains active virtual GPUs and cannot be deleted.</value>
9292
</data>
9393
<data name="HANDLE_INVALID" xml:space="preserve">
94-
<value>Object has been deleted.{0}:{1}</value>
94+
<value>Could not find the specified object. If it existed before, it may have recently been deleted. {0} {1}</value>
9595
</data>
9696
<data name="HA_CONSTRAINT_VIOLATION_NETWORK_NOT_SHARED" xml:space="preserve">
9797
<value>This operation cannot be performed because the referenced network is not properly shared. The network must either be entirely virtual or must be physically present via a currently attached PIF on every server.</value>

ocaml/sdk-gen/csharp/autogen/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# XenServer.NET
22

3-
Copyright (c) 2007-2025 Cloud Software Group, Inc. All Rights Reserved.
3+
Copyright (c) 2007-2026 Cloud Software Group, Inc. All Rights Reserved.
44

55
XenServer.NET is a complete SDK for XenServer, exposing the XenServer
66
API as .NET classes. It is written in C#.
@@ -18,10 +18,10 @@ terms of the BSD 2-Clause license. See LICENSE.txt for details.
1818
For XenServer documentation see <https://docs.xenserver.com>
1919

2020
The XenServer Management API Reference is available at
21-
<https://docs.xenserver.com/en-us/xenserver/8/developer/management-api>
21+
<https://docs.xenserver.com/en-us/xenserver/developer/api-reference>
2222

2323
The XenServer Software Development Kit Guide is available at
24-
<https://docs.xenserver.com/en-us/xenserver/8/developer/sdk-guide>
24+
<https://docs.xenserver.com/en-us/xenserver/developer/sdk-guide>
2525

2626
A number of examples to help you get started with the SDK is available at
2727
<https://github.com/xenserver/xenserver-samples>
@@ -30,11 +30,11 @@ For community content, blogs, and downloads, visit
3030
<https://www.xenserver.com/blogs> and <https://www.citrix.com/community>
3131

3232
To network with other developers using XenServer visit
33-
<https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver>
33+
<https://community.citrix.com/forums/forum/1118-xenserver-sdk/>
3434

3535
## Prerequisites
3636

37-
This library requires .NET Standard 2.0.
37+
This library targets .NET Framework 4.6.2, .NET Standard 2.0, and .NET 8.0.
3838

3939
## Dependencies
4040

ocaml/sdk-gen/csharp/autogen/src/Event.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,6 @@ public override void UpdateFrom(Event update)
4545
id = update.id;
4646
}
4747

48-
[Obsolete("Use the calls setting individual fields of the API object instead.")]
49-
public override string SaveChanges(Session session, string opaqueRef, Event serverObject)
50-
{
51-
if (opaqueRef == null)
52-
{
53-
throw new InvalidOperationException("There is no constructor available for this type; you cannot directly create one on the server.");
54-
}
55-
56-
Event server = serverObject;
57-
58-
if (!_id.Equals(server._id))
59-
set_id(session, opaqueRef, _id);
60-
61-
return null;
62-
}
63-
6448
public static Event get_record(Session session, string _event)
6549
{
6650
return session.JsonRpcClient.event_get_record(session.opaque_ref, _event);

ocaml/sdk-gen/csharp/autogen/src/HTTP.cs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,21 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
9090
[Serializable]
9191
public class BadServerResponseException : Exception
9292
{
93+
public int StatusCode { get; }
94+
public string InitialLine { get; }
95+
public string Body { get; }
96+
9397
public BadServerResponseException() { }
9498

9599
public BadServerResponseException(string message) : base(message) { }
96100

101+
public BadServerResponseException(string message, int statusCode, string initialLine, string body) : base(message)
102+
{
103+
StatusCode = statusCode;
104+
InitialLine = initialLine;
105+
Body = body;
106+
}
107+
97108
public BadServerResponseException(string message, Exception exception) : base(message, exception) { }
98109

99110
#if !(NET8_0_OR_GREATER)
@@ -195,11 +206,16 @@ private static string ReadLine(Stream stream)
195206
private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nodelay, int timeout_ms, List<string> headers = null)
196207
{
197208
// read headers/fields
198-
string line = ReadLine(stream), initialLine = line, transferEncodingField = null;
209+
string line = ReadLine(stream);
210+
string initialLine = line;
211+
string transferEncodingField = null;
212+
199213
if (string.IsNullOrEmpty(initialLine)) // sanity check
200214
return false;
215+
201216
if (headers == null)
202217
headers = new List<string>();
218+
203219
while (!string.IsNullOrWhiteSpace(line)) // IsNullOrWhiteSpace also checks for empty string
204220
{
205221
line = line.TrimEnd('\r', '\n');
@@ -211,6 +227,7 @@ private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nod
211227

212228
// read chunks
213229
string entityBody = "";
230+
214231
if (!string.IsNullOrEmpty(transferEncodingField))
215232
{
216233
int lastChunkSize = -1;
@@ -246,13 +263,9 @@ private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nod
246263
entityBody = entityBody.TrimEnd('\r', '\n');
247264
headers.Add(entityBody); // keep entityBody if it's needed for Digest authentication (when qop="auth-int")
248265
}
249-
else
250-
{
251-
// todo: handle other transfer types, in case "Transfer-Encoding: Chunked" isn't used
252-
}
253266

254267
// handle server response
255-
int code = getResultCode(initialLine);
268+
int code = GetResultCode(initialLine);
256269
switch (code)
257270
{
258271
case 407: // authentication error; caller must handle this case
@@ -268,17 +281,32 @@ private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nod
268281
return true; // headers need to be sent again
269282

270283
default:
284+
var contentLengthHeader = headers
285+
.FirstOrDefault(h => h.StartsWith("Content-Length:", StringComparison.InvariantCultureIgnoreCase));
286+
287+
if (contentLengthHeader != null && int.TryParse(contentLengthHeader.Substring(15).Trim(), out var len))
288+
{
289+
byte[] bytes = new byte[len];
290+
int total = 0;
291+
int read;
292+
293+
while (total < len && (read = stream.Read(bytes, total, len - total)) > 0)
294+
total += read;
295+
296+
entityBody = Encoding.ASCII.GetString(bytes);
297+
}
298+
271299
stream.Close();
272-
throw new BadServerResponseException(string.Format("Received error code {0} from the server", initialLine));
300+
throw new BadServerResponseException(string.Format("Received error code {0} from the server", initialLine), code, initialLine, entityBody);
273301
}
274302

275303
return false;
276304
}
277305

278-
private static int getResultCode(string line)
306+
private static int GetResultCode(string line)
279307
{
280308
string[] bits = line.Split(' ');
281-
return (bits.Length < 2 ? 0 : Int32.Parse(bits[1]));
309+
return bits.Length < 2 ? 0 : Int32.Parse(bits[1]);
282310
}
283311

284312
public static bool UseSSL(Uri uri)
@@ -651,7 +679,7 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox
651679
if (authenticatedResponse.Count == 0)
652680
throw new BadServerResponseException("No response from the proxy server after authentication attempt.");
653681

654-
switch (getResultCode(authenticatedResponse[0]))
682+
switch (GetResultCode(authenticatedResponse[0]))
655683
{
656684
case 200:
657685
break;

ocaml/sdk-gen/csharp/autogen/src/JsonRpc.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public override string ToString()
163163
public partial class JsonRpcClient
164164
{
165165
private int _globalId;
166+
private string _userAgent;
166167

167168
#if (NET8_0_OR_GREATER)
168169
private static readonly Type ClassType = typeof(JsonRpcClient);
@@ -205,6 +206,10 @@ public JsonRpcClient(string baseUrl)
205206
Url = baseUrl;
206207
JsonRpcUrl = new Uri(new Uri(baseUrl), "/jsonrpc").ToString();
207208
JsonRpcVersion = JsonRpcVersion.v1;
209+
Timeout = Session.STANDARD_TIMEOUT;
210+
UserAgent = Session.DefaultUserAgent;
211+
KeepAlive = true;
212+
AllowAutoRedirect = true;
208213
}
209214

210215
/// <summary>
@@ -215,7 +220,13 @@ public JsonRpcClient(string baseUrl)
215220
public event Action<string> RequestEvent;
216221

217222
public JsonRpcVersion JsonRpcVersion { get; set; }
218-
public string UserAgent { get; set; }
223+
224+
public string UserAgent
225+
{
226+
get => _userAgent;
227+
set => _userAgent = string.IsNullOrEmpty(value) ? Session.DefaultUserAgent : value;
228+
}
229+
219230
public bool KeepAlive { get; set; }
220231
public IWebProxy WebProxy { get; set; }
221232
public int Timeout { get; set; }
@@ -239,7 +250,7 @@ public JsonRpcClient(string baseUrl)
239250

240251
public string JsonRpcUrl { get; private set; }
241252

242-
private void Rpc(string callName, JToken parameters, JsonSerializer serializer)
253+
protected void Rpc(string callName, JToken parameters, JsonSerializer serializer)
243254
{
244255
Rpc<object>(callName, parameters, serializer);
245256
}
@@ -516,7 +527,7 @@ private JsonSerializerSettings CreateSettings(IList<JsonConverter> converters)
516527
};
517528
}
518529

519-
private JsonSerializer CreateSerializer(IList<JsonConverter> converters)
530+
protected JsonSerializer CreateSerializer(IList<JsonConverter> converters)
520531
{
521532
var settings = CreateSettings(converters);
522533
return JsonSerializer.Create(settings);
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# XenServer.NET
22

3-
Copyright (c) 2007-2025 Cloud Software Group, Inc. All Rights Reserved.
3+
Copyright (c) 2007-2026 Cloud Software Group, Inc. All Rights Reserved.
44

55
XenServer.NET is a complete SDK for XenServer, exposing the XenServer
66
API as .NET classes. It is written in C#.
@@ -13,35 +13,32 @@ are ideal for developers wishing to use XenServer.NET.
1313
XenServer.NET is free software. You can redistribute and modify it under the
1414
terms of the BSD 2-Clause license. See LICENSE.txt for details.
1515

16-
1716
## Reference
1817

19-
For XenServer documentation see https://docs.xenserver.com
18+
For XenServer documentation see <https://docs.xenserver.com>
2019

2120
The XenServer Management API Reference is available at
22-
https://docs.xenserver.com/en-us/xenserver/8/developer/management-api
21+
<https://docs.xenserver.com/en-us/xenserver/developer/api-reference>
2322

2423
The XenServer Software Development Kit Guide is available at
25-
https://docs.xenserver.com/en-us/xenserver/8/developer/sdk-guide
24+
<https://docs.xenserver.com/en-us/xenserver/developer/sdk-guide>
2625

2726
A number of examples to help you get started with the SDK is available at
28-
https://github.com/xenserver/xenserver-samples
27+
<https://github.com/xenserver/xenserver-samples>
2928

3029
For community content, blogs, and downloads, visit
31-
https://www.xenserver.com/blogs and https://www.citrix.com/community
30+
<https://www.xenserver.com/blogs> and <https://www.citrix.com/community>
3231

3332
To network with other developers using XenServer visit
34-
https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver
35-
33+
<https://community.citrix.com/forums/forum/1118-xenserver-sdk/>
3634

3735
## Prerequisites
3836

39-
This library requires .NET Standard 2.0.
40-
37+
This library targets .NET Framework 4.6.2, .NET Standard 2.0, and .NET 8.0.
4138

4239
## Dependencies
4340

4441
XenServer.NET is dependent upon the following libraries:
4542

46-
- Newtonsoft JSON.NET by James Newton-King (see https://www.newtonsoft.com).
43+
- Newtonsoft JSON.NET by James Newton-King (see <https://www.newtonsoft.com>).
4744
JSON.NET is licensed under the MIT license.

0 commit comments

Comments
 (0)