From 8dc0908f92cc6186da35acc814b854bf88198a7f Mon Sep 17 00:00:00 2001 From: Adrian Jachacy Date: Wed, 3 Jul 2013 14:54:05 +0100 Subject: [PATCH] CP-5352: PR-1634: Request and consume list of SRs required to recover a VM / vApp, and add Resolve All button. 1. Added MethodExists method to Helpers class: this method tests wheather given method exists already. 2. Utilized new Helpers method in VM and VM_appliance classes. 3. Fixed ACTION_MULTIPLE_DR_TASK_CREATE_ messages. Signed-off-by: Adrian Jachacy --- XenModel/Messages.Designer.cs | 4 ++-- XenModel/Messages.resx | 4 ++-- XenModel/Utils/Helpers.cs | 12 ++++++++++++ XenModel/XenAPI-Extensions/VM.cs | 4 +++- XenModel/XenAPI-Extensions/VM_appliance.cs | 5 ++++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index baacf9352..6c5ae74d5 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -1096,7 +1096,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Preparing Storage Repositories. + /// Looks up a localized string similar to Storage Repositories prepared. /// public static string ACTION_MULTIPLE_DR_TASK_CREATE_END { get { @@ -1105,7 +1105,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Storage Repositories prepared. + /// Looks up a localized string similar to Preparing Storage Repositories. /// public static string ACTION_MULTIPLE_DR_TASK_CREATE_START { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index da359450f..aa1d5d207 100644 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -463,10 +463,10 @@ Moving {0} virtual disks to {1} - Preparing Storage Repositories + Storage Repositories prepared - Storage Repositories prepared + Preparing Storage Repositories Prepare Storage Repositories diff --git a/XenModel/Utils/Helpers.cs b/XenModel/Utils/Helpers.cs index b4a065c08..25d5106b9 100644 --- a/XenModel/Utils/Helpers.cs +++ b/XenModel/Utils/Helpers.cs @@ -1836,5 +1836,17 @@ namespace XenAdmin.Core return connection.Cache.Hosts.Any(h => h.enabled); } + + /// + /// Returns true if given method exists already; false otherwise + /// + /// + /// + /// + public static bool MethodExists(Session session, string methodName) + { + string[] methods = session.proxy.SystemListMethods(); + return methods.Contains(methodName); + } } } diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 56f058ef5..e6129c3e4 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -1423,7 +1423,9 @@ namespace XenAPI public static List> GetDRMissingSRs(Session session, string vm, string sessionTo) { - return VM.get_SRs_required_for_recovery(session, vm, sessionTo); + return Helpers.MethodExists(session, "VM.get_SRs_required_for_recovery") + ? VM.get_SRs_required_for_recovery(session, vm, sessionTo) + : null; } } diff --git a/XenModel/XenAPI-Extensions/VM_appliance.cs b/XenModel/XenAPI-Extensions/VM_appliance.cs index 1416adca3..40ad8a1a4 100644 --- a/XenModel/XenAPI-Extensions/VM_appliance.cs +++ b/XenModel/XenAPI-Extensions/VM_appliance.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Linq; +using XenAdmin.Core; namespace XenAPI { @@ -92,7 +93,9 @@ namespace XenAPI public static List> GetDRMissingSRs(Session session, string vm, string sessionTo) { - return VM_appliance.get_SRs_required_for_recovery(session, vm, sessionTo); + return Helpers.MethodExists(session, "VM_appliance.get_SRs_required_for_recovery") + ? VM_appliance.get_SRs_required_for_recovery(session, vm, sessionTo) + : null; } } }