diff --git a/XenAdmin/Dialogs/PropertiesDialog.cs b/XenAdmin/Dialogs/PropertiesDialog.cs index 1af7923bf..43dc648d6 100755 --- a/XenAdmin/Dialogs/PropertiesDialog.cs +++ b/XenAdmin/Dialogs/PropertiesDialog.cs @@ -322,7 +322,23 @@ private void Build() (connection.Session.IsLocalSuperuser || connection.Session.Roles.Any(r => r.name_label == Role.MR_ROLE_POOL_ADMIN))) { NRPEEditPage = new NRPEEditPage(); - ShowTab(NRPEEditPage); + bool nrpeAvailable = false; + using (var dialog = new ActionProgressDialog( + new DelegatedAsyncAction(connection, Messages.NRPE_PLUGIN_CHECKING, + Messages.NRPE_PLUGIN_CHECKING, Messages.NRPE_PLUGIN_CHECKED, + delegate (Session session) + { + nrpeAvailable = NRPEEditPage.IsNRPEAvailable(_xenObjectCopy); + }), + ProgressBarStyle.Continuous)) + { + dialog.ShowCancel = true; + dialog.ShowDialog(Program.MainWindow); + } + if (nrpeAvailable) + { + ShowTab(NRPEEditPage); + } } } finally diff --git a/XenAdmin/SettingsPanels/NRPEEditPage.cs b/XenAdmin/SettingsPanels/NRPEEditPage.cs index ffbde99d9..0020aa90e 100644 --- a/XenAdmin/SettingsPanels/NRPEEditPage.cs +++ b/XenAdmin/SettingsPanels/NRPEEditPage.cs @@ -42,6 +42,8 @@ namespace XenAdmin.SettingsPanels { public partial class NRPEEditPage : UserControl, IEditPage { + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly Regex REGEX_IPV4 = new Regex("^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)"); private static readonly Regex REGEX_IPV4_CIDR = new Regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}(\\/([0-9]|[1-2][0-9]|3[0-2]))?$"); private static readonly Regex REGEX_DOMAIN = new Regex("^(((?!-))(xn--|_)?[a-z0-9-]{0,61}[a-z0-9]{1,1}\\.)*(xn--)?([a-z0-9][a-z0-9\\-]{0,60}|[a-z0-9-]{1,30}\\.[a-z]{2,})$"); @@ -363,6 +365,22 @@ private void UpdateCurrentNRPEConfiguration() } } + public bool IsNRPEAvailable(IXenObject clone) + { + IXenObject o = clone is Pool p ? Helpers.GetCoordinator(p) : clone; + try + { + Host.call_plugin(o.Connection.Session, o.opaque_ref, NRPEHostConfiguration.XAPI_NRPE_PLUGIN_NAME, + NRPEHostConfiguration.XAPI_NRPE_STATUS, null); + return true; + } + catch (Exception e) + { + log.ErrorFormat("NRPE plugin checking failed, failed reason: {0}", e.Message); + return false; + } + } + private void EnableNRPECheckBox_CheckedChanged(object sender, EventArgs e) { UpdateComponentStatusBasedEnableNRPECheckBox(); diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 92325ebca..652bac6b9 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -29285,6 +29285,24 @@ public static string NRPE_INACTIVE { } } + /// + /// Looks up a localized string similar to Checking NRPE plugin status finished.. + /// + public static string NRPE_PLUGIN_CHECKED { + get { + return ResourceManager.GetString("NRPE_PLUGIN_CHECKED", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Checking NRPE plugin status.. + /// + public static string NRPE_PLUGIN_CHECKING { + get { + return ResourceManager.GetString("NRPE_PLUGIN_CHECKING", resourceCulture); + } + } + /// /// Looks up a localized string similar to Retrieve NRPE configuration failed, please check XenCenter logs.. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 6e390e156..0f19bf8f5 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10161,6 +10161,12 @@ When you configure an NFS storage repository, you simply provide the host name o NRPE service is inactive + + Checking NRPE plugin status finished. + + + Checking NRPE plugin status. + Retrieve NRPE configuration failed, please check XenCenter logs.