From c55eacef62d9692d0d16349144d214e4958acb3e Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 11 Jul 2008 20:09:29 +0000 Subject: [PATCH] fixed the code so that the moncfgmaster function is not dispatched to the service nodes when not needed. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1871 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../lib/xcat/monitoring/monitorctrl.pm | 40 ++++++++++++++++++- xCAT-server/lib/xcat/plugins/monctrlcmds.pm | 5 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm index 721b8efb4..d7543744b 100644 --- a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm @@ -1328,7 +1328,45 @@ sub configMaster4Nodes { return ($retcode, $message); } - +#-------------------------------------------------------------------------------- +=head3 shouldConfigMaster + This function goes to every monitoring plug-in module to check if + anyone implements the configMaster4Nodes function. + Arguments: + none + Returns: + 1, if any monitoring plug-in module implements the configMaster4Nodes fucntion. + 0. if none. +=cut +#-------------------------------------------------------------------------------- +sub shouldConfigMaster { + + #get all the module names from /opt/xcat/lib/perl/XCAT_monitoring directory + my %names=(); + my @plugins=glob("$::XCATROOT/lib/perl/xCAT_monitoring/*.pm"); + foreach (@plugins) { + /.*\/([^\/]*).pm$/; + $names{$1}=1; + } + # remove 2 files that are not plug-ins + delete($names{monitorctrl}); + delete($names{montbhandler}); + + #get node conf data from each plug-in module + foreach my $pname (keys(%names)) { + my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/$pname.pm"; + my $module_name="xCAT_monitoring::$pname"; + #load the module in memory + eval {require($file_name)}; + if (!$@) { + if (defined(${$module_name."::"}{configMaster4Nodes})) { + return 1; + } + } + } + + return 0; +} diff --git a/xCAT-server/lib/xcat/plugins/monctrlcmds.pm b/xCAT-server/lib/xcat/plugins/monctrlcmds.pm index 60a1710a1..3d074504b 100644 --- a/xCAT-server/lib/xcat/plugins/monctrlcmds.pm +++ b/xCAT-server/lib/xcat/plugins/monctrlcmds.pm @@ -69,6 +69,11 @@ sub preprocess_request my $reqcopy = {%$req}; push @requests, $reqcopy; } else { + if (! xCAT_monitoring::monitorctrl->shouldConfigMaster()) { + $req = {}; + return; + } + my $nodes = $req->{node}; my $noderef=xCAT_monitoring::monitorctrl->getMonServer($nodes);