From 600ab740aea724065e0e6b311b795435e4107588 Mon Sep 17 00:00:00 2001 From: yinqing Date: Wed, 7 Aug 2013 13:29:25 +0800 Subject: [PATCH] #220993 Can not import node by auto discovery switch and switch port. --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 27 +++++++++++++++++++ xCAT-server/lib/xcat/plugins/profilednodes.pm | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 16fd6ae38..80f740384 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -550,6 +550,32 @@ sub get_allnode_singleattrib_hash #------------------------------------------------------------------------------- +=head3 get_db_swtiches + Description : Get all records of switch config from a table, then return a string list. + Arguments : $tabname - the table name. + Returns : Reference of the records hash. +=cut + +#------------------------------------------------------------------------------- +sub get_db_switches +{ + my $class = shift; + my $table = xCAT::Table->new("switches"); + my @attribs = ("switch"); + my @entries = $table->getAllAttribs(@attribs); + $table->close(); + my %allrecords; + foreach (@entries) + { + if ($_->{'switch'}){ + $allrecords{$_->{'switch'}} = 0; + } + } + return \%allrecords; +} + +#------------------------------------------------------------------------------- + =head3 get_db_swtichports Description : Get all records of switch config from a table, then return a string list. Arguments : $tabname - the table name. @@ -563,6 +589,7 @@ sub get_db_switchports my $table = xCAT::Table->new("switch"); my @attribs = ("switch", "port"); my @entries = $table->getAllAttribs(@attribs); + $table->close(); my %allrecords; foreach (@entries) { diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 7c0b273bd..9161577e5 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -370,7 +370,7 @@ Usage: my %allfspips = %$recordsref; # Get all switches name - $recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('switches', 'switch'); + $recordsref = xCAT::ProfiledNodeUtils->get_db_switches(); %allswitches = %$recordsref; # Get all switches_switchport