diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index a737fe30d..bc8a1d50b 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4476,24 +4476,23 @@ sub cleanup_for_powerLE_hardware_discovery { #This may be simply a mac address, which would be bound to the node name (such as "01:02:03:04:05:0E"). #This may also be a "|" delimited string of "mac address!hostname" format (such as "01:02:03:04:05:0E!node5|01:02:03:05:0F!node6-eth1"). sub parseMacTabEntry{ - my $macString=shift; - if( $macString =~ /xCAT::Utils/) { + if( $macString =~ /xCAT::Utils/){ $macString=shift; } - my $HostName=shift; + my $HostName=shift; my $mac_ret; my @macEntry=split(/\|/,$macString); - foreach my $mac_t (@macEntry){ - if($mac_t =~ /!/){ - if($mac_t =~ /(.+)!$HostName$/){ - $mac_ret=$1; - } - }else{ + unless($mac_t =~ /!/){ $mac_ret=$mac_t; } + + if($HostName and $mac_t =~ /(.+)\!$HostName$/){ + $mac_ret=$1; + last; + } } if ($mac_ret) { @@ -4501,10 +4500,11 @@ sub parseMacTabEntry{ $mac_ret =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; } } - + return $mac_ret; } + #The splitkcmdline subroutine is used to split the "persistent kernel options" #and "provision-time kernel options" out of the kernel cmdline string #Arguments: diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index 77ac57c72..535afed84 100755 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -14,7 +14,6 @@ require xCAT::TableUtils; require xCAT::NetworkUtils; use File::Basename; use File::Path; - use strict; use Exporter; our @ISA = qw/Exporter/; @@ -640,7 +639,7 @@ sub update_tables_with_templates #now get all the profile names for full installation my %profiles=(); - my @tmplfiles=glob($cuspath."/*.tmpl"); + my @tmplfiles=glob($cuspath."/{compute,service}.*tmpl"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' @@ -654,7 +653,7 @@ sub update_tables_with_templates #print "$tmpf\n"; $profiles{$tmpf}=1; } - @tmplfiles=glob($defpath."/*.tmpl"); + @tmplfiles=glob($defpath."/{compute,service}.*tmpl"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' @@ -845,7 +844,7 @@ sub update_tables_with_mgt_image #now get all the profile names for full installation my %profiles=(); - my @tmplfiles=glob($cuspath."/*.tmpl"); + my @tmplfiles=glob($cuspath."/{compute,service}.*tmpl"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' @@ -854,7 +853,7 @@ sub update_tables_with_mgt_image #print "$tmpf\n"; $profiles{$tmpf}=1; } - @tmplfiles=glob($defpath."/*.tmpl"); + @tmplfiles=glob($defpath."/{compute,service}.*tmpl"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' @@ -1049,7 +1048,7 @@ sub update_tables_with_diskless_image if ($profile) { $profiles{$profile} = 1; } else { - my @tmplfiles=glob($cuspath."/*.pkglist"); + my @tmplfiles=glob($cuspath."/compute.*pkglist"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' @@ -1057,7 +1056,7 @@ sub update_tables_with_diskless_image $tmpf = $1; $profiles{$tmpf}=1; } - @tmplfiles=glob($defpath."/*.pkglist"); + @tmplfiles=glob($defpath."/compute.*pkglist"); foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 88d47a65e..fff570b7e 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -335,6 +335,7 @@ sub subvars { $inc =~ s/#HOSTNAME#/$node/g; $inc =~ s/#SHORTNAME#/$shortname/g; $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg; + $inc =~ s/#GETPRINICMAC:([^#]+)#/xCAT::Utils::parseMacTabEntry(tabdb("mac",$1,"mac"),$1)/eg; my $nrtab = xCAT::Table->new("noderes"); my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']); diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 325f4666b..2c24fd90d 100755 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2337,10 +2337,6 @@ sub copycd #$callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); #} - my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite",$path,$osdistroname); - #if ($ret[0] != 0) { - #$callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); - #} } } } diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 91ab68bc8..d17063712 100755 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -119,7 +119,8 @@ sub bmcdiscovery_usage { push @{ $rsp->{data} }, "\t If there is bmc,bmcdiscover returns bmc ip or hostname, or else, it returns null. \n "; push @{ $rsp->{data} }, "\t Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 \n "; push @{ $rsp->{data} }, "\t2, bmcdiscover -i -u -p -c\n "; - push @{ $rsp->{data} }, "\t Note : check if bmc username and password are correct or not "; + push @{ $rsp->{data} }, "\t Note : check if bmc username and password are correct or not. If bmc has no username,\n"; + push @{ $rsp->{data} }, "\t use none instead, Ex: bmcdiscover -i p8bmc -u none -p passw0rd -c\n"; xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK ); return 0; @@ -262,7 +263,15 @@ sub check_auth_process{ my $bmstr4 = "BMC Session ID"; my $callback = $::CALLBACK; - my $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -U $bmcuser -P $bmcpw -H $bmcip chassis status "; + my $icmd; + if ( $bmcuser eq "none" ) + { + $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -P $bmcpw -H $bmcip chassis status "; + } + else + { + $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -U $bmcuser -P $bmcpw -H $bmcip chassis status "; + } my $output = xCAT::Utils->runcmd("$icmd", -1); if ( $output =~ $bmstr1 ) { diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index f8d6d836d..65b2cdbd5 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -430,10 +430,6 @@ sub copycd if ($ret[0] != 0) { $callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); } - my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite", $temppath, $osdistroname); - if ($ret[0] != 0) { - $callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); - } } } } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 5e0f491d1..84f586189 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -2042,10 +2042,6 @@ sub copycd $callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); } - my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite",$path,$osdistroname); - if ($ret[0] != 0) { - $callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); - } } } } diff --git a/xCAT-server/share/xcat/install/scripts/chroot.sles b/xCAT-server/share/xcat/install/scripts/chroot.sles index cf22e985a..f82f0113e 100644 --- a/xCAT-server/share/xcat/install/scripts/chroot.sles +++ b/xCAT-server/share/xcat/install/scripts/chroot.sles @@ -40,7 +40,7 @@ chmod 755 /tmp/updateflag.awk export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then - export PRINIC='#TABLE:mac:THISNODE:mac#' + export PRINIC='#GETPRINICMAC:THISNODE#' fi if [ -z "$PRINIC" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 5d54bc7d6..38dc53027 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -6,7 +6,7 @@ echo "post scripts" >/root/post.log export PRINIC=#TABLE:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then - export PRINIC='#TABLE:mac:THISNODE:mac#' + export PRINIC='#GETPRINICMAC:THISNODE#' fi if [ -z "$PRINIC" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common index f7a177061..cadc45d08 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rh.common +++ b/xCAT-server/share/xcat/install/scripts/post.rh.common @@ -7,7 +7,7 @@ echo "post scripts" >/root/post.log export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then - export PRINIC='#TABLE:mac:THISNODE:mac#' + export PRINIC='#GETPRINICMAC:THISNODE#' fi if [ -z "$PRINIC" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 80a6ea669..a8f86af22 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -6,7 +6,7 @@ echo "post scripts" >/root/post.log export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then - export PRINIC='#TABLE:mac:THISNODE:mac#' + export PRINIC='#GETPRINICMAC:THISNODE#' fi if [ -z "$PRINIC" ] then diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.sh b/xCAT-server/xCAT-wsapi/xcatws-test.sh index cbf8ebb4f..55049dad8 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.sh +++ b/xCAT-server/xCAT-wsapi/xcatws-test.sh @@ -41,14 +41,14 @@ function usage { echo " xcatws-test.sh -u -p [-t]" echo " xcatws-test.sh -u -p -h [-c] [-t]" echo " -u The username of xCAT user which is used to access xCAT resource" - echo " -p The password of username" + echo " -p The userPW of username" echo " The fully qualified hostname of xCAT management node. It can be an IP if using -k." echo " -c Check the server identity. The server certificate authentication must be enabled." echo " -t Using token authentication method." } if [ "$USER" = "" ] || [ "$PW" = "" ]; then - echo "Error: Miss username or password" + echo "Error: Miss username or userPW" usage exit 1 fi @@ -78,13 +78,13 @@ function REST { if [ "$token" = "yes" ]; then CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1" else - CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW" + CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&passwor=$PW" fi else if [ "$token" = "yes" ]; then CMD="curl -X $METHOD -k -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1" else - CMD="curl -X $METHOD -k $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW" + CMD="curl -X $METHOD -k $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&userPW=$PW" fi fi @@ -125,7 +125,7 @@ fi # get a token if [ "$token" = "yes" ]; then - TOKENID=$(curl -X POST -k "https://$HOST/xcatws/tokens?pretty=1" -H Content-Type:application/json --data "{\"userName\":\"$USER\",\"password\":\"$PW\"}" 2>/dev/null | grep '"id"' | awk -F: {'print $2'} | awk -F \" {'print $2'}) + TOKENID=$(curl -X POST -k "https://$HOST/xcatws/tokens?pretty=1" -H Content-Type:application/json --data "{\"userName\":\"$USER\",\"userPW\":\"$PW\"}" 2>/dev/null | grep '"id"' | awk -F: {'print $2'} | awk -F \" {'print $2'}) echo "** Using Token: $TOKENID to authenticate" fi diff --git a/xCAT-test/autotest/testcase/xdsh/cases0 b/xCAT-test/autotest/testcase/xdsh/cases0 index d1c8f8c54..a30722e49 100644 --- a/xCAT-test/autotest/testcase/xdsh/cases0 +++ b/xCAT-test/autotest/testcase/xdsh/cases0 @@ -73,11 +73,11 @@ check:rc==0 end start:xdsh_i_linux -cmd:XCATBYPASS=1 copycds $$ISO +cmd: copycds $$ISO check:rc==0 -cmd:XCATBYPASS=1 genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +cmd: genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 -cmd:XCATBYPASS=1 xdsh -i /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg "rpm -qa|grep uuid" +cmd: xdsh -i /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg "rpm -qa|grep uuid" check:rc==0 check:output=~libuuid end diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index c70ba64e5..ba4862b59 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -632,9 +632,17 @@ sub getnodeattr { my ($node, $attr) = @_; my @output = runcmd("lsdef -t node -o $node -i $attr"); + my $t ; if($::RUNCMD_RC){ - return "Unknown"; - }else{ + # return "Unknown"; + foreach $t (1 .. 40) { + log_this("could not get node attr $attr "); + @output = runcmd("lsdef -t node -o $node -i $attr"); + last if ($::RUNCMD_RC == 0); + } + + } + if($::RUNCMD_RC == 0){ foreach my $output1 (@output){ if($output1 =~ /$attr=(\w.+)/){ log_this("$attr is $1");