Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 13 additions & 33 deletions XenModel/XenAPI/ApiVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
*/

using System;
using System.Collections;
using System.Collections.Generic;


namespace XenAPI
{
Expand Down Expand Up @@ -88,12 +85,12 @@ public enum API_Version
API_2_14 = 25,
/// <summary>Citrix Hypervisor 8.2 (stockholm)</summary>
API_2_15 = 26,
/// <summary>XCP-ng 8.2</summary>
API_2_16 = 27,
/// <summary>XCP-ng 8.3</summary>
API_2_20 = 28,
/// <summary>XCP-ng 8.3</summary>
API_2_21 = 29,
/// <summary>XenServer 8 Preview (nile-preview)</summary>
API_2_20 = 27,
/// <summary>XenServer 8 (nile)</summary>
API_2_21 = 28,
/// <summary>XenServer 9 (orinoco)</summary>
API_2_23 = 29,
LATEST = 29,
UNKNOWN = 99
}
Expand Down Expand Up @@ -156,12 +153,12 @@ public static string APIVersionString(API_Version v)
return "2.14";
case API_Version.API_2_15:
return "2.15";
case API_Version.API_2_16:
return "2.16";
case API_Version.API_2_20:
return "2.20";
case API_Version.API_2_21:
return "2.21";
case API_Version.API_2_23:
return "2.23";
default:
return "Unknown";
}
Expand All @@ -171,8 +168,7 @@ public static API_Version GetAPIVersion(long major, long minor)
{
try
{
return (API_Version)Enum.Parse(typeof(API_Version),
string.Format("API_{0}_{1}", major, minor));
return (API_Version)Enum.Parse(typeof(API_Version), $"API_{major}_{minor}");
}
catch (ArgumentException)
{
Expand All @@ -190,30 +186,14 @@ public static API_Version GetAPIVersion(string version)
{
string[] tokens = version.Split('.');
int major, minor;
if (tokens.Length == 2 && int.TryParse(tokens[0], out major) && int.TryParse(tokens[1], out minor))
if (tokens.Length == 2 &&
int.TryParse(tokens[0], out major) &&
int.TryParse(tokens[1], out minor))
{
return GetAPIVersion(major, minor);
}
}
return API_Version.UNKNOWN;
}

/// <summary>
/// Return a positive number if the given session's API version is greater than the given
/// API_version, negative if it is less, and 0 if they are equal.
/// </summary>
internal static int APIVersionCompare(Session session, API_Version v)
{
return (int)session.APIVersion - (int)v;
}

/// <summary>
/// Return true if the given session's API version is greater than or equal to the given
/// API_version.
/// </summary>
internal static bool APIVersionMeets(Session session, API_Version v)
{
return APIVersionCompare(session, v) >= 0;
}
}
}
}
23 changes: 10 additions & 13 deletions XenModel/XenAPI/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,30 @@ public bool DeepEquals(Auth other)
return false;
}

public override string SaveChanges(Session session, string opaqueRef, Auth server)
{
if (opaqueRef == null)
{
System.Diagnostics.Debug.Assert(false, "Cannot create instances of this type on the server");
return "";
}
else
{
throw new InvalidOperationException("This type has no read/write properties");
}
}

/// <summary>
/// This call queries the external directory service to obtain the subject_identifier as a string from the human-readable subject_name
/// First published in XenServer 5.5.
/// </summary>
/// <param name="session">The session</param>
/// <param name="_subject_name">The human-readable subject_name, such as a username or a groupname</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string get_subject_identifier(Session session, string _subject_name)
{
return session.JsonRpcClient.auth_get_subject_identifier(session.opaque_ref, _subject_name);
}

/// <summary>
/// This call queries the external directory service to obtain the user information (e.g. username, organization etc) from the specified subject_identifier
/// This call queries the external directory service to obtain the user information (for example, username, organization etc.) from the specified subject_identifier
/// First published in XenServer 5.5.
/// </summary>
/// <param name="session">The session</param>
/// <param name="_subject_identifier">A string containing the subject_identifier, unique in the external directory service</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static Dictionary<string, string> get_subject_information_from_identifier(Session session, string _subject_identifier)
{
return session.JsonRpcClient.auth_get_subject_information_from_identifier(session.opaque_ref, _subject_identifier);
Expand All @@ -134,6 +128,9 @@ public static Dictionary<string, string> get_subject_information_from_identifier
/// </summary>
/// <param name="session">The session</param>
/// <param name="_subject_identifier">A string containing the subject_identifier, unique in the external directory service</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string[] get_group_membership(Session session, string _subject_identifier)
{
return session.JsonRpcClient.auth_get_group_membership(session.opaque_ref, _subject_identifier);
Expand Down
77 changes: 55 additions & 22 deletions XenModel/XenAPI/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,16 @@ public bool DeepEquals(Blob other)
Helper.AreEqual2(_mime_type, other._mime_type);
}

public override string SaveChanges(Session session, string opaqueRef, Blob server)
{
if (opaqueRef == null)
{
System.Diagnostics.Debug.Assert(false, "Cannot create instances of this type on the server");
return "";
}
else
{
if (!Helper.AreEqual2(_name_label, server._name_label))
{
Blob.set_name_label(session, opaqueRef, _name_label);
}
if (!Helper.AreEqual2(_name_description, server._name_description))
{
Blob.set_name_description(session, opaqueRef, _name_description);
}

return null;
}
}

/// <summary>
/// Get a record containing the current state of the given blob.
/// First published in XenServer 5.0.
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static Blob get_record(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_record(session.opaque_ref, _blob);
Expand All @@ -176,6 +158,9 @@ public static Blob get_record(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_uuid">UUID of object to return</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static XenRef<Blob> get_by_uuid(Session session, string _uuid)
{
return session.JsonRpcClient.blob_get_by_uuid(session.opaque_ref, _uuid);
Expand All @@ -187,6 +172,9 @@ public static XenRef<Blob> get_by_uuid(Session session, string _uuid)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_label">label of object to return</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static List<XenRef<Blob>> get_by_name_label(Session session, string _label)
{
return session.JsonRpcClient.blob_get_by_name_label(session.opaque_ref, _label);
Expand All @@ -198,6 +186,9 @@ public static List<XenRef<Blob>> get_by_name_label(Session session, string _labe
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string get_uuid(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_uuid(session.opaque_ref, _blob);
Expand All @@ -209,6 +200,9 @@ public static string get_uuid(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string get_name_label(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_name_label(session.opaque_ref, _blob);
Expand All @@ -220,6 +214,9 @@ public static string get_name_label(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string get_name_description(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_name_description(session.opaque_ref, _blob);
Expand All @@ -231,6 +228,9 @@ public static string get_name_description(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static long get_size(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_size(session.opaque_ref, _blob);
Expand All @@ -242,6 +242,9 @@ public static long get_size(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static bool get_public(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_public(session.opaque_ref, _blob);
Expand All @@ -253,6 +256,9 @@ public static bool get_public(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static DateTime get_last_updated(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_last_updated(session.opaque_ref, _blob);
Expand All @@ -264,6 +270,9 @@ public static DateTime get_last_updated(Session session, string _blob)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static string get_mime_type(Session session, string _blob)
{
return session.JsonRpcClient.blob_get_mime_type(session.opaque_ref, _blob);
Expand All @@ -276,6 +285,9 @@ public static string get_mime_type(Session session, string _blob)
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <param name="_label">New value to set</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static void set_name_label(Session session, string _blob, string _label)
{
session.JsonRpcClient.blob_set_name_label(session.opaque_ref, _blob, _label);
Expand All @@ -288,6 +300,9 @@ public static void set_name_label(Session session, string _blob, string _label)
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <param name="_description">New value to set</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static void set_name_description(Session session, string _blob, string _description)
{
session.JsonRpcClient.blob_set_name_description(session.opaque_ref, _blob, _description);
Expand All @@ -300,6 +315,9 @@ public static void set_name_description(Session session, string _blob, string _d
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <param name="_public">New value to set</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static void set_public(Session session, string _blob, bool _public)
{
session.JsonRpcClient.blob_set_public(session.opaque_ref, _blob, _public);
Expand All @@ -311,6 +329,9 @@ public static void set_public(Session session, string _blob, bool _public)
/// </summary>
/// <param name="session">The session</param>
/// <param name="_mime_type">The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static XenRef<Blob> create(Session session, string _mime_type)
{
return session.JsonRpcClient.blob_create(session.opaque_ref, _mime_type);
Expand All @@ -323,6 +344,9 @@ public static XenRef<Blob> create(Session session, string _mime_type)
/// <param name="session">The session</param>
/// <param name="_mime_type">The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied</param>
/// <param name="_public">True if the blob should be publicly available First published in XenServer 6.1.</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static XenRef<Blob> create(Session session, string _mime_type, bool _public)
{
return session.JsonRpcClient.blob_create(session.opaque_ref, _mime_type, _public);
Expand All @@ -334,6 +358,9 @@ public static XenRef<Blob> create(Session session, string _mime_type, bool _publ
/// </summary>
/// <param name="session">The session</param>
/// <param name="_blob">The opaque_ref of the given blob</param>
/// <remarks>
/// Minimum allowed role: pool-operator
/// </remarks>
public static void destroy(Session session, string _blob)
{
session.JsonRpcClient.blob_destroy(session.opaque_ref, _blob);
Expand All @@ -344,16 +371,22 @@ public static void destroy(Session session, string _blob)
/// First published in XenServer 5.0.
/// </summary>
/// <param name="session">The session</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static List<XenRef<Blob>> get_all(Session session)
{
return session.JsonRpcClient.blob_get_all(session.opaque_ref);
}

/// <summary>
/// Get all the blob Records at once, in a single XML RPC call
/// Return a map of blob references to blob records for all blobs known to the system.
/// First published in XenServer 5.0.
/// </summary>
/// <param name="session">The session</param>
/// <remarks>
/// Minimum allowed role: read-only
/// </remarks>
public static Dictionary<XenRef<Blob>, Blob> get_all_records(Session session)
{
return session.JsonRpcClient.blob_get_all_records(session.opaque_ref);
Expand Down
Loading
Loading