xenadmin/XenModel/XenAPI/ApiVersion.cs
Alexander Schulz cd477a4e18 Merge branch 'master' of https://github.com/xenserver/xenadmin into development
# Conflicts:
#	Branding/Branding.resx
#	Branding/HomePage.mht
#	Branding/HomePage.zh-CN.mht
#	Branding/Images/000_XenCenterAlerts_h32bit_24.png
#	Branding/Images/DlgBmp.bmp
#	Branding/Images/XS.png
#	Branding/Images/about_box_graphic_423x79.png
#	Branding/Images/alerts_32.png
#	Branding/Images/splash.bmp
#	Branding/Images/upsell_16.png
#	Branding/Images/wizard_background.png
#	CFUValidator/CFUValidator.csproj
#	Jenkinsfile
#	LICENSE
#	MAINTAINERS
#	README.md
#	WixInstaller/XenCenter.wxs
#	WixInstaller/branding.wxi
#	WixInstaller/codepagechange.vbs
#	WixInstaller/en-us.wxl
#	WixInstaller/ja-jp.wxl
#	WixInstaller/wix_src.patch
#	WixInstaller/zh-cn.wxl
#	XenAdmin.sln
#	XenAdmin/Commands/Controls/ContextMenuBuilder.cs
#	XenAdmin/Commands/Controls/MigrateVMToolStripMenuItem.cs
#	XenAdmin/Commands/Controls/VMLifeCycleToolStripMenuItem.cs
#	XenAdmin/Commands/CopyTemplateCommand.cs
#	XenAdmin/Commands/CopyVMCommand.cs
#	XenAdmin/Commands/CrossPoolCopyVMCommand.cs
#	XenAdmin/Commands/CrossPoolMigrateCommand.cs
#	XenAdmin/Commands/CrossPoolMoveVMCommand.cs
#	XenAdmin/Commands/DragDropCrossPoolMoveHaltedVMCommand.cs
#	XenAdmin/Commands/DragDropMigrateVMCommand.cs
#	XenAdmin/Commands/MoveVMCommand.cs
#	XenAdmin/ConsoleView/VNCTabView.cs
#	XenAdmin/Core/Updates.cs
#	XenAdmin/Dialogs/AboutDialog.resx
#	XenAdmin/Dialogs/LegalNoticesDialog.cs
#	XenAdmin/Dialogs/WarningDialogs/LicenseWarningDialog.ja.resx
#	XenAdmin/Dialogs/WarningDialogs/LicenseWarningDialog.resx
#	XenAdmin/Dialogs/WarningDialogs/LicenseWarningDialog.zh-CN.resx
#	XenAdmin/Help/HelpManager.cs
#	XenAdmin/Images.cs
#	XenAdmin/MainWindow.Designer.cs
#	XenAdmin/MainWindow.cs
#	XenAdmin/MainWindow.ja.resx
#	XenAdmin/MainWindow.resx
#	XenAdmin/MainWindow.zh-CN.resx
#	XenAdmin/Properties/Resources.Designer.cs
#	XenAdmin/Properties/Settings.Designer.cs
#	XenAdmin/Properties/Settings.settings
#	XenAdmin/SettingsPanels/BootOptionsEditPage.cs
#	XenAdmin/TabPages/GeneralTabPage.Designer.cs
#	XenAdmin/TabPages/GeneralTabPage.cs
#	XenAdmin/TabPages/GeneralTabPage.resx
#	XenAdmin/VNC/VNCException.cs
#	XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateDestinationPage.cs
#	XenAdmin/Wizards/CrossPoolMigrateWizard/CrossPoolMigrateWizard.cs
#	XenAdmin/Wizards/CrossPoolMigrateWizard/Filters/CrossPoolMigrateCanMigrateFilter.cs
#	XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs
#	XenAdmin/Wizards/NewSRWizard.cs
#	XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs
#	XenAdmin/XenAdmin.csproj
#	XenAdmin/app.config
#	XenAdminTests/ArchiveTests/ArchiveFactoryTests.cs
#	XenAdminTests/ArchiveTests/ArchiveIteratorTests.cs
#	XenAdminTests/ArchiveTests/ArchiveWriterTests.cs
#	XenAdminTests/ArchiveTests/ThirdPartyArchiveWriterTests.cs
#	XenAdminTests/CompressionTests/CompressionFactoryTests.cs
#	XenAdminTests/CompressionTests/ThirdPartyCompressionStreamTests.cs
#	XenAdminTests/HealthCheckTests/RequestUploadTaskTests.cs
#	XenAdminTests/UnitTests/CPUMaskingTest.cs
#	XenAdminTests/UnitTests/TimeUtilTests.cs
#	XenAdminTests/UnitTests/WlbTests/WlbPoolConfigurationTests.cs
#	XenAdminTests/UnitTests/WlbTests/WlbScheduledTaskTests.cs
#	XenAdminTests/UnitTests/WlbTests/WlbScheduledTasksTests.cs
#	XenAdminTests/XenAdminTests.csproj
#	XenModel/Actions/HealthCheck/GetHealthCheckAnalysisResultAction.cs
#	XenModel/Actions/HealthCheck/HealthCheckAuthenticationAction.cs
#	XenModel/Actions/HealthCheck/UploadServerStatusReportAction.cs
#	XenModel/Actions/HealthCheck/XenServerHealthCheckUpload.cs
#	XenModel/Actions/VM/ImportVmAction.cs
#	XenModel/Actions/VM/VMCrossPoolMigrateAction.cs
#	XenModel/Actions/VM/VMPauseAction.cs
#	XenModel/FriendlyNames.Designer.cs
#	XenModel/FriendlyNames.ja.resx
#	XenModel/FriendlyNames.resx
#	XenModel/FriendlyNames.zh-CN.resx
#	XenModel/HealthCheckSettings.cs
#	XenModel/InvisibleMessages.Designer.cs
#	XenModel/InvisibleMessages.ja.resx
#	XenModel/InvisibleMessages.resx
#	XenModel/InvisibleMessages.zh-CN.resx
#	XenModel/Messages.Designer.cs
#	XenModel/Messages.ja.resx
#	XenModel/Messages.resx
#	XenModel/Messages.zh-CN.resx
#	XenModel/SshConsole.cs
#	XenModel/Utils/Helpers.cs
#	XenModel/XenAPI-Extensions/SR.cs
#	XenModel/XenAPI/ApiVersion.cs
#	XenModel/XenModel.csproj
#	XenServerHealthCheck/Registry.cs
#	scripts/check_copyright.ps1
#	scripts/check_i18n.ps1
#	scripts/check_spelling.ps1
#	scripts/deps-map.json
#	scripts/dictionary.txt
#	scripts/download_hotfixes.ps1
#	scripts/download_packages.ps1
#	scripts/hotfix-map.json
#	splash/util.h
#	xe/Xe.csproj
#	xe/app.manifest
2023-12-30 16:43:15 +01:00

187 lines
7.1 KiB
C#

/*
* Copyright (c) Cloud Software Group, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1) Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
namespace XenAPI
{
public enum API_Version
{
API_1_1 = 1, //XenServer 4.0 (rio)
API_1_2 = 2, //XenServer 4.1 (miami)
API_1_3 = 3, //XenServer 5.0 (orlando)
API_1_4 = 4, //Unreleased ()
API_1_5 = 5, //XenServer 5.0 update 3 ()
API_1_6 = 6, //XenServer 5.5 (george)
API_1_7 = 7, //XenServer 5.6 (midnight-ride)
API_1_8 = 8, //XenServer 5.6 FP1 (cowley)
API_1_9 = 9, //XenServer 6.0 (boston)
API_1_10 = 10, //XenServer 6.1 (tampa)
API_2_0 = 11, //XenServer 6.2 (clearwater)
API_2_1 = 12, //XenServer 6.2 SP1 (vgpu-productisation)
API_2_2 = 13, //XenServer 6.2 SP1 Hotfix 4 (clearwater-felton)
API_2_3 = 14, //XenServer 6.5 (creedence)
API_2_4 = 15, //XenServer 6.5 SP1 (cream)
API_2_5 = 16, //XenServer 7.0 (dundee)
API_2_6 = 17, //XenServer 7.1 (ely)
API_2_7 = 18, //XenServer 7.2 (falcon)
API_2_8 = 19, //XenServer 7.3 (inverness)
API_2_9 = 20, //XenServer 7.4 (jura)
API_2_10 = 21, //XenServer 7.5 (kolkata)
API_2_11 = 22, //XenServer 7.6 (lima)
API_2_12 = 23, //Citrix Hypervisor 8.0 (naples)
API_2_13 = 24, //Unreleased (oslo)
API_2_14 = 25, //Citrix Hypervisor 8.1 (quebec)
API_2_15 = 26, //Citrix Hypervisor 8.2 (stockholm)
API_2_16 = 27, //unreleased (stockholm)
LATEST = 27,
UNKNOWN = 99
}
public static partial class Helper
{
public static string APIVersionString(API_Version v)
{
switch (v)
{
case API_Version.API_1_1:
return "1.1";
case API_Version.API_1_2:
return "1.2";
case API_Version.API_1_3:
return "1.3";
case API_Version.API_1_4:
return "1.4";
case API_Version.API_1_5:
return "1.5";
case API_Version.API_1_6:
return "1.6";
case API_Version.API_1_7:
return "1.7";
case API_Version.API_1_8:
return "1.8";
case API_Version.API_1_9:
return "1.9";
case API_Version.API_1_10:
return "1.10";
case API_Version.API_2_0:
return "2.0";
case API_Version.API_2_1:
return "2.1";
case API_Version.API_2_2:
return "2.2";
case API_Version.API_2_3:
return "2.3";
case API_Version.API_2_4:
return "2.4";
case API_Version.API_2_5:
return "2.5";
case API_Version.API_2_6:
return "2.6";
case API_Version.API_2_7:
return "2.7";
case API_Version.API_2_8:
return "2.8";
case API_Version.API_2_9:
return "2.9";
case API_Version.API_2_10:
return "2.10";
case API_Version.API_2_11:
return "2.11";
case API_Version.API_2_12:
return "2.12";
case API_Version.API_2_13:
return "2.13";
case API_Version.API_2_14:
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";
default:
return "Unknown";
}
}
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));
}
catch (ArgumentException)
{
return API_Version.UNKNOWN;
}
}
/// <summary>
/// Converts the string representation of an API version number to its API_Version equivalent.
/// This function assumes that API version numbers are of form a.b
/// </summary>
public static API_Version GetAPIVersion(string version)
{
if (version != null)
{
string[] tokens = version.Split('.');
int major, 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;
}
}
}