diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 16fd6ae38..4e7a7c759 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -550,6 +550,31 @@ 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 +588,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