From 4d5734558bd78f71e576e5946256cbc758863bd7 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 16 Jun 2016 03:47:51 -0400 Subject: [PATCH 1/2] issue1308 lsdef and Rest API issues with regex on nicks --- perl-xCAT/xCAT/DBobjUtils.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index f71625898..780f5fbcc 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2458,6 +2458,10 @@ sub expandnicsattr() # Value: eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 my $nicval=$2; + #In the lsdef, remove the ^| and |$ before displaying + $nicval=~s/(^\||\|$)//g; + + # $nicarr[0]: eth0!1.1.1.1|2.1.1.1 # $nicarr[1]: eth1!3.1.1.1|4.1.1.1 my @nicarr = split(/,/, $nicval); From 705a45b6d92b8cc22805560c4e8a6e8e2b9bf6fa Mon Sep 17 00:00:00 2001 From: bybai Date: Fri, 17 Jun 2016 03:01:39 -0400 Subject: [PATCH 2/2] polish --- perl-xCAT/xCAT/DBobjUtils.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 780f5fbcc..65843aacd 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2458,9 +2458,22 @@ sub expandnicsattr() # Value: eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 my $nicval=$2; - #In the lsdef, remove the ^| and |$ before displaying - $nicval=~s/(^\||\|$)//g; - + #if there is regrex in nicips + if (($nicval) && ($nicval =~ /^\|(.*?)\|$/)) { + + #$nicval Value: |node(d+)|eth0!192.1.1.($1+10)| or + # |eth0!192.1.1.($1+10),bond0!10.28.41.($1+10)| + #In the lsdef, remove the ^| and |$ before displaying + $nicval=~s/(^\||\|$)//g; + + #$nicval Value: node(d+)|eth0!192.1.1.($1+10) + if (($nicval) && ($nicval =~ /\|/)) { + my ($str1,$str2)=split('\|', $nicval); + + #$nivval Value: eth0!192.1.1.($1+10) + $nicval=$str2; + } + } # $nicarr[0]: eth0!1.1.1.1|2.1.1.1 # $nicarr[1]: eth1!3.1.1.1|4.1.1.1