From 9e173d19ffe10751c03137ae9173a6856b92dc8e Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 21 Mar 2012 09:49:34 +0000 Subject: [PATCH] fixing bug 3490738: for getmacs -F option, mac address now can be with or without colon, uppercase and lowcase is also supported. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11929 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/FSPmac.pm | 19 +++++++++++++++---- perl-xCAT/xCAT/PPCmac.pm | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/perl-xCAT/xCAT/FSPmac.pm b/perl-xCAT/xCAT/FSPmac.pm index 07fc46149..eb14524f2 100644 --- a/perl-xCAT/xCAT/FSPmac.pm +++ b/perl-xCAT/xCAT/FSPmac.pm @@ -369,10 +369,21 @@ sub getmacs { # specified ######################################### if ( defined($filter) ) { - my $matched = 1; - foreach ( keys %$filter ) { - if ( $att{$_} ne $filter->{$_} ) { - $matched = 0; + my $matched = 0; + foreach my $key ( keys %$filter ) { + if ( $key eq "MAC_Address" ) { + my $mac = lc($att{$key}); + my $filter_mac = lc($filter->{$key}); + + $mac =~ s/://g; + $filter_mac =~ s/://g; + + if ( grep(/$filter_mac/, $mac) ) { + $matched = 1; + last; + } + } elsif ( grep(/$filter->{$key}/, $att{$key}) ) { + $matched = 1; last; } } diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index 724d9c584..3f7dc80bb 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -560,10 +560,21 @@ sub getmacs { # specified ######################################### if ( defined($filter) ) { - my $matched = 1; - foreach ( keys %$filter ) { - if ( $att{$_} ne $filter->{$_} ) { - $matched = 0; + my $matched = 0; + foreach my $key ( keys %$filter ) { + if ( $key eq "MAC_Address" ) { + my $mac = lc($att{$key}); + my $filter_mac = lc($filter->{$key}); + + $mac =~ s/://g; + $filter_mac =~ s/://g; + + if ( grep(/$filter_mac/, $mac) ) { + $matched = 1; + last; + } + } elsif ( grep(/$filter->{$key}/, $att{$key}) ) { + $matched = 1; last; } }