-Xlint:deprecation
-Xlint:unchecked
diff --git a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/Connection.java b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/Connection.java
index bc8b5c644e4..bc1fccb99d5 100644
--- a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/Connection.java
+++ b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/Connection.java
@@ -68,29 +68,6 @@ public Connection(JsonRpcClient jsonRpcClient) {
this.client = jsonRpcClient;
}
- /**
- * Creates a connection to a particular server using a given url. This object can then be passed
- * in to any other API calls.
- *
- * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
- * passing the Connection as a parameter. No attempt to connect to the server is made until login is called.
- *
- * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually
- * logging out the Session.
- *
- * @param httpClient The HttpClient used to make calls, this will be used by the underlying {@link #client} for handling requests
- * @param url The URL of the server to connect to. Should be of the form http(s)://host-url/jsonrpc or http(s)://host-url.
- * @param requestTimeout The reply timeout for JSON-RPC calls in seconds
- * @deprecated This constructor is deprecated. To set the {@code requestTimeout} please {@link #setRequestTimeout(int)}. You may also use the {@link com.xensource.xenapi.JsonRpcClient#setRequestTimeout(int)}
- * method of this object's {@link #client}. This option is only advisable if you are managing your own {@link com.xensource.xenapi.JsonRpcClient} as the underlying
- * {@link #client} for this object.
- */
- @Deprecated
- public Connection(CloseableHttpClient httpClient, URL url, int requestTimeout) {
- this.client = new JsonRpcClient(httpClient, url);
- this.client.setRequestTimeout(requestTimeout);
- }
-
/**
* Creates a connection to a particular server using a given url. This object can then be passed
* in to any other API calls.
@@ -110,31 +87,6 @@ public Connection(URL url) {
this.client = new JsonRpcClient(url);
}
- /**
- * Creates a connection to a particular server using a given url. This object can then be passed
- * in to any other API calls.
- *
- * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
- * passing the Connection as a parameter. No attempt to connect to the server is made until login is called.
- *
- * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually
- * logging out the Session.
- *
- * @param url The URL of the server to connect to. Should be of the form http(s)://host-url/jsonrpc or http(s)://host-url.
- * @param requestTimeout The reply timeout for JSON-RPC calls in seconds
- * @param connectionTimeout The connection timeout for JSON-RPC calls in seconds
- * @deprecated This constructor is deprecated. To set {@code requestTimeout} or {@code connectionTimeout} please use {@link #setRequestTimeout(int)} or {@link #setConnectionTimeout(int)} respectively.
- * You may also use the {@link com.xensource.xenapi.JsonRpcClient#setRequestTimeout(int)} method of this object's {@link #client}.
- * This option is only advisable if you are managing your own {@link com.xensource.xenapi.JsonRpcClient} as the underlying
- * {@link #client} for this object.
- */
- @Deprecated
- public Connection(URL url, int requestTimeout, int connectionTimeout) {
- this.client = new JsonRpcClient(url);
- this.client.setRequestTimeout(requestTimeout);
- this.client.setConnectionTimeout(connectionTimeout);
- }
-
/**
* Creates a connection to a particular server using a given url. This object can then be passed
* in to any other API calls.
@@ -159,36 +111,6 @@ public Connection(URL url, String sessionReference) {
this.sessionReference = sessionReference;
}
- /**
- * Creates a connection to a particular server using a given url. This object can then be passed
- * in to any other API calls.
- *
- * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
- * passing the Connection as a parameter. No attempt to connect to the server is made until login is called.
- *
- * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually
- * logging out the Session.
- *
- * @param url The URL of the server to connect to. Should be of the form http(s)://host-url/jsonrpc or http(s)://host-url.
- * @param sessionReference A reference to a logged-in Session. Any method calls on this Connection will use it.
- * This constructor does not call Session.loginWithPassword, and dispose() on the resulting
- * Connection object does not call Session.logout. The programmer is responsible for
- * ensuring the Session is logged in and out correctly.
- * @param requestTimeout The reply timeout for JSON-RPC calls in seconds
- * @param connectionTimeout The connection timeout for JSON-RPC calls in seconds
- * @deprecated This constructor is deprecated. To set {@code requestTimeout} or {@code connectionTimeout} please use {@link #setRequestTimeout(int)} or {@link #setConnectionTimeout(int)} respectively.
- * You may also use the {@link com.xensource.xenapi.JsonRpcClient#setRequestTimeout(int)} method of this object's {@link #client}.
- * This option is only advisable if you are managing your own {@link com.xensource.xenapi.JsonRpcClient} as the underlying
- * {@link #client} for this object.
- */
- @Deprecated
- public Connection(URL url, String sessionReference, int requestTimeout, int connectionTimeout) {
- this.client = new JsonRpcClient(url);
- this.client.setRequestTimeout(requestTimeout);
- this.client.setConnectionTimeout(connectionTimeout);
- this.sessionReference = sessionReference;
- }
-
/**
* Set the timeout in seconds for every request made by this object's {@link #client}.
* If not set the value defaults to {@value JsonRpcClient#DEFAULT_REQUEST_TIMEOUT}.
diff --git a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/CustomDateDeserializer.java b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/CustomDateDeserializer.java
index 63be5c1c458..d3d43df7bc1 100644
--- a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/CustomDateDeserializer.java
+++ b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/CustomDateDeserializer.java
@@ -49,7 +49,7 @@ public class CustomDateDeserializer extends StdDeserializer {
/**
* Array of {@link SimpleDateFormat} objects representing the date formats
* used in xen-api responses.
- *
+ *
* RFC-3339 date formats can be returned in either Zulu or time zone agnostic.
* This list is not an exhaustive list of formats supported by RFC-3339, rather
* a set of formats that will enable the deserialization of xen-api dates.
diff --git a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/JsonRpcClient.java b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/JsonRpcClient.java
index 9d1389eaf28..f3db8252446 100644
--- a/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/JsonRpcClient.java
+++ b/ocaml/sdk-gen/java/autogen/xen-api/src/main/java/com/xensource/xenapi/JsonRpcClient.java
@@ -53,15 +53,14 @@
/**
* Provides a JSON-RPC v2.0 client for making remote procedure calls to xapi's backend URL.
- *
+ *
* This class enables the communication to the JSON-RPC backend. The client utilizes the HttpClient class for
* sending HTTP POST requests with JSON payloads and the ObjectMapper class from the Jackson library for
* serialization and deserialization of JSON data.
- *
+ *
* The client can be customised by passing it as a parameter to corresponding constructor, enabling custom
* handling of requests.
- *
- *
+ *
* By default, the timeout for requests is set to {@value #DEFAULT_REQUEST_TIMEOUT}. The default timeout for connecting to the
* JSON-RPC backend is set to {@value #DEFAULT_CONNECTION_TIMEOUT} seconds. The maximum number of concurrent connections handled
* by the underlying {@link PoolingHttpClientConnectionManager} is {@value #MAX_CONCURRENT_CONNECTIONS}.
diff --git a/ocaml/sdk-gen/java/autogen/xen-api/src/main/resources/README.txt b/ocaml/sdk-gen/java/autogen/xen-api/src/main/resources/README.txt
index f5d13f889f5..4d469b5efcf 100644
--- a/ocaml/sdk-gen/java/autogen/xen-api/src/main/resources/README.txt
+++ b/ocaml/sdk-gen/java/autogen/xen-api/src/main/resources/README.txt
@@ -1,7 +1,7 @@
XenServerJava
=============
-Copyright (c) 2007-2025 Cloud Software Group, Inc. All Rights Reserved.
+Copyright (c) 2007-2026 Cloud Software Group, Inc. All Rights Reserved.
XenServerJava is a complete SDK for XenServer, exposing the XenServer API as
Java classes.
@@ -21,10 +21,10 @@ Reference
For XenServer documentation see https://docs.xenserver.com
The XenServer Management API Reference is available at
-https://docs.xenserver.com/en-us/xenserver/8/developer/management-api
+https://docs.xenserver.com/en-us/xenserver/developer/api-reference
The XenServer Software Development Kit Guide is available at
-https://docs.xenserver.com/en-us/xenserver/8/developer/sdk-guide
+https://docs.xenserver.com/en-us/xenserver/developer/sdk-guide
A number of examples to help you get started with the SDK is available at
https://github.com/xenserver/xenserver-samples
@@ -33,7 +33,7 @@ For community content, blogs, and downloads, visit
https://www.xenserver.com/blogs and https://www.citrix.com/community/
To network with other developers using XenServer visit
-https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver/
+https://community.citrix.com/forums/forum/1118-xenserver-sdk/
Dependencies
diff --git a/ocaml/sdk-gen/java/main.ml b/ocaml/sdk-gen/java/main.ml
index 9fdab7102a4..ca779c54058 100644
--- a/ocaml/sdk-gen/java/main.ml
+++ b/ocaml/sdk-gen/java/main.ml
@@ -501,15 +501,6 @@ let get_types_json types =
("name", `String type_string)
; ("class_name", `String class_name)
; ("method_name", `String method_name)
- ; ( "suppress_unchecked_warning"
- , `Bool
- ( match t with
- | Map _ | Record _ | Option (Record _) | Option (Map _) ->
- true
- | _ ->
- false
- )
- )
; ( "generate_reference_task_result_func"
, `Bool generate_reference_task_result_func
)
diff --git a/ocaml/sdk-gen/java/templates/Class.mustache b/ocaml/sdk-gen/java/templates/Class.mustache
index 658deeb05f2..e96d2914145 100644
--- a/ocaml/sdk-gen/java/templates/Class.mustache
+++ b/ocaml/sdk-gen/java/templates/Class.mustache
@@ -61,9 +61,10 @@ public class {{class_name}} extends XenAPIObject {
protected final String ref;
/**
- * For internal use only.
+ * Creates an object from a given XenAPI reference (OpaqueRef)
+ * @param ref The OpaqueRef from which to create the object.
*/
- {{{class_name}}}(String ref) {
+ public {{{class_name}}}(String ref) {
this.ref = ref;
}
@@ -79,21 +80,17 @@ public class {{class_name}} extends XenAPIObject {
* If obj is a {{{class_name}}}, compares XenAPI references for equality.
*/
@Override
- public boolean equals(Object obj)
- {
- if (obj instanceof {{{class_name}}})
- {
+ public boolean equals(Object obj) {
+ if (obj instanceof {{{class_name}}}) {
{{{class_name}}} other = ({{{class_name}}}) obj;
return other.ref.equals(this.ref);
- } else
- {
+ } else {
return false;
}
}
@Override
- public int hashCode()
- {
+ public int hashCode() {
return ref.hashCode();
}
diff --git a/ocaml/sdk-gen/java/templates/Types.mustache b/ocaml/sdk-gen/java/templates/Types.mustache
index 4da97c774cd..67906c33029 100644
--- a/ocaml/sdk-gen/java/templates/Types.mustache
+++ b/ocaml/sdk-gen/java/templates/Types.mustache
@@ -40,50 +40,46 @@ import java.util.regex.Pattern;
*/
public class Types
{
- /**
- * Interface for all Record classes
- */
- public interface Record
- {
- /**
- * Convert a Record to a Map
- */
- Map toMap();
- }
- /**
- * Base class for all XenAPI Exceptions
- */
- public static class XenAPIException extends IOException {
- public final String shortDescription;
- public final String[] errorDescription;
- XenAPIException(String shortDescription)
- {
- this.shortDescription = shortDescription;
- this.errorDescription = null;
- }
- XenAPIException(String[] errorDescription)
- {
- this.errorDescription = errorDescription;
- if (errorDescription.length > 0)
- {
- shortDescription = errorDescription[0];
- } else
- {
- shortDescription = "";
- }
- }
- public String toString()
- {
- if (errorDescription == null)
- {
- return shortDescription;
- } else if (errorDescription.length == 0)
- {
- return "";
- }
+ /**
+ * Interface for all Record classes
+ */
+ public interface Record
+ {
+ /**
+ * Convert a Record to a Map
+ */
+ Map toMap();
+ }
+ /**
+ * Base class for all XenAPI Exceptions
+ */
+ public static class XenAPIException extends IOException {
+ public final String shortDescription;
+ public final String[] errorDescription;
+
+ XenAPIException(String shortDescription) {
+ this.shortDescription = shortDescription;
+ this.errorDescription = null;
+ }
+
+ XenAPIException(String[] errorDescription) {
+ this.errorDescription = errorDescription;
+ if (errorDescription.length > 0) {
+ shortDescription = errorDescription[0];
+ } else {
+ shortDescription = "";
+ }
+ }
+
+ public String toString() {
+ if (errorDescription == null) {
+ return shortDescription;
+ } else if (errorDescription.length == 0) {
+ return "";
+ }
+
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < errorDescription.length - 1; i++)
- {
+ for (int i = 0; i < errorDescription.length - 1; i++) {
sb.append(errorDescription[i]);
}
sb.append(errorDescription[errorDescription.length - 1]);
@@ -91,33 +87,30 @@ public class Types
}
}
- /**
- * Thrown if the response from the server contains an invalid status.
- */
- public static class BadServerResponse extends XenAPIException
- {
- public BadServerResponse(JsonRpcResponseError responseError)
- {
- super(String.valueOf(responseError));
- }
- }
+ /**
+ * Thrown if the response from the server contains an invalid status.
+ */
+ public static class BadServerResponse extends XenAPIException {
+ public BadServerResponse(JsonRpcResponseError responseError) {
+ super(String.valueOf(responseError));
+ }
+ }
- /**
- * Checks the provided server response was successful. If the call
- * failed, throws a XenAPIException. If the server
- * returned an invalid response, throws a BadServerResponse.
- * Otherwise, returns the server response as passed in.
- */
- public static void checkError(JsonRpcResponseError response) throws XenAPIException, BadServerResponse
- {
+ /**
+ * Checks the provided server response was successful. If the call
+ * failed, throws a XenAPIException. If the server
+ * returned an invalid response, throws a BadServerResponse.
+ * Otherwise, returns the server response as passed in.
+ */
+ public static void checkError(JsonRpcResponseError response) throws XenAPIException, BadServerResponse {
var errorData = response.data;
- if(errorData.length == 0){
+ if(errorData.length == 0) {
throw new BadServerResponse(response);
}
var errorName = response.message;
{{#errors}}
- if (errorName.equals("{{{name}}}")){
+ if (errorName.equals("{{{name}}}")) {
{{#err_params}}
String p{{{index}}} = errorData.length > {{{index}}} ? errorData[{{{index}}}] : "";
{{/err_params}}
@@ -180,37 +173,12 @@ public class Types
/**
* Create a new BadAsyncResult
*/
- public BadAsyncResult(String result)
- {
+ public BadAsyncResult(String result) {
super(result);
this.result = result;
}
}
- {{#types}}
- /**
- * Converts an {@link Object} to a {@link {{{name}}}} object.
- *
- * This method takes an {@link Object} as input and attempts to convert it into a {@link {{{name}}}} object.
- * If the input object is null, the method returns null. Otherwise, it creates a new {@link {{{name}}}}
- * object using the input object's {@link String} representation.
- *
- * @param object The {@link Object} to be converted to a {@link {{{name}}}} object.
- * @return A {@link {{{name}}}} object created from the input {@link Object}'s {@link String} representation,
- * or null if the input object is null.
- * @deprecated this method will not be publicly exposed in future releases of this package.
- */
- @Deprecated{{#suppress_unchecked_warning}}
- @SuppressWarnings("unchecked"){{/suppress_unchecked_warning}}
- public static {{{name}}} {{{method_name}}}(Object object) {
- if (object == null) {
- return null;
- }
- {{{method_body}}}
- }
-
- {{/types}}
-
{{#types}}{{#generate_reference_task_result_func}}
/**
* Attempt to convert the {@link Task}'s result to a {@link {{{name}}}} object.
@@ -218,12 +186,13 @@ public class Types
* @param task The task from which to fetch the result.
* @param connection The connection
* @return the instantiated object if a valid value was found, null otherwise.
- * @throws BadServerResponse Thrown if the response from the server contains an invalid status.
+ * @throws BadServerResponse if the response from the server contains an invalid status.
* @throws XenAPIException if the call failed.
- * @throws IOException if an error occurs during a send or receive. This includes cases where a payload is invalid JSON.
+ * @throws IOException if an error occurs during send or receive. This includes cases where a payload is invalid JSON.
*/
public static {{class_name}} to{{class_name}}(Task task, Connection connection) throws IOException {
- return Types.to{{class_name}}(parseResult(task.getResult(connection)));
+ String result = parseResult(task.getResult(connection));
+ return result == null || result.isEmpty() ? null : new {{class_name}}(result);
}
{{/generate_reference_task_result_func}}
@@ -238,16 +207,4 @@ public class Types
return matcher.group(1);
}
-
- public static EventBatch toEventBatch(Object object) {
- if (object == null) {
- return null;
- }
- Map map = (Map) object;
- EventBatch batch = new EventBatch();
- batch.token = toString(map.get("token"));
- batch.validRefCounts = map.get("valid_ref_counts");
- batch.events = toSetOfEventRecord(map.get("events"));
- return batch;
- }
}
diff --git a/ocaml/sdk-gen/powershell/autogen/README.md b/ocaml/sdk-gen/powershell/autogen/README.md
index 40812c3f7c8..dc4b260c6ba 100644
--- a/ocaml/sdk-gen/powershell/autogen/README.md
+++ b/ocaml/sdk-gen/powershell/autogen/README.md
@@ -1,6 +1,6 @@
# XenServer PowerShell Module
-Copyright (c) 2013-2025 Cloud Software Group, Inc. All Rights Reserved.
+Copyright (c) 2013-2026 Cloud Software Group, Inc. All Rights Reserved.
The XenServer PowerShell Module is a complete SDK for XenServer,
exposing the XenServer API as Windows PowerShell cmdlets.
@@ -18,10 +18,10 @@ terms of the BSD 2-Clause license. See LICENSE.txt for details.
For XenServer documentation see
The XenServer Management API Reference is available at
-
+
The XenServer Software Development Kit Guide is available at
-
+
A number of examples to help you get started with the SDK is available at
@@ -30,11 +30,11 @@ For community content, blogs, and downloads, visit
and
To network with other developers using XenServer visit
-
+
## Prerequisites
-This library requires .NET 6.0 and PowerShell 7.2 or greater.
+This library requires .NET 8.0 and PowerShell 7.4 or greater.
## Dependencies
diff --git a/ocaml/sdk-gen/powershell/autogen/README_51.md b/ocaml/sdk-gen/powershell/autogen/README_51.md
index 24ac038ee3c..47bd82e15c5 100644
--- a/ocaml/sdk-gen/powershell/autogen/README_51.md
+++ b/ocaml/sdk-gen/powershell/autogen/README_51.md
@@ -1,6 +1,6 @@
# XenServer PowerShell Module
-Copyright (c) 2013-2025 Cloud Software Group, Inc. All Rights Reserved.
+Copyright (c) 2013-2026 Cloud Software Group, Inc. All Rights Reserved.
The XenServer PowerShell Module is a complete SDK for XenServer,
exposing the XenServer API as Windows PowerShell cmdlets.
@@ -18,10 +18,10 @@ terms of the BSD 2-Clause license. See LICENSE.txt for details.
For XenServer documentation see
The XenServer Management API Reference is available at
-
+
The XenServer Software Development Kit Guide is available at
-
+
A number of examples to help you get started with the SDK is available at
@@ -30,11 +30,11 @@ For community content, blogs, and downloads, visit
and
To network with other developers using XenServer visit
-
+
## Prerequisites
-This library requires .NET Framework 4.5 or greater and PowerShell 5.1 or greater.
+This library requires .NET Framework 4.6.2 or greater and PowerShell 5.1 or greater.
## Dependencies
diff --git a/ocaml/sdk-gen/powershell/autogen/src/CommonCmdletFunctions.cs b/ocaml/sdk-gen/powershell/autogen/src/CommonCmdletFunctions.cs
index d22d5eadee0..943c91a7642 100644
--- a/ocaml/sdk-gen/powershell/autogen/src/CommonCmdletFunctions.cs
+++ b/ocaml/sdk-gen/powershell/autogen/src/CommonCmdletFunctions.cs
@@ -30,11 +30,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.IO;
using System.Management.Automation;
-using System.Reflection;
-using System.Xml;
-
using XenAPI;
namespace Citrix.XenServer
@@ -44,11 +40,6 @@ internal class CommonCmdletFunctions
private const string SessionsVariable = "global:Citrix.XenServer.Sessions";
private const string DefaultSessionVariable = "global:XenServer_Default_Session";
- static CommonCmdletFunctions()
- {
- Session.UserAgent = string.Format("XenServerPSModule/{0}", Assembly.GetExecutingAssembly().GetName().Version);
- }
-
internal static Dictionary GetAllSessions(PSCmdlet cmdlet)
{
object obj = cmdlet.SessionState.PSVariable.GetValue(SessionsVariable);
diff --git a/ocaml/sdk-gen/powershell/autogen/src/Connect-XenServer.cs b/ocaml/sdk-gen/powershell/autogen/src/Connect-XenServer.cs
index 52cb8e21e54..8f60885d057 100644
--- a/ocaml/sdk-gen/powershell/autogen/src/Connect-XenServer.cs
+++ b/ocaml/sdk-gen/powershell/autogen/src/Connect-XenServer.cs
@@ -52,9 +52,12 @@ public class ConnectXenServerCommand : PSCmdlet
private readonly object _certificateValidationLock = new object();
+ private static readonly string DefaultUserAgent = $"XenServerPSModule/@SDK_VERSION@";
+
public ConnectXenServerCommand()
{
Port = 443;
+ Originator = DefaultUserAgent;
}
#region Cmdlet Parameters
@@ -85,7 +88,10 @@ public ConnectXenServerCommand()
public string[] OpaqueRef { get; set; }
[Parameter]
- public string Originator { get; set; } = "XenServerPSModule/" + Helper.APIVersionString(API_Version.LATEST);
+ public string Originator { get; set; }
+
+ [Parameter(HelpMessage = "The UserAgent to use for the requests to the server")]
+ public string UserAgent { get; set; }
[Parameter]
public SwitchParameter PassThru { get; set; }
@@ -193,7 +199,7 @@ protected override void ProcessRecord()
Session session;
if (string.IsNullOrEmpty(OpaqueRef[i]))
{
- session = new Session(Url[i]);
+ session = new Session(Url[i]) { UserAgent = UserAgent };
try
{
session.login_with_password(connUser, connPassword, Helper.APIVersionString(API_Version.LATEST), Originator);
@@ -235,12 +241,15 @@ protected override void ProcessRecord()
});
}
+ if (inner != null)
+ throw inner;
+
throw;
}
}
else
{
- session = new Session(Url[i], OpaqueRef[i]);
+ session = new Session(Url[i], OpaqueRef[i]){ UserAgent = UserAgent };
}
session.Tag = Creds;
diff --git a/ocaml/sdk-gen/powershell/autogen/src/XenServerPowerShell.csproj b/ocaml/sdk-gen/powershell/autogen/src/XenServerPowerShell.csproj
index 35c2fc8fa42..c6f0390ff9a 100644
--- a/ocaml/sdk-gen/powershell/autogen/src/XenServerPowerShell.csproj
+++ b/ocaml/sdk-gen/powershell/autogen/src/XenServerPowerShell.csproj
@@ -1,7 +1,7 @@
0.0.0
- net8.0;net45
+ net8.0;net462
Library
True
@@ -12,7 +12,7 @@
-
+
diff --git a/ocaml/sdk-gen/powershell/gen_powershell_binding.ml b/ocaml/sdk-gen/powershell/gen_powershell_binding.ml
index ed84c2c7120..467b5b65c7e 100644
--- a/ocaml/sdk-gen/powershell/gen_powershell_binding.ml
+++ b/ocaml/sdk-gen/powershell/gen_powershell_binding.ml
@@ -17,11 +17,15 @@ module TypeSet = Set.Make (struct
let compare = compare
end)
-let destdir = "autogen-out/src"
+let destdir = "autogen-out"
+
+let srcdir = "autogen-out/src"
let templdir = "templates"
-type cmdlet = {filename: string; content: string}
+type cmdlet = {cmdletname: string; content: string}
+
+let cmdlets_to_export = ref []
let api =
Datamodel_utils.named_self := true ;
@@ -68,6 +72,21 @@ let maps = ref TypeSet.empty
let generated x =
not (List.mem x.name ["blob"; "session"; "debug"; "event"; "vtpm"])
+let rec is_last x list =
+ match list with
+ | [] ->
+ false
+ | hd :: [] ->
+ if hd = x then
+ true
+ else
+ false
+ | hd :: tl ->
+ if hd = x then
+ false
+ else
+ is_last x tl
+
let rec main () =
let json =
`O
@@ -91,7 +110,7 @@ let rec main () =
in
render_file
("ConvertTo-XenRef.mustache", "ConvertTo-XenRef.cs")
- json templdir destdir ;
+ json templdir srcdir ;
http_actions
|> List.filter (fun (_, (_, _, sdk, _, _, _)) -> sdk)
@@ -100,9 +119,45 @@ let rec main () =
let filtered_classes = List.filter generated classes in
let cmdlets = List.concat_map gen_cmdlets filtered_classes in
- List.iter (fun x -> write_file x.filename x.content) cmdlets ;
+ List.iter (fun x -> write_file x.cmdletname x.content) cmdlets ;
- filtered_classes |> List.iter gen_destructor
+ filtered_classes |> List.iter gen_destructor ;
+
+ cmdlets_to_export :=
+ [
+ "Connect-XenServer"
+ ; "Disconnect-XenServer"
+ ; "Get-XenSession"
+ ; "Receive-XenPoolPatch"
+ ; "Send-XenOemPatchStream"
+ ; "Wait-XenTask"
+ ; "ConvertTo-XenRef"
+ ]
+ @ !cmdlets_to_export ;
+
+ cmdlets_to_export := List.sort String.compare !cmdlets_to_export ;
+
+ let module_json =
+ `O
+ [
+ ( "cmdlets_to_export"
+ , `A
+ (List.map
+ (fun x ->
+ `O
+ [
+ ("cmdlet_to_export", `String x)
+ ; ("is_last", `Bool (is_last x !cmdlets_to_export))
+ ]
+ )
+ !cmdlets_to_export
+ )
+ )
+ ]
+ in
+ render_file
+ ("XenServerPSModule.mustache", "XenServerPSModule.psd1")
+ module_json templdir destdir
(****************)
(* Http actions *)
@@ -161,9 +216,11 @@ and gen_http_action action =
)
]
in
+ let cmdlet_name = sprintf "%s-Xen%s" commonVerb stem in
render_file
- ("HttpAction.mustache", sprintf "%s-Xen%s.cs" commonVerb stem)
- json templdir destdir
+ ("HttpAction.mustache", sprintf "%s.cs" cmdlet_name)
+ json templdir srcdir ;
+ cmdlets_to_export := cmdlet_name :: !cmdlets_to_export
(*************************)
(* Autogenerated cmdlets *)
@@ -174,30 +231,30 @@ and gen_cmdlets obj =
let cmdlets =
[
- {filename= sprintf "Get-Xen%s.cs" stem; content= gen_class obj classname}
+ {cmdletname= sprintf "Get-Xen%s" stem; content= gen_class obj classname}
; {
- filename= sprintf "New-Xen%s.cs" stem
+ cmdletname= sprintf "New-Xen%s" stem
; content=
gen_constructor obj classname (List.filter is_constructor messages)
}
; {
- filename= sprintf "Remove-Xen%sProperty.cs" stem
+ cmdletname= sprintf "Remove-Xen%sProperty" stem
; content= gen_remover obj classname (List.filter is_remover messages)
}
; {
- filename= sprintf "Add-Xen%s.cs" stem
+ cmdletname= sprintf "Add-Xen%s" stem
; content= gen_adder obj classname (List.filter is_adder messages)
}
; {
- filename= sprintf "Set-Xen%s.cs" stem
+ cmdletname= sprintf "Set-Xen%s" stem
; content= gen_setter obj classname (List.filter is_setter messages)
}
; {
- filename= sprintf "Get-Xen%sProperty.cs" stem
+ cmdletname= sprintf "Get-Xen%sProperty" stem
; content= gen_getter obj classname (List.filter is_getter messages)
}
; {
- filename= sprintf "Invoke-Xen%s.cs" stem
+ cmdletname= sprintf "Invoke-Xen%s" stem
; content= gen_invoker obj classname (List.filter is_invoke messages)
}
]
@@ -205,8 +262,10 @@ and gen_cmdlets obj =
cmdlets |> List.filter (fun x -> x.content <> "")
-and write_file filename content =
- let fn = Filename.concat destdir filename in
+and write_file cmdletname content =
+ let filename = sprintf "%s.cs" cmdletname in
+ let fn = Filename.concat srcdir filename in
+ cmdlets_to_export := cmdletname :: !cmdlets_to_export ;
with_output fn (fun x -> output_string x content)
(*********************************)
@@ -617,11 +676,13 @@ and gen_destructor obj =
; ("has_name", `Bool (has_name obj))
]
in
+ let cmdlet_name =
+ sprintf "Remove-Xen%s" (ocaml_class_to_csharp_class classname)
+ in
render_file
- ( "Remove-XenObject.mustache"
- , sprintf "Remove-Xen%s.cs" (ocaml_class_to_csharp_class classname)
- )
- json templdir destdir
+ ("Remove-XenObject.mustache", sprintf "%s.cs" cmdlet_name)
+ json templdir srcdir ;
+ cmdlets_to_export := cmdlet_name :: !cmdlets_to_export
| _ ->
assert false
diff --git a/ocaml/sdk-gen/powershell/autogen/XenServerPSModule.psd1 b/ocaml/sdk-gen/powershell/templates/XenServerPSModule.mustache
similarity index 90%
rename from ocaml/sdk-gen/powershell/autogen/XenServerPSModule.psd1
rename to ocaml/sdk-gen/powershell/templates/XenServerPSModule.mustache
index 968dfddce70..29336b1dec2 100644
--- a/ocaml/sdk-gen/powershell/autogen/XenServerPSModule.psd1
+++ b/ocaml/sdk-gen/powershell/templates/XenServerPSModule.mustache
@@ -37,7 +37,7 @@ GUID = 'D695A8B9-039A-443C-99A4-0D48D7C6AD76'
#Copyright
Author = ''
CompanyName = 'Cloud Software Group, Inc'
-Copyright = 'Copyright (c) 2013-2025 Cloud Software Group, Inc. All rights reserved.'
+Copyright = 'Copyright (c) 2013-2026 Cloud Software Group, Inc. All rights reserved.'
# Requirements
PowerShellVersion = '@PS_VERSION@'
@@ -67,7 +67,11 @@ FileList = @('about_XenServer.help.txt',
#Public interface
FunctionsToExport = ''
-CmdletsToExport = '*'
+CmdletsToExport = @(
+{{#cmdlets_to_export}}
+ '{{cmdlet_to_export}}'{{^is_last}},{{/is_last}}
+{{/cmdlets_to_export}}
+)
VariablesToExport = @('Citrix.XenServer.Sessions','XenServer_Default_Session')
AliasesToExport = '*'