From 3a4f26c3ccd2e81d8287e1d36527f07aab1250e7 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 9 Aug 2012 04:05:37 +0000 Subject: [PATCH] for item: clean up Utils.pm, the code in xCAT-server/lib/xcat/monitoring git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13466 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/monitoring/gangliamon.pm | 13 +++++++------ xCAT-server/lib/xcat/monitoring/monitorctrl.pm | 7 ++++--- xCAT-server/lib/xcat/monitoring/nagiosmon.pm | 17 +++++++++-------- xCAT-server/lib/xcat/monitoring/pcpmon.pm | 4 ++-- .../lib/xcat/monitoring/samples/templatemon.pm | 4 ++-- xCAT-server/lib/xcat/monitoring/snmpmon.pm | 17 +++++++++-------- xCAT-server/lib/xcat/monitoring/xcatmon.pm | 2 +- 7 files changed, 34 insertions(+), 30 deletions(-) diff --git a/xCAT-server/lib/xcat/monitoring/gangliamon.pm b/xCAT-server/lib/xcat/monitoring/gangliamon.pm index aa8926b0d..164da20fe 100755 --- a/xCAT-server/lib/xcat/monitoring/gangliamon.pm +++ b/xCAT-server/lib/xcat/monitoring/gangliamon.pm @@ -13,6 +13,7 @@ use xCAT::Utils; use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use xCAT::MsgUtils; +use xCAT::TableUtils; use strict; use warnings; 1; @@ -125,7 +126,7 @@ sub start { } # Identification of this node - my @hostinfo = xCAT::Utils->determinehostname(); + my @hostinfo = xCAT::NetworkUtils->determinehostname(); my $isSV = xCAT::Utils->isServiceNode(); my %iphash = (); foreach (@hostinfo) { @@ -290,7 +291,7 @@ sub confGmond { } # Identification of this node - my @hostinfo = xCAT::Utils->determinehostname(); + my @hostinfo = xCAT::NetworkUtils->determinehostname(); my $isSV = xCAT::Utils->isServiceNode(); my %iphash = (); foreach (@hostinfo) { @@ -348,7 +349,7 @@ sub confGmond { if ($scope) { my @children; - my $install_root = xCAT::Utils->getInstallDir(); + my $install_root = xCAT::TableUtils->getInstallDir(); foreach my $key ( keys(%$pPairHash) ) { my @key_a = split( ':', $key ); if ( !$iphash{ $key_a[0] } ) { @@ -473,7 +474,7 @@ sub confGmetad { return ( 1, "" ); } - my @hostinfo = xCAT::Utils->determinehostname(); + my @hostinfo = xCAT::NetworkUtils->determinehostname(); my $isSV = xCAT::Utils->isServiceNode(); my %iphash = (); foreach (@hostinfo) { $iphash{$_} = 1; } @@ -627,7 +628,7 @@ sub deconfGmond { } # Identification of this node - my @hostinfo = xCAT::Utils->determinehostname(); + my @hostinfo = xCAT::NetworkUtils->determinehostname(); my $isSV = xCAT::Utils->isServiceNode(); my %iphash = (); foreach (@hostinfo) { $iphash{$_} = 1; } @@ -827,7 +828,7 @@ sub stop { } #identification of this node - my @hostinfo = xCAT::Utils->determinehostname(); + my @hostinfo = xCAT::NetworkUtils->determinehostname(); my $isSV = xCAT::Utils->isServiceNode(); my %iphash = (); foreach (@hostinfo) { $iphash{$_} = 1; } diff --git a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm index 73673befa..cb8fcfe11 100644 --- a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm @@ -11,6 +11,7 @@ use xCAT::NodeRange; use xCAT::Table; use xCAT::MsgUtils; use xCAT::Utils; +use xCAT::TableUtils; use xCAT_plugin::notification; use xCAT_monitoring::montbhandler; use Sys::Hostname; @@ -824,7 +825,7 @@ sub isMonServer { if (ref($pHash) eq 'ARRAY') { return 0; } - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -883,7 +884,7 @@ sub getNodeMonServerPair { my %gnopts; if (scalar (@nodes) == 1) { $gnopts{prefetchcache}=1; } #if only doing one server, it seems probable that this was a Postage type scenario my $tabdata = $table2->getNodesAttribs(\@nodes,['monserver', 'servicenode', 'xcatmaster'],%gnopts); - my $sitemaster=xCAT::Utils->get_site_attribute('master'); + my $sitemaster=xCAT::TableUtils->get_site_attribute('master'); foreach my $node (@nodes) { my $monserver; my $monmaster; @@ -967,7 +968,7 @@ sub getMonHierarchy { foreach (@tmp3) { $temp_hash3{$_->{node}}=$_; } - my $sitemaster=xCAT::Utils->get_site_attribute('master'); + my $sitemaster=xCAT::TableUtils->get_site_attribute('master'); if (@tmp1 > 0) { foreach(@tmp1) { diff --git a/xCAT-server/lib/xcat/monitoring/nagiosmon.pm b/xCAT-server/lib/xcat/monitoring/nagiosmon.pm index 4ad96f066..c2452f792 100644 --- a/xCAT-server/lib/xcat/monitoring/nagiosmon.pm +++ b/xCAT-server/lib/xcat/monitoring/nagiosmon.pm @@ -15,6 +15,7 @@ use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use xCAT::MsgUtils; use xCAT::DBobjUtils; +use xCAT::TableUtils; use Data::Dumper; 1; @@ -191,7 +192,7 @@ sub config { my $localhostname=hostname(); #the identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSN=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -422,7 +423,7 @@ sub setup_nagios_cfg_sn { #create ncsa the commands my $ocsp_command="/usr/lib/nagios/plugins/eventhandler/submit_service_check_result"; my $ochp_command="/usr/lib/nagios/plugins/eventhandler/submit_host_check_result"; - my $master=xCAT::Utils->get_site_Master(); + my $master=xCAT::TableUtils->get_site_Master(); if (!$master) { my $rc=`grep XCATMASTER /opt/xcat/xcatinfo`; if ($rc && ($rc =~/^XCATMASTER=(.*)/)) { @@ -560,7 +561,7 @@ sub addNodes { my $callback=shift; print "nagiosmon.addNodes mon_nodes=@mon_nodes\n"; - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} my $localhostname=hostname(); @@ -756,7 +757,7 @@ sub removeNodes { my $callback=shift; print "nagiosmon.removeNodes mon_nodes=@mon_nodes\n"; - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} my $localhostname=hostname(); @@ -848,7 +849,7 @@ sub addGrandNodes { my $callback=shift; print "nagiosmon.addGrandNodes\n"; - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} my $localhostname=hostname(); @@ -1058,7 +1059,7 @@ sub removeGrandNodes { my $callback=shift; print "nagiosmon.removeGrandNodes\n"; - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} my $localhostname=hostname(); @@ -1156,7 +1157,7 @@ sub deconfig { my $localhostname=hostname(); #the identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSN=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -1272,7 +1273,7 @@ sub startNodeStatusMon { return (1, ""); } - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} if (!$isSN) { $iphash{'noservicenode'}=1;} diff --git a/xCAT-server/lib/xcat/monitoring/pcpmon.pm b/xCAT-server/lib/xcat/monitoring/pcpmon.pm index 0af1be3ed..0fdc7f405 100644 --- a/xCAT-server/lib/xcat/monitoring/pcpmon.pm +++ b/xCAT-server/lib/xcat/monitoring/pcpmon.pm @@ -135,7 +135,7 @@ sub start } #identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -299,7 +299,7 @@ sub stop #identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} diff --git a/xCAT-server/lib/xcat/monitoring/samples/templatemon.pm b/xCAT-server/lib/xcat/monitoring/samples/templatemon.pm index 2c6dc1d67..6dd03b0f8 100644 --- a/xCAT-server/lib/xcat/monitoring/samples/templatemon.pm +++ b/xCAT-server/lib/xcat/monitoring/samples/templatemon.pm @@ -96,7 +96,7 @@ sub start { if ($scope) { #demo how to get the children - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -164,7 +164,7 @@ sub stop { if ($scope) { #demo how to get the children - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} diff --git a/xCAT-server/lib/xcat/monitoring/snmpmon.pm b/xCAT-server/lib/xcat/monitoring/snmpmon.pm index 47c972191..98f1f3ec5 100644 --- a/xCAT-server/lib/xcat/monitoring/snmpmon.pm +++ b/xCAT-server/lib/xcat/monitoring/snmpmon.pm @@ -10,6 +10,7 @@ use strict; use IO::File; use xCAT::Utils; use xCAT::MsgUtils; +use xCAT::TableUtils; use xCAT::NodeRange; use xCAT_monitoring::monitorctrl; use Sys::Hostname; @@ -382,7 +383,7 @@ sub configBMC { my $ret_val=0; #the identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -464,7 +465,7 @@ sub configBMC { my $ref2=$masterhash{$_}; if (@$ref2==0) { next;} my $nr2=join(',', @$ref2); - my @tmp_a=xCAT::Utils::toIP($_); + my @tmp_a=xCAT::NetworkUtils::toIP($_); my $ptmp=$tmp_a[0]; if ($ptmp->[0]>0) { xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n"); @@ -517,7 +518,7 @@ sub configMPA { my $ret_text=""; #the identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -611,7 +612,7 @@ sub configMPA { my $ref2=$masterhash{$_}; if (@$ref2==0) { next;} my $nr2=join(',', @$ref2); - my @tmp_a=xCAT::Utils::toIP($_); + my @tmp_a=xCAT::NetworkUtils::toIP($_); my $ptmp=$tmp_a[0]; if ($ptmp->[0]>0) { xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n"); @@ -665,7 +666,7 @@ sub configSwitch { my $ret_val=0; #the identification of this node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my $isSV=xCAT::Utils->isServiceNode(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} @@ -765,7 +766,7 @@ sub configSwitch { my @a_temp=split(':',$pairs); my $monserver=$a_temp[0]; my $master=$a_temp[1]; - my @tmp_a=xCAT::Utils::toIP($master); + my @tmp_a=xCAT::NetworkUtils::toIP($master); my $ptmp=$tmp_a[0]; if ($ptmp->[0]>0) { xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n"); @@ -789,7 +790,7 @@ sub configSwitch { my @a_temp=split(':',$pairs); my $monserver=$a_temp[0]; my $master=$a_temp[1]; - my @tmp_a=xCAT::Utils::toIP($master); + my @tmp_a=xCAT::NetworkUtils::toIP($master); my $ptmp=$tmp_a[0]; if ($ptmp->[0]>0) { xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n"); @@ -839,7 +840,7 @@ sub configSwitch { sub configSNMP { print "configSNMP called \n"; my $isSN=xCAT::Utils->isServiceNode(); - my $master=xCAT::Utils->get_site_Master(); + my $master=xCAT::TableUtils->get_site_Master(); my $cmd; # now move /usr/share/snmp/snmptrapd.conf to /usr/share/snmp/snmptrapd.conf.orig # if it exists. diff --git a/xCAT-server/lib/xcat/monitoring/xcatmon.pm b/xCAT-server/lib/xcat/monitoring/xcatmon.pm index 895c3f837..04ed3b8de 100644 --- a/xCAT-server/lib/xcat/monitoring/xcatmon.pm +++ b/xCAT-server/lib/xcat/monitoring/xcatmon.pm @@ -301,7 +301,7 @@ sub getMonNodesStatus { my $isSV=xCAT::Utils->isServiceNode(); #on a service node or on ms, get the nodes that has local host as the server node - my @hostinfo=xCAT::Utils->determinehostname(); + my @hostinfo=xCAT::NetworkUtils->determinehostname(); my %iphash=(); foreach(@hostinfo) {$iphash{$_}=1;} #if this is mn, include the ones that has no service nodes