From 3ad0eb8f16a96d10fa42df54367fe5f4b34a29ea Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 7 May 2014 11:07:15 -0400 Subject: [PATCH 01/26] defect 4091 remove linux ifconfig calls --- perl-xCAT/xCAT/NetworkUtils.pm | 255 +++++++++++---------------------- 1 file changed, 82 insertions(+), 173 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 1bd6397e0..c3555833d 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -643,16 +643,11 @@ sub get_nic_ip { my $nic; my %iphash; - my $cmd = "ifconfig -a"; - my $result = `$cmd`; my $mode = "MULTICAST"; + my $payingattention=0; + my $interface; + my $keepcurrentiface; - ############################################# - # Error running command - ############################################# - if ( !$result ) { - return undef; - } if (xCAT::Utils->isAIX()) { ############################################################## @@ -664,6 +659,14 @@ sub get_nic_ip # en1: ... # ############################################################## + my $cmd = "ifconfig -a"; + my $result = `$cmd`; + ############################################# + # Error running command + ############################################# + if ( !$result ) { + return undef; + } my @adapter = split /(\w+\d+):\s+flags=/, $result; foreach ( @adapter ) { if ($_ =~ /^(en\d)/) { @@ -683,44 +686,39 @@ sub get_nic_ip } } } - else { - ############################################################## - # Should look like this for Linux: - # eth0 Link encap:Ethernet HWaddr 00:02:55:7B:06:30 - # inet addr:9.114.154.193 Bcast:9.114.154.223 - # inet6 addr: fe80::202:55ff:fe7b:630/64 Scope:Link - # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - # RX packets:1280982 errors:0 dropped:0 overruns:0 frame:0 - # TX packets:3535776 errors:0 dropped:0 overruns:0 carrier:0 - # collisions:0 txqueuelen:1000 - # RX bytes:343489371 (327.5 MiB) TX bytes:870969610 (830.6 MiB) - # Base address:0x2600 Memory:fbfe0000-fc0000080 - # - # eth1 ... - # Redhat7 - #eth0: flags=4163 mtu 1500 - # inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255 - # - ############################################################## - my @adapter= split /\n{2,}/, $result; - foreach ( @adapter ) { - if ( !($_ =~ /LOOPBACK/ ) and - $_ =~ /UP( |,|>)/ and - $_ =~ /$mode/ ) { - my @ip = split /\n/; - for my $ent ( @ip ) { - if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) { - $nic = $1; - } - if ($ent =~ /^(eth\d:|ib\d:|hf\d:)\s+/) { - $nic = $1; - } - $ent=~ s/addr://; # works for Redhat7 also - if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { - $iphash{$nic} = $1; - next; - } + else { # linux + my @ipoutput = `ip addr`; + ############################################# + # Error running command + ############################################# + if ( !@ipoutput ) { + return undef; + } + foreach my $line (@ipoutput) { + if ($line =~ /^\d/) { # new interface, new context.. + if ($interface and not $keepcurrentiface) { + #don't bother reporting unusable nics + delete $iphash{$interface}; } + $keepcurrentiface=0; + if ( !($line =~ /LOOPBACK/ ) and + $line =~ /UP( |,|>)/ and + $line =~ /$mode/ ) { + + $payingattention=1; + $line =~ /^([^:]*): ([^:]*):/; + $interface=$2; + } else { + $payingattention=0; + next; + } + } + unless ($payingattention) { next; } + if ($line =~ /inet/) { + $keepcurrentiface=1; + } + if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { + $iphash{$interface} = $1; } } } @@ -1593,7 +1591,7 @@ sub thishostisnot #----------------------------------------------------------------------------- =head3 gethost_ips (AIX and Linux) - Will use ifconfig to determine all possible ip addresses for the + Will use ifconfig or ip addr to determine all possible ip addresses for the host it is running on and then gethostbyaddr to get all possible hostnames input: @@ -1608,52 +1606,57 @@ sub gethost_ips my ($class) = @_; my $cmd; my @ipaddress; - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet\""; + if (xCAT::Utils->isLinux()) { + $cmd = "ip addr "; + $cmd = $cmd . "| grep \"inet\""; + } else { # AIX + $cmd = "ifconfig" . " -a"; + $cmd = $cmd . "| grep \"inet\""; + } my @result = xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("S", "Error from $cmd\n"); exit $::RUNCMD_RC; } - foreach my $addr (@result) - { + if (xCAT::Utils->isLinux()) { + foreach (@result) + { my @ip; - if (xCAT::Utils->isLinux()) + if (/inet6/) { - if ($addr =~ /inet6/) + #TODO, Linux ipv6 + } + else + { + my @ents = split(/\s+/); + my $ip = $ents[2]; + $ip =~ s/\/.*//; + $ip =~ s/\%.*//; + push @ipaddress, $ip; + } + } + } else { #AIX + foreach my $addr (@result) + { + if ($addr =~ /inet6/) + { + $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; + my $v6ip = $1; + my $v6mask = $2; + if ($v6ip) { - #TODO, Linux ipv6 - } - else - { - my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); - #@ip = split(":", $addr1); - #push @ipaddress, $ip[1]; - $addr1 =~ s/.*://; - push @ipaddress, $addr1; + push @ipaddress, $v6ip; } } else - { #AIX - if ($addr =~ /inet6/) - { - $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; - my $v6ip = $1; - my $v6mask = $2; - if ($v6ip) - { - push @ipaddress, $v6ip; - } - } - else - { - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - push @ipaddress, $addr1; - } - + { + my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = + split(" ", $addr); + push @ipaddress, $addr1; } + + } } my @names = @ipaddress; foreach my $ipaddr (@names) @@ -1844,100 +1847,6 @@ sub validate_ip return([0]); } -#------------------------------------------------------------------------------- - -=head3 getFacingIP - Gets the ip address of the adapter of the localhost that is facing the - the given node. - Assume it is the same as my_ip_facing... - Arguments: - The name of the node that is facing the localhost. - Returns: - The ip address of the adapter that faces the node. - -=cut - -#------------------------------------------------------------------------------- -sub getFacingIP -{ - my ($class, $node) = @_; - my $ip; - my $cmd; - my @ipaddress; - - my $nodeip = inet_ntoa(inet_aton($node)); - unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) - { - return 0; #Not supporting IPv6 here IPV6TODO - } - - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet \""; - my @result = xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - # split node address - my ($n1, $n2, $n3, $n4) = split('\.', $nodeip); - - foreach my $addr (@result) - { - my $ip; - my $mask; - if (xCAT::Utils->isLinux()) - { - my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); - if ((!$addr1) || (!$Mask)) { next; } - my @ips = split(":", $addr1); - my @masks = split(":", $Mask); - $ip = $ips[1]; - $mask = $masks[1]; - } - else - { #AIX - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - if ((!$addr1) && (!$mask1)) { next; } - $ip = $addr1; - $mask1 =~ s/0x//; - $mask = - `printf "%d.%d.%d.%d" \$(echo "$mask1" | sed 's/../0x& /g')`; - } - - if ($ip && $mask) - { - - # split interface IP - my ($h1, $h2, $h3, $h4) = split('\.', $ip); - - # split mask - my ($m1, $m2, $m3, $m4) = split('\.', $mask); - - # AND this interface IP with the netmask of the network - my $a1 = ((int $h1) & (int $m1)); - my $a2 = ((int $h2) & (int $m2)); - my $a3 = ((int $h3) & (int $m3)); - my $a4 = ((int $h4) & (int $m4)); - - # AND node IP with the netmask of the network - my $b1 = ((int $n1) & (int $m1)); - my $b2 = ((int $n2) & (int $m2)); - my $b3 = ((int $n3) & (int $m3)); - my $b4 = ((int $n4) & (int $m4)); - - if (($b1 == $a1) && ($b2 == $a2) && ($b3 == $a3) && ($b4 == $a4)) - { - return $ip; - } - } - } - - xCAT::MsgUtils->message("S", "Cannot find master for the node $node\n"); - return 0; -} #------------------------------------------------------------------------------- From 1f48dcea9c19378af4c87ccf4651a86612726df0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 7 May 2014 14:17:00 -0400 Subject: [PATCH 02/26] Recognize Win2012R2 media --- xCAT-server/lib/xcat/plugins/windows.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/windows.pm b/xCAT-server/lib/xcat/plugins/windows.pm index dd4ac7f76..102e07fe2 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -742,6 +742,12 @@ sub copycd $darch = "x86_64"; } elsif (/BuildBranch=win7_rtm/){ $distname = "win7"; + } elsif (/BuildBranch=winblue_rtm/){ + if (-r $mntpath . "/sources/background_svr.bmp") { + if (! -r $mntpath . "/sources/EI.CFG") { + $distname = "win2012r2"; + } + } } elsif (/BuildBranch=win8_rtm/){ if (-r $mntpath . "/sources/background_cli.bmp") { $distname = "win8"; From 8af243775a04944b46c752e7ef100f9cc0f4b397 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 02:48:21 -0700 Subject: [PATCH 03/26] Add test script restapitest to xcat-test --- xCAT-test/xCAT-test.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-test/xCAT-test.spec b/xCAT-test/xCAT-test.spec index 5672ed42f..2aa2bcc4c 100644 --- a/xCAT-test/xCAT-test.spec +++ b/xCAT-test/xCAT-test.spec @@ -39,6 +39,7 @@ pod2html pods/man1/xcattest.1.pod > share/doc/man1/xcattest.1.html rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin +mkdir -p $RPM_BUILD_ROOT/%{prefix}/sbin mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1 mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1 @@ -46,6 +47,9 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1 cp xcattest $RPM_BUILD_ROOT/%{prefix}/bin chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/* +cp restapitest $RPM_BUILD_ROOT/%{prefix}/sbin +chmod 755 $RPM_BUILD_ROOT/%{prefix}/sbin/* + # These were built dynamically in the build phase cp share/man/man1/* $RPM_BUILD_ROOT/%{prefix}/share/man/man1 chmod 444 $RPM_BUILD_ROOT/%{prefix}/share/man/man1/* From bbd6972315fcaa73325bf410b635a4362bd50f07 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 05:17:17 -0700 Subject: [PATCH 04/26] Add a new file restapitest --- xCAT-test/restapitest | 498 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 498 insertions(+) create mode 100755 xCAT-test/restapitest diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest new file mode 100755 index 000000000..1307cd678 --- /dev/null +++ b/xCAT-test/restapitest @@ -0,0 +1,498 @@ +#!/usr/bin/env perl +############################################################################### +# This script is used for rest-api automation test +# Flags are used for test input: +# -m method. Should be GET, POST, PUT, DELETE +# -r resource +# -t token +# -h host +# -u user +# -p passwd +# -P port (BC) +# -d data +# -c cert +# -n hostname +# Flags are used for check output: +# -o expected output +# -l logical operator +# +# Expected result format is '{ANY:{ANY:content}}' +# These steps are used to explain how to scan result +# step 1. go through to see if content can be found +# step 2. compare content if found +# options are used as followed: +# == returns 0 if found and equal, returns 1 if not found or found but not equal +# != returns 0 if found, returns 1 if not found +# =~ returns 0 if match, returns 1 if not match +# !=~ returns 0 if not match, returns 1 if match +################################################################################ +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use Getopt::Long; +use Data::Dumper; +use strict; +my $help; +my $method; +my $token; +my $resource; +my $host; +my $user; +my $passwd; +my $port; +my $data; +my $cert; +my $hostname; +my $output; +my $loperator; +my $debug; +my $defaulthash; +my $defaulthttpresult = 0; +my $outputfile = "/tmp/testrestapiresult"; + +if ( + !GetOptions("h|?" => \$help, + "m=s" => \$method, + "t=s" => \$token, + "r=s" => \$resource, + "h=s" => \$host, + "u=s" => \$user, + "p=s" => \$passwd, + "P=s" => \$port, + "d=s" => \$data, + "c=s" => \$cert, + "n=s" => \$hostname, + "o=s" => \$output, + "l=s" => \$loperator, + "debug" => \$debug, + ) + ) { + &usage; + exit 1; +} + +############################################################## +# check result +############################################################## +if ($output) { + if ($method or $resource) { + &usage; + exit 1; + } + + my $res = check_result($output,$loperator,$outputfile); + print_debug( "check result runs with $output and $loperator, result is $res\n" ); + exit $res; +} +############################################################## +# return help +############################################################## +if ($help) { + &usage; + exit 0; +} +############################################################## +# Give default values for optional vars. +############################################################### +my $rootdir = "$::XCATROOT/share/xcat/tools/autotest"; +my $resultdir = "$rootdir/result"; +my $logfile = "$rootdir/result/restapitest.log"; #/opt/xcat/share/xcat/tools/autotest/result/restapitest.log +my $cert1 = "/root/ca-cert.pem"; +# get token +my $gettoken = `curl -X POST -k 'https://127.0.0.1/xcatws/tokens?userName=root&password=cluster' -H Content-Type:application/json --data '{"userName":"root","password":"cluster"}' 2>/dev/null`; +my $reshash = parse_json($gettoken); +my $token1 = $$reshash{token}{id}; + + +# get hostname +unless ($hostname) { + $hostname = `hostname`; + chomp($hostname); + +} + +# keey default test result for save +my $res = run_restapi($method, $resource, $data, "", $port, "127.0.0.1", "root", "cluster"); +$defaulthash = parse_json($res); +$defaulthttpresult = check_errcode(); + +# debug info +print_debug( "get token $token1. \n" ); +print_debug( "get hostname $hostname.\n"); +print_debug( "default result is $res. \n" ); +print_debug( "default resulthash is: \n" ); +print_debug($defaulthash); +print_debug( "default errcode is $defaulthttpresult \n" ); + + +#################################################### +# Begin to run test cases +#################################################### +my @users = ("root","wsuser", $user); +my @passwds = ("cluster","cluster", $passwd); +my @tokens = ("", $token1, $token); +my @certs = ("", $cert1, $cert); +unless ($host) { + $host = "127.0.0.1"; +} +log_me("**************begin restapi test***************"); +my $i = 0; +for my $u (@users) { + next unless($u); + my $p = $passwds[$i]; + $i++; + for my $t (@tokens) { + for my $c (@certs){ + my $res = run_restapi($method, $resource, $data, $c, $port, $host, $u, $p, $t); + if($res){ + my $reshash = parse_json($res); + print_debug("parse curl result and got:\n"); + print_debug($reshash); + if (%$reshash != %$defaulthash) { + log_me("restapi test cases run different result"); + print_debug( "restapi test cases run different result with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" ); + exit 1; + } + } + my $errcode = check_errcode(); + print_debug("get curl error code: $errcode\n"); + if ($errcode != $defaulthttpresult) { + log_me("restapi test cases run different errcode"); + print_debug( "restapi test cases run different error code with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" ); + exit 1; + } + } + } +} +exit $defaulthttpresult; + +################################################ +# begin subroutine +################################################ + +########## +# usage # +########## +sub usage +{ + print "Usage:testrestapi - Run xcat test cases.\n"; + print " testrestapi [-?|-h]\n"; + print " testrestapi [-m method] [-r resource] [-t tocken]\n"; + print " [-h host] [-P port][-u user] [-p passwd]\n"; + print " [-d data] [-c cert] [-n hostname]\n"; + print " [-o expect_output] [-l logical_operator] [-debug]\n"; + print " [-debug]\n"; + print "\n"; + return; +} + +############### +# record log # +############### +sub log_me +{ + my $msg = shift; + open (LOG, ">>$logfile") + or return 1; + my $date = `date`; + print LOG "$date\: $msg\n"; +} + +##################### +# print debug infor # +##################### +sub print_debug +{ + my $msg = shift; + return 0 unless($debug); + if(ref($msg) eq 'HASH') { + print Dumper($msg); + } elsif( ref($msg) eq 'ARRAY') { + print Dumper($msg); + } else { + print "$msg"; + } +} +######################### +# run rest-api command # +######################### +sub run_restapi +{ + my ($m,$r,$d,$c,$p,$h,$u,$a,$t) = @_; + my $cmd = "curl"; + $cmd .= " -X $m"; + unless ($c) { + $cmd .= " -k "; + }else { + $cmd .= " --cacert $c"; + } + if($t){ + $cmd .= " -H X-Auth-Token:$t "; + } + if($t or $c){ + $cmd .= " 'https://$hostname"; + } else { + $cmd .= " 'https://$h"; + } + if ($p) { + $cmd .= ":$p"; + } + $cmd .= "/xcatws"; + $cmd .= "$r?"; + unless($t){ + $cmd .= "userName=$u&password=$a'"; + }else { + $cmd .= "'"; + } + if($d) { + $cmd .= " --data '$d'"; + } + $cmd .= " -D /tmp/err.log"; + log_me("Begin to run restapi test with $cmd"); + my $res = `$cmd 2>/dev/null`; + print_debug("run curl: $cmd\n"); + print_debug("result is $res\n"); + if (!open (RESULT, ">$outputfile")) { + log_me("wirte outputfile error"); + } + print RESULT $res; + close RESULT; + return $res; +} + +############################ +# transfer json into hash # +############################ +sub parse_json +{ + my $input = shift; + my %hash; + if ($input =~ /:/) { + # for those who look like: + # {"networks":[{"mgtifname":"eth1","mask":"255.255.255.0"},{"mgtifname":"eth1","mask":"255.255.255.0"}]} + if ($input =~ /^\[(.*)\]$/s) { + my $content = $1; + print "[:] content is $content \n" if($debug); + parse_json($content); + } + # for those who look like + # {"clustersite":{"domain":"cluster.com","master":"192.168.1.15"}} + elsif ($input =~ /^\s*{(.*)}\s*$/s) { + my $content = $1; + print "{} content is $content \n" if($debug); + parse_json($content); + } + # for those who look like + # "domain":"cluster.com","master":"192.168.1.15" + elsif ($input =~ /,/ and !($input =~ /}/)) { + my @contents = split /,/, $input; + my @reval; + # record result + foreach my $t (@contents) { + print ", content is $t \n" if($debug); + my $re = parse_json($t); + push @reval, $re; + } + # merge hash + foreach my $t (@reval) { + if(ref($t) =~ "HASH") { + foreach my $k (keys %$t){ + $hash{$k} = $$t{$k}; + } + } + } + return \%hash; + + } + # for those who look like: + # "clustersite":{"domain":"cluster.com","master":"192.168.1.15"} + # "domain":"cluster.com" + elsif ($input =~ /\"(\S+?)\":(.+)/s) { + my $key = $1; + my $value = $2; + if ($value =~ /{/) { + # "clustersite":{"domain":"cluster.com","master":"192.168.1.15"} + print "{ content is $value \n" if($debug); + $hash{$key} = parse_json($value, $key); + return \%hash; + } else { + # "domain":"cluster.com" + $value =~ /\"(\S+)\"/; + $hash{$key} = $1; + return \%hash; + } + } + } + # for those who look like + # ["10.1.255.250","192.168.200.16","192.168.200.19","192.168.200.22"] + else { + if ($input =~ /^\[(.*)\]/s) { + my $content = $1; + print "[] content is $content \n" if($debug); + my @all = split /,/, $content; + foreach my $n (@all) { + $n =~ /\"(.*)\"/; + $hash{$1} = 1; + } + return \%hash; + } + } +} + +############################ +# check curl running code # +############################ +sub check_errcode +{ + if(!open (ERRLOG, "){ + if (/HTTP\/\w*\.*\w* (\w+) (\w+)/) { + $num = $1; + last; + } + } + close ERRLOG; + print_debug("can't get errorcode\n") unless($num); + return $num; +} + +############################ +# check curl return result # +############################ +sub check_result +{ + my $data = shift; + my $opterator = shift; + my $output = shift; + if ( !open (OUTPUT, "<$output")) { + log_me("can't read output file"); + return 1; + } + my $res; + while () { + $res .= $_; + } + close OUTPUT; + + + my $expects = transf_hash(parse_json($data)); # one entry + my $actuals = transf_hash(parse_json($res)); # serval entries + + print_debug("expected result is:\n"); + print_debug($expects); + print_debug("testcase run result is \n"); + print_debug($actuals); + + my $flag = 0; + my %flaghash; + my $expect = $$expects[0]; # $expect = ANY:ANY:x86_64 + + my @expectvalue = split /:/, $expect; #@expectvalue = ANY, ANY, x86_64 + $flag = 0; + foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64 + foreach my $expval (@expectvalue) { # $expval = ANY + my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64 + if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype + $flaghash{$actual} = "eq"; + } elsif ($expval =~ $actualvalue[$flag] or $expval == "ANY") { + $flaghash{$actual} = "match"; + } else { + $flaghash{$actual} = "none"; + next; + } + } + $flag++; + } + print_debug("search result is \n"); + print_debug(\%flaghash); + + if ($opterator eq "!="){ + foreach my $val (keys %flaghash) { + if ($flaghash{$val} eq "eq") { + print_debug("compare result: failed\n"); + return 1; # fail + } + } + print_debug("compare result: succeed\n"); + return 0; #succeed + } + if ($opterator eq "=="){ + foreach my $val (keys %flaghash) { + if ($flaghash{$val} eq "eq") { + print_debug("compare result: succeed\n"); + return 0; # succeed + } + } + print_debug("compare result: failed\n"); + return 1; #fail + } + + if ($opterator eq "=~"){ + foreach my $val (keys %flaghash) { + if ($flaghash{$val} eq "match") { + print_debug("compare result: succeed\n"); + return 0; # succeed + } + } + print_debug("compare result: failed\n"); + return 1; #fail + } + if ($opterator eq "!=~"){ + foreach my $val (keys %flaghash) { + if ($flaghash{$val} eq "match") { + print_debug("compare result: failed\n"); + return 1; # fail + } + } + print_debug("compare result: succeed\n"); + return 0; #succeed + } + +} + +#################################### +# help to transfer hash into array # +#################################### +sub find_key +{ + my $input = shift; + my $en = shift; + my $ou = shift; + if( ref($input) =~ "HASH") { + foreach my $val (keys %$input) { + my $tmp = $$en; # keey head + $$en .= "$val:"; + my $t1 = find_key($$input{$val}, $en, $ou); + if ($$en == ""){ + $$en = $tmp; #restore head + } + } + } else { + $$en .= $input; + push @$ou, $$en; + $$en = ""; # clear entry; + } +} + +############################ +# transfer hash into array # +############################ +sub transf_hash +{ + my $input = shift; + my $entry; + my @array; + find_key($input, \$entry, \@array); + return \@array; +} + + + + + + From cde9aed074721c046f3e579628f5174034a50cc6 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 May 2014 00:38:30 -0700 Subject: [PATCH 05/26] fix defect 4117 and 4113 --- build-ubunturepo | 4 ++-- xCAT-server/lib/xcat/plugins/dhcp.pm | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index f8ae7a10d..f23106d12 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -279,7 +279,7 @@ __EOF__ cat << '__EOF__' > mklocalrepo.sh . /etc/lsb-release cd `dirname $0` -echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list +echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list __EOF__ chmod 775 mklocalrepo.sh @@ -380,7 +380,7 @@ __EOF__ cat << '__EOF__' > mklocalrepo.sh . /etc/lsb-release cd `dirname $0` -echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list +echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list __EOF__ chmod 775 mklocalrepo.sh diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 21c5456b9..0d59f9c87 100755 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -884,10 +884,15 @@ sub check_options # if not help and not -n, dhcpd needs to be running if (!($opt->{h})&& (!($opt->{n}))) { if (xCAT::Utils->isLinux()) { - my @output = xCAT::Utils->runcmd("service dhcpd status", -1); + my $DHCPSERVER="dhcpd"; + if( -e "/etc/init.d/isc-dhcp-server" ){ + $DHCPSERVER="isc-dhcp-server"; + } + + my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1); if ($::RUNCMD_RC != 0) { # not running my $rsp = {}; - $rsp->{data}->[0] = "dhcpd is not running. Run service dhcpd start and rerun your command."; + $rsp->{data}->[0] = "$DHCPSERVER is not running. Run service $DHCPSERVER start and rerun your command."; xCAT::MsgUtils->message("E", $rsp, $callback, 1); return 1; } From e590737654bcc657a3f6446cb73defd54eb8aa96 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 06:07:12 -0700 Subject: [PATCH 06/26] Add cmdcheck for xcattest --- xCAT-test/xcattest | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index c159bc9b2..a4cff3ae3 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -25,10 +25,10 @@ my $string1 = undef; if ( !GetOptions("h|?" => \$needhelp, "f=s" => \$configfile, - "b=s" => \$bundle_list, - "t=s" => \$case_list, - "c=s" => \$cmd_list, - "l" => \$needshow, + "b=s" => \$bundle_list, + "t=s" => \$case_list, + "c=s" => \$cmd_list, + "l" => \$needshow, "restore"=>\$restore) ) { @@ -221,7 +221,7 @@ sub getConfig } } } - + if(exists $config{object}){ foreach my $type (keys %{$config{object}}){ foreach my $name (keys %{$config{object}{$type}}){ @@ -344,7 +344,7 @@ sub init log_this("No compute node defined,can't get ARCH of compute node"); } else { $config{var}{ARCH} = getnodeattr($config{var}{CN},"arch"); - if($config{var}{ARCH} =~ /ppc/){ + if($config{var}{ARCH} =~ /ppc/){ $config{var}{ARCH} = 'ppc'; }elsif($config{var}{ARCH}=~/86/){ $config{var}{ARCH} = 'x86'; @@ -432,7 +432,7 @@ sub loadcase my $j = -1; my $z = 0; my $skip = 0; - + my @caserange = (); my @rightcase = (); my @notrightcase = (); @@ -452,7 +452,7 @@ sub loadcase } } if($case_list){ - @caserange = split /,/, $case_list; + @caserange = split /,/, $case_list; } foreach $file (@files){ if(!open(FILE, "<$file")){ @@ -498,13 +498,13 @@ sub loadcase $cases[$i]->{os}=$string1; } - + if($cases[$i]->{os} !~ /$config{var}{OS}/){ push(@notrightcase, $cases[$i]->{name}); pop(@rightcase); $skip = 1; } - + }elsif($line =~ /^arch\s*:\s*(\w[\w\,]+)/){ next if $skip; $cases[$i]->{arch}=$1; @@ -631,7 +631,7 @@ sub getfunc $func = $1; $parameter = $2; @para = split /\s*,\s*/, trim($parameter); - if($func eq "GETNODEATTR"){ + if($func eq "GETNODEATTR"){ $value= getnodeattr(@para); if($value eq "Unknown"){ $value = ''; @@ -669,9 +669,9 @@ sub runcase my $time1=gmtime $now1; log_this("------START:$$case{name}::Time:$time1------"); push @record, "------START:$$case{name}::Time:$time1------"; - push @record, "FILENAME:$$case{filename}"; + push @record, "FILENAME:$$case{filename}"; foreach my $cmd (@{$$case{cmd}}){ - $cmd = getfunc($cmd); + $cmd = getfunc($cmd); #by my $runstart=timelocal(localtime()); @@ -684,10 +684,10 @@ sub runcase my $diffduration=$runstop-$runstart; log_this("\n[$cmd] Running Time:$diffduration sec"); push(@record,("\n[$cmd] Running Time:$diffduration sec")); - + log_this("RETURN: rc = $rc","OUTPUT:",@output); push(@record,("RETURN rc = $rc","OUTPUT:",@output)); - + foreach my $check (@{$$case{check}->[$j]}){ if($failed){ @@ -766,7 +766,17 @@ sub runcase } } foreach my $cmdcheck (@{$$case{cmdcheck}->[$j]}){ - &runcmd($cmdcheck); + if($cmdcheck) { + &runcmd($cmdcheck); + $rc = $::RUNCMD_RC; + if($rc == 1) { + log_this("CMDCHECK:output $cmdcheck\t[Failed]"); + push(@record, "CHECK:output $cmdcheck\t[Failed]"); + } elsif ($rc == 0) { + log_this("CMDCHECK:output $cmdcheck\t[Pass]"); + push(@record, "CHECK:output $cmdcheck\t[Pass]"); + } + } } $j = $j + 1; } @@ -798,6 +808,7 @@ sub runcmd if ($?) { $rc = $? ; + $rc = $rc >> 8; $::RUNCMD_RC = $rc; } chomp(@$outref); @@ -835,3 +846,5 @@ sub getreport close(FD); close(STDOUT); } + + From 49dd61bcacf6a6478caaeb7b79a8e45e6abaf2d6 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 08:04:04 -0700 Subject: [PATCH 07/26] Add some debug info for the script --- xCAT-test/restapitest | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest index 1307cd678..425ef7b2a 100755 --- a/xCAT-test/restapitest +++ b/xCAT-test/restapitest @@ -246,7 +246,7 @@ sub run_restapi $cmd .= "'"; } if($d) { - $cmd .= " --data '$d'"; + $cmd .= " -H Content-Type:application/json --data '$d'"; } $cmd .= " -D /tmp/err.log"; log_me("Begin to run restapi test with $cmd"); @@ -394,17 +394,22 @@ sub check_result my @expectvalue = split /:/, $expect; #@expectvalue = ANY, ANY, x86_64 $flag = 0; - foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64 - foreach my $expval (@expectvalue) { # $expval = ANY + foreach my $expval (@expectvalue) { # $expval = ANY + foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64 + if($flaghash{$actual} eq "none"){ + next; + } my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64 + print_debug("begin to compare $expval and $actualvalue[$flag]"); + if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype $flaghash{$actual} = "eq"; - } elsif ($expval =~ $actualvalue[$flag] or $expval == "ANY") { + } elsif (($expval =~ $actualvalue[$flag]) or ($expval eq "ANY")) { $flaghash{$actual} = "match"; } else { $flaghash{$actual} = "none"; - next; } + print_debug(", compare result is $flaghash{$actual}\n"); } $flag++; } From 40d4c75b29fa076efd601ae8327208dbd61a4a3c Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 May 2014 10:11:37 -0400 Subject: [PATCH 08/26] code change for rh7 stateless support --- xCAT-server/share/xcat/netboot/rh/genimage | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 37eadfd8f..0acc19ed4 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -583,8 +583,8 @@ if ( (-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut") my $dracutver = `rpm --root $rootimg_dir -qi dracut | grep Version | awk -F' ' '{print \$3}'`; chomp($dracutver); if ($dracutver =~ /^\d\d\d$/) { - if (($dracutver >= "009") and ($dracutver < "033")) { - $dracutdir = "dracut_009"; + if ($dracutver >= "033") { + $dracutdir = "dracut_033"; } else { $dracutdir = "dracut"; # The default directory } @@ -924,7 +924,11 @@ sub mkinitrd_dracut { $additional_options= qq{--include /tmp/cmdline /etc/cmdline}; } - system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver"); + # force the dracut run in non-hostonly mode for dracut higher than version 033 + if ($dracutver > "033") { + $additional_options .= " -N"; + } + system("chroot $rootimg_dir dracut -N $additional_options -f /tmp/initrd.$$.gz $kernelver"); print "the initial ramdisk for $mode is generated successfully.\n"; move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); } @@ -1665,7 +1669,11 @@ sub using_systemd { my $os = shift; if ($os =~ /fedora(\d+)/) { if ($1 >= 15) { - return 1; + return 1; + } + }elsif ($os =~ /rhels(\d+)/) { + if ($1 >= 7) { + return 1; } } From cee55105de5a262517b9d1bca080fe681529a329 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 May 2014 10:14:04 -0400 Subject: [PATCH 09/26] add dracut support scripts for dracut-033. Most of them are copied from dracut --- .../share/xcat/netboot/rh/dracut_033/check | 3 + .../netboot/rh/dracut_033/install.netboot | 9 + .../netboot/rh/dracut_033/install.statelite | 8 + .../xcat/netboot/rh/dracut_033/installkernel | 2 + .../netboot/rh/dracut_033/xcat-cmdline.sh | 4 + .../netboot/rh/dracut_033/xcat-premount.sh | 18 ++ .../netboot/rh/dracut_033/xcat-prepivot.sh | 126 +++++++++ .../netboot/rh/dracut_033/xcat-updateflag | 24 ++ .../share/xcat/netboot/rh/dracut_033/xcatroot | 259 ++++++++++++++++++ 9 files changed, 453 insertions(+) create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/check create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel create mode 100644 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh create mode 100644 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/check b/xCAT-server/share/xcat/netboot/rh/dracut_033/check new file mode 100755 index 000000000..d7cc89ce0 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/check @@ -0,0 +1,3 @@ +#!/bin/sh +[ "$1" = "-d" ] && echo network +exit 0 diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot new file mode 100755 index 000000000..b52b6690f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot @@ -0,0 +1,9 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip modprobe touch echo cut wc +dracut_install grep ifconfig hostname awk egrep grep dirname expr +dracut_install mount.nfs +dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" +inst "$moddir/xcatroot" "/sbin/xcatroot" +inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite new file mode 100755 index 000000000..7c7646652 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite @@ -0,0 +1,8 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip modprobe wc touch echo cut +dracut_install grep ifconfig hostname awk egrep grep dirname expr +dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" +inst_hook pre-mount 5 "$moddir/xcat-premount.sh" +inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel b/xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel new file mode 100755 index 000000000..7902ce5f7 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nfs sunrpc diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh new file mode 100644 index 000000000..80d088557 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh @@ -0,0 +1,4 @@ +root=1 +rootok=1 +netroot=xcat +echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh new file mode 100644 index 000000000..40c1dbbe5 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh @@ -0,0 +1,18 @@ +#!/bin/sh +#script to update nodelist.nodestatus during provision + +MASTER=`echo $XCAT |awk -F: '{print $1}'` + +getarg nonodestatus +NODESTATUS=$? + +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh new file mode 100755 index 000000000..d6eac21f9 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh @@ -0,0 +1,126 @@ +#!/bin/sh +NEWROOT=/sysroot +SERVER=${SERVER%%/*} +SERVER=${SERVER%:} +RWDIR=.statelite +if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + #echo $SNAPSHOTROOT + #echo $SNAPSHOTSERVER + # may be that there is not server and just a directory. + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi +fi + +echo Setting up Statelite +mkdir -p $NEWROOT + +# now we need to mount the rest of the system. This is the read/write portions +# echo Mounting snapshot directories + +MAXTRIES=7 +ITER=0 +if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... " + echo "" + /bin/sh +fi + +if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode" + echo "" + /bin/sh +fi + +mount -t tmpfs rw $NEWROOT/$RWDIR +mkdir -p $NEWROOT/$RWDIR/tmpfs +ME=`hostname` +if [ ! -z $NODE ]; then + ME=$NODE +fi + +# mount the SNAPSHOT directory here for persistent use. +if [ ! -z $SNAPSHOTSERVER ]; then + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + + # create directory which is named after my node name + mkdir -p $NEWROOT/$RWDIR/persistent/$ME + ITER=0 + # umount current persistent mount + while ! umount -l $NEWROOT/$RWDIR/persistent; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Cannot umount $NEWROOT/$RWDIR/persistent." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done +fi + +# TODO: handle the dhclient/resolv.conf/ntp, etc +echo "Get to enable localdisk" +$NEWROOT/etc/init.d/localdisk +$NEWROOT/etc/init.d/statelite +READONLY=yes +export READONLY +fastboot=yes +export fastboot +keep_old_ip=yes +export keep_old_ip +mount -n --bind /dev $NEWROOT/dev +mount -n --bind /proc $NEWROOT/proc +mount -n --bind /sys $NEWROOT/sys + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh +# force udevsettle to break +> $hookdir/initqueue/work diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag new file mode 100755 index 000000000..2f9ac3165 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag @@ -0,0 +1,24 @@ +#!/bin/awk -f +#script to feedback the node provision status to xcatd +BEGIN { + + xcatdhost = ARGV[1] + xcatiport = ARGV[2] + + + ns = "/inet/tcp/0/" xcatdhost "/" xcatiport + print "xCAT_xcatd" |& ns + + while(1) { + ns |& getline + + if($0 == "ready") + print ARGV[3] |& ns + if($0 == "done") + break + } + + close(ns) + + exit 0 +} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot new file mode 100755 index 000000000..4cde3f1ca --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -0,0 +1,259 @@ +#!/bin/sh +NEWROOT=$3 +RWDIR=.statelite +XCATMASTER=$XCAT + +. /lib/dracut-lib.sh +rootlimit="$(getarg rootlimit=)" + + +getarg nonodestatus +NODESTATUS=$? + +MASTER=`echo $XCATMASTER |awk -F: '{print $1}'` +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi + +if [ ! -z "$imgurl" ]; then + if [ xhttp = x${imgurl%%:*} ]; then + NFS=0 + FILENAME=${imgurl##*/} + while [ ! -r "$FILENAME" ]; do + echo Getting $imgurl... + if ! wget $imgurl; then + rm -f $FILENAME + sleep 27 + fi + done + elif [ xnfs = x${imgurl%%:*} ]; then + NFS=1 + SERVER=${imgurl#nfs:} + SERVER=${SERVER#/} + SERVER=${SERVER#/} + ROOTDIR=$SERVER + SERVER=${SERVER%%/*} + SERVER=${SERVER%:} + ROOTDIR=/${ROOTDIR#*/} + fi +fi +#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug + +if [ -r /rootimg.sfs ]; then + echo Setting up squashfs with ram overlay. + mknod /dev/loop0 b 7 0 + mkdir -p /ro + mkdir -p /rw + mount -t squashfs /rootimg.sfs /ro + mount -t tmpfs rw /rw + mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT + mkdir -p $NEWROOT/ro + mkdir -p $NEWROOT/rw + mount --move /ro $NEWROOT/ro + mount --move /rw $NEWROOT/rw +elif [ -r /rootimg.gz ]; then + echo Setting up RAM-root tmpfs. + if [ -z $rootlimit ];then + mount -t tmpfs -o mode=755 rootfs $NEWROOT + else + mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT + fi + + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.gz |/bin/cpio -idum + else + gzip -cd /rootimg.gz |cpio -idum + fi + $NEWROOT/etc/init.d/localdisk + echo Done +elif [ -r /rootimg-statelite.gz ]; then + echo Setting up RAM-root tmpfs for statelite mode. + + if [ -z $rootlimit];then + mount -t tmpfs -o mode=755 rootfs $NEWROOT + else + mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT + fi + + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg-statelite.gz |/bin/cpio -idum + else + gzip -cd /rootimg-statelite.gz |cpio -idum + fi + echo Done + # then, the statelite staffs will be processed + echo Setting up Statelite + modprobe nfs + MAXTRIES=7 + ITER=0 + if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "The /$RWDIR directory doesn't exist in the rootimg... " + echo "" + /bin/sh + fi + + if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist... " + echo "" + /bin/sh + fi + + mount -t tmpfs rw $NEWROOT/$RWDIR + mkdir -p $NEWROOT/$RWDIR/tmpfs + ME=`hostname` + if [ ! -z $NODE ]; then + ME=$NODE + fi + + + # mount the SNAPSHOT directory here for persistent use. + if [ ! -z $STATEMNT ]; then + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + + if [ ! -z $SNAPSHOTSERVER ]; then + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "You are dead, rpower $ME boot to play again." + echo "Possible problems: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS=$(( $RANDOM % 20 )) + echo "Trying again in $RS seconds ..." + sleep $RS + done + + # create directory which is named after my node name + mkdir -p $NEWROOT/$RWDIR/persistent/$ME + ITER=0 + # umount current persistent mount + while ! umount -l $NEWROOT/$RWDIR/persistent; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Cannot umount $NEWROOT/$RWDIR/persistent." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + fi + + $NEWROOT/etc/init.d/localdisk + $NEWROOT/etc/init.d/statelite + fastboot=yes + export fastboot + keep_old_ip=yes + export keep_old_ip + + mount -n --bind /dev $NEWROOT/dev + mount -n --bind /proc $NEWROOT/proc + mount -n --bind /sys $NEWROOT/sys + +else + echo -n Failed to download image, panicing in 5... + for i in 4 3 2 1 0; do + /bin/sleep 1 + echo -n $i... + done + echo + echo "You're dead. rpower nodename reset to play again. + +* Did you packimage with -m cpio, -m squashfs, or -m nfs? +* If using -m squashfs did you include aufs.ko with geninitrd? + e.g.: -n tg3,squashfs,aufs,loop +* If using -m nfs did you export NFS and sync rootimg? And + did you include the aufs and nfs modules in the proper order: + e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs + +" + /bin/dash + exit +fi +cd / + +if [ -z $STATEMNT ]; then + for lf in /tmp/dhclient.*.lease; do + netif=${lf#*.} + netif=${netif%.*} + cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + done + + if [ ! -z "$ifname" ]; then + MACX=${ifname#*:} + ETHX=${ifname%:$MACX*} + elif [ ! -z "$netdev" ]; then + ETHX=$netdev + MACX=`ip link show $netdev | grep ether | awk '{print $2}'` + elif [ ! -z "$BOOTIF" ]; then + MACX=$BOOTIF + ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` + fi + + if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then + if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then + touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi + echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi +fi + +cp /etc/resolv.conf "$NEWROOT/etc/" + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh +# force udevsettle to break +> $hookdir/initqueue/work From bf306b5fc12edd9c25eb5c5d6534d8a5b69b74da Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 May 2014 03:22:23 -0700 Subject: [PATCH 10/26] fix the problem that redhat provisioning on X will enter infinite installation loop when unicats dhcp is enabled --- xCAT-server/lib/perl/xCAT/Template.pm | 24 ++++++++++++++----- .../share/xcat/install/scripts/post.rh.common | 12 +++++++++- .../xcat/install/scripts/post.sles.common | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 7e03dff72..d6bc2c818 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -105,11 +105,6 @@ sub subvars { } - my @managedaddressmode = xCAT::TableUtils->get_site_attribute("managedaddressmode"); - my $tmp=$managedaddressmode[0]; - if( defined($tmp) ){ - $ENV{MANAGEDADDRESSMODE}=$tmp; - } #replace the env with the right value so that correct include files can be found $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; @@ -249,6 +244,7 @@ sub subvars { $inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg; $inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg; $inc =~ s/#HOSTNAME#/$node/g; + $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg; my $nrtab = xCAT::Table->new("noderes"); my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']); @@ -638,6 +634,22 @@ sub get_win_prodkey { sub managed_address_mode { return $::XCATSITEVALS{managedaddressmode}; } + + +sub get_node_domain { + my $lcnode=shift; + if ( $lcnode eq 'THISNODE' ){ + $lcnode=$node; + } + + my $nd = xCAT::NetworkUtils->getNodeDomains([$lcnode]); + my %nodedomains = %$nd; + my $domain=$nodedomains{$lcnode}; + + return $domain; + +} + sub esxipv6setup { if (not $::XCATSITEVALS{managedaddressmode} or $::XCATSITEVALS{managedaddressmode} =~ /v4/) { return ""; } # blank line for ipv4 schemes my $v6addr; @@ -705,7 +717,7 @@ sub kickstartnetwork { push @nameserversIP, $ip; } - + #there is no network option to set dns search domain in kickstart, it will be set in %post if (scalar @nameserversIP) { $line .=" --nameserver=". join(",",@nameserversIP); } diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common index f34fe6e5d..b3b1fc0f1 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rh.common +++ b/xCAT-server/share/xcat/install/scripts/post.rh.common @@ -1,7 +1,17 @@ # -# Setup hostname +# Setup hostname and resov.conf # echo "post scripts" >/root/post.log + +#there is no network option to set dns search domain in kickstart file, +#the search domain in /etc/resolv.conf is set in the post installation script +export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE# +export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE# + +if [ "$MANAGEDADDRESSMODE" == "static" ]; then + echo "search $SEARCHDOMAIN" >> /etc/resolv.conf +fi + export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.sles.common b/xCAT-server/share/xcat/install/scripts/post.sles.common index cfe6f29cc..ae6db1e24 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles.common +++ b/xCAT-server/share/xcat/install/scripts/post.sles.common @@ -1,5 +1,5 @@ #!/bin/sh -export MANAGEDADDRESSMODE="#XCATVAR:MANAGEDADDRESSMODE#" +export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE# cd /etc/sysconfig/network From d915fcf4b724e828c4cb36e8acc1461372e1e6e0 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 May 2014 03:45:39 -0700 Subject: [PATCH 11/26] add replace token in kickstart template file for rhels6.x86_64 and rhel7 to support unicast dhcp --- xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl | 1 + xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl | 1 + 2 files changed, 2 insertions(+) diff --git a/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl index ec75d88bd..b32f1f01d 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhel7.tmpl @@ -2,6 +2,7 @@ #cmdline lang en_US +#KICKSTARTNET# # # Where's the source? diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl index ff7321d77..55b0aa2f8 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl @@ -3,6 +3,7 @@ #cmdline lang en_US +#KICKSTARTNET# # # Where's the source? From eebfcc912bb1c2e04410874e04154a47fa747838 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 8 May 2014 09:29:46 -0400 Subject: [PATCH 12/26] REDHAT7 support defect 4091 --- xCAT/postscripts/configeth | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 85994e869..5bc33da04 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -335,7 +335,8 @@ elif [ "$1" = "-s" ];then if [ -n "$MACADDRESS" ];then str_inst_mac=$MACADDRESS else - str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'` + #str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'` + str_inst_mac=`ip link show $netdev | grep ether | awk '{print $2}'` fi if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then From 729304691585887493d8ca1cffde800233241a4f Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 8 May 2014 09:49:39 -0400 Subject: [PATCH 13/26] defect 4091 --- xCAT-client/bin/rcons | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/rcons b/xCAT-client/bin/rcons index 979759c49..86497d9f1 100755 --- a/xCAT-client/bin/rcons +++ b/xCAT-client/bin/rcons @@ -115,7 +115,11 @@ else length=`expr $index2 - $index1` length=`expr $length - 1` cons_ip=`expr substr "$result" $pos $length` - ifconfig |grep "$cons_ip" + if [ "$os" == "AIX" ]; then + ifconfig |grep "$cons_ip" + else + ip addr |grep "$cons_ip" + fi if [ $? -eq 0 ]; then CONSERVER="" fi From 80ddcd845b8c68a40fc179365ac6883177d00f0e Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 9 May 2014 02:02:45 -0700 Subject: [PATCH 14/26] correct the dns configuration during node provision when unicast dhcp is enabled --- xCAT-server/lib/xcat/plugins/sles.pm | 10 +++++++++- xCAT-server/share/xcat/install/scripts/post.rh.common | 10 +--------- xCAT-server/share/xcat/install/scripts/pre.rh | 11 +++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index d53db653b..61ac8b8ac 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1182,11 +1182,19 @@ sub mkinstall } if(scalar @nameserversIP){ - $kcmdline .=" dns=".join(",",@nameserversIP); + $kcmdline .=" Nameserver=".join(",",@nameserversIP); } + + my $nd = xCAT::NetworkUtils->getNodeDomains([$node]); + my %nodedomains = %$nd; + my $domain=$nodedomains{$node}; + + $kcmdline .=" Domain=$domain "; } + + if (defined $sent->{serialport}) { diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common index b3b1fc0f1..79bc733a7 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rh.common +++ b/xCAT-server/share/xcat/install/scripts/post.rh.common @@ -1,16 +1,8 @@ # -# Setup hostname and resov.conf +# Setup hostname # echo "post scripts" >/root/post.log -#there is no network option to set dns search domain in kickstart file, -#the search domain in /etc/resolv.conf is set in the post installation script -export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE# -export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE# - -if [ "$MANAGEDADDRESSMODE" == "static" ]; then - echo "search $SEARCHDOMAIN" >> /etc/resolv.conf -fi export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 113c5760b..346b6de73 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -14,6 +14,17 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then fi +#there is no boot option to set dns search domain in kickstart file, +#the search domain in /etc/resolv.conf is set in the pre installation script +export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE# +export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE# + +if [ "$MANAGEDADDRESSMODE" == "static" ]; then + echo "#appended by %pre " >> /etc/resolv.conf + echo "search $SEARCHDOMAIN" >> /etc/resolv.conf +fi + + cat >/tmp/baz.py < Date: Fri, 9 May 2014 10:19:52 -0400 Subject: [PATCH 15/26] defect 4091 remove ifconfig calls --- xCAT/postscripts/setupesx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT/postscripts/setupesx b/xCAT/postscripts/setupesx index 0e062cd60..3f6a9f09e 100644 --- a/xCAT/postscripts/setupesx +++ b/xCAT/postscripts/setupesx @@ -43,9 +43,9 @@ cat >/tmp/esxcfg.sh < Date: Mon, 12 May 2014 01:57:52 -0700 Subject: [PATCH 16/26] fix defect #4123 [fvt]2.8.4:ubuntu 12.04 diskfull install failed --- xCAT/debian/dirs | 1 + xCAT/debian/install | 2 +- xCAT/debian/postinst | 9 +++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/xCAT/debian/dirs b/xCAT/debian/dirs index ef4317183..7fed8339e 100644 --- a/xCAT/debian/dirs +++ b/xCAT/debian/dirs @@ -5,4 +5,5 @@ install/prescripts install/kdump opt/xcat/share/xcat etc/apache2/conf.d +etc/apache2/conf-enabled opt/xcat/share/doc/packages/xCAT diff --git a/xCAT/debian/install b/xCAT/debian/install index edd37eb13..ab485abda 100644 --- a/xCAT/debian/install +++ b/xCAT/debian/install @@ -1,5 +1,5 @@ xcat.conf etc/apache2/conf.d/ -xcat.conf.apach24 etc/apache2/conf.d/ +xcat.conf.apach24 etc/apache2/conf-enabled LICENSE.html opt/xcat/share/doc/packages/xCAT postscripts/* install/postscripts/ prescripts/* install/prescripts/ diff --git a/xCAT/debian/postinst b/xCAT/debian/postinst index 9215ea63b..06a9e549b 100644 --- a/xCAT/debian/postinst +++ b/xCAT/debian/postinst @@ -40,12 +40,9 @@ case "$1" in else xcatconfig -i -d -s fi - ver=$(cat /etc/issue |awk '{print $2}') - num=${ver%.*} - file="xcat.conf.apach24" - if [ $num -gt 12 ];then - mv /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf-enabled/ - fi + +# [ -e /etc/apache2/conf-enabled/xcat.conf ] && rm /etc/apache2/conf-enabled/xcat.conf +# mv /etc/apache2/conf-enabled/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf /etc/init.d/apache2 restart ;; From 8927265eba1c4cd99626515345110bd70becc51f Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 12 May 2014 02:06:08 -0700 Subject: [PATCH 17/26] change the uploader to ligc --- build-ubunturepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ubunturepo b/build-ubunturepo index f23106d12..d2d81d47d 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -86,7 +86,7 @@ if [ "$c_flag" -a "$d_flag" ];then exit 2 fi -uploader="bp-sawyers" +uploader="ligc" # Find where this script is located to set some build variables old_pwd=`pwd` cd `dirname $0` From 988ffd5ba9f38ca51961d7eaf58413bfaf4eb1c7 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Mon, 12 May 2014 08:08:31 -0400 Subject: [PATCH 18/26] modified softlayer sysclone for bonded nics --- xCAT-SoftLayer/bin/modifygrub | 13 +- xCAT-SoftLayer/bin/pushinitrd | 2 +- xCAT-SoftLayer/postscripts/configbond | 228 ++++++++++++++++++ .../si-post-install/16all.updatenetwork | 79 +++++- 4 files changed, 305 insertions(+), 17 deletions(-) create mode 100755 xCAT-SoftLayer/postscripts/configbond diff --git a/xCAT-SoftLayer/bin/modifygrub b/xCAT-SoftLayer/bin/modifygrub index a2e70caff..2c3566e46 100755 --- a/xCAT-SoftLayer/bin/modifygrub +++ b/xCAT-SoftLayer/bin/modifygrub @@ -106,12 +106,13 @@ sub getNodeIpInfo { my @nics = grep(m/\s+master\s+$nic\s+/, @output); if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; } ($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /; - # go back thru the ip add show output and find the mac of this nic - foreach my $line (@output) { - my ($nictmp, $mactmp, $foundnic); - if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; } - if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done - } + # do not need to go back thru the ip addr show output and find the mac of this nic because the mac + # of the bond nic is the same. Plus the code below does not work right for some reason anyway. + #foreach my $line (@output) { + # my ($nictmp, $mactmp, $foundnic); + # if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; } + # if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done + #} } # finally, find the gateway diff --git a/xCAT-SoftLayer/bin/pushinitrd b/xCAT-SoftLayer/bin/pushinitrd index bcad30198..fe7e88c83 100755 --- a/xCAT-SoftLayer/bin/pushinitrd +++ b/xCAT-SoftLayer/bin/pushinitrd @@ -207,7 +207,7 @@ sub modifyAutoinstFiles { # Copy softlayer specific systemimager post-install scripts to the systemimager location. # These cause si to use static ip and insert a wait into the bring up of the network. sub copySyscloneFiles { - my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/* /install/sysclone/scripts/post-install"; + my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/16all.updatenetwork /install/sysclone/scripts/post-install"; print "Copying SoftLayer-specific post scripts to the SystemImager post-install directory.\n"; runcmd($cmd); } diff --git a/xCAT-SoftLayer/postscripts/configbond b/xCAT-SoftLayer/postscripts/configbond new file mode 100755 index 000000000..0cd4e033d --- /dev/null +++ b/xCAT-SoftLayer/postscripts/configbond @@ -0,0 +1,228 @@ +#!/usr/bin/perl + +# xCAT postscript for configuring bonding of nics. +# Usage: configbond bond1 eth1 [eth3] +# +# Note: this postscript currently has some assumptions that are specific to the softlayer environment. +# It is only used to configure bond1, because bond0 gets configured by the node provisioning process. + +use strict; +# Check number of args + +my $nargs = $#ARGV + 1; +if (scalar(@ARGV) < 2 || scalar(@ARGV) > 3) { + system("logger -t xcat -p local4.err 'Usage: configbond bond dev0 [dev1]'"); + exit 1; +} + +my $bond = shift(@ARGV); +my $nic = $ARGV[0]; +my @devs = (); +push(@devs,$ARGV[0]); +if (defined($ARGV[1])) { push(@devs,$ARGV[1]); } +my $nicips = $ENV{NICIPS}; +my $nicnetworks = $ENV{NICNETWORKS}; +my $net_cnt = $ENV{NETWORKS_LINES}; + +#todo: these are specific to softlayer. They should be another attribute or argument +my $bondingopts = 'mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1'; + +my $netmask =''; +my $ipaddr = ''; +my $nic_num = ''; +my $subnet = ''; +my $nic_net = ''; +my $net_name = ''; +my @nic_nets = (); # array of networks for this nic +my @nic_ips =(); # array of ipaddresses for this nic +my @networks = (); # array of all networks from networks table. + # { network_name, subnet, netmask } + +system("logger -t xcat -p local4.err 'configbond: Master: $bond'"); +system("logger -t xcat -p local4.err 'configbond: Slaves: @devs'"); +#system("logger -t xcat -p local4.err 'configbond: NIC: $nic'"); +system("logger -t xcat -p local4.err 'configbond: NICNETWORKS: $nicnetworks'"); +system("logger -t xcat -p local4.err 'configbond: NICIPS: $nicips'"); + +# Update modprobe +my $file = "/etc/modprobe.d/$bond.conf"; +if (!open(FILE, ">$file")) { system("logger -t xcat -p local4.err 'configbond: cannot open $file.'"); exit 1; } + +print FILE "alias $bond bonding\n"; +# the bonding options are put in the ifcfg file instead +#print FILE "options $bond mode=balance-rr miimon=100\n"; +close FILE; + +# create array of network info. Needed in case where there are +# more than one ip address per nic and shouldn't be many networks. +my $net_info; +my $cnt = 1; + +while ( $cnt <= $net_cnt ) { + $net_info = $ENV{"NETWORKS_LINE$cnt"}; + $net_info =~ /^netname=([^\|]*)\|\|/; + $net_name = $1; + $net_info =~ /net=([^\|]*)\|\|/; + $subnet = $1; + $net_info =~ /mask=([^\|]*)\|\|/; + $netmask = $1; + push @{ $networks[$cnt-1] }, ($net_name, $subnet, $netmask); + $cnt +=1; +} + +# get network or networks for this nic from NICNETWORKS: +# eth0:1_0_0_0-255_255_0_0|network2,eth1:1_1_0_0 +# create array of networks for this nic +foreach my $nic_networks (split(/,/,$nicnetworks)) { + my @net = (); + if ( $nic_networks =~ /!/ ) { + @net = split(/!/,$nic_networks); + } else { + @net = split(/:/,$nic_networks); + } + if ($net[0] eq $nic) { + @nic_nets = split(/\|/,$net[1]); + last; + } +} + +# get all nic ipaddress from $nicips: i.e. eth0:1.0.0.1|2.0.0.1,eth1:1.1.1.1 +# Then get all ips for this specific nic, i.e. eth0. +foreach my $ips (split(/,/,$nicips)) { + my @ip = (); + if ( $ips =~ /!/ ) { + @ip = split(/!/,$ips); + } else { + @ip = split(/:/,$ips); + } + if ($ip[0] eq $nic ) { + @nic_ips = split(/\|/,$ip[1]); + } +} + + +my $i; +for ($i=0; $i < (scalar @nic_ips) ; $i++ ) { + + # Time to create the interfaces. + # loop through the nic networks, find the matching networks to get the + # subnet and netmask and then create the appropriate ifcfg file for linux + my $specific_nic = $nic; + if ($i > 0) { + $specific_nic = $nic . ":" . ($i); + } + + #todo: support case in which nicnetworks is not specified, find the correct network by calculation + $cnt = 0; + $subnet = ""; + $netmask = ""; + $net_name = ""; + while ( $cnt < $net_cnt ) { + if ( $networks[$cnt][0] eq $nic_nets[$i] ) { + + $subnet = $networks[$cnt][1]; + $netmask = $networks[$cnt][2]; + $cnt = $net_cnt; # found match - get out. + } + else { + $cnt++; + } + } + + # check that there is a subnet and netmask set + if ( !(length($subnet) > 0) || !(length($netmask) > 0) ) { + system("logger -t xcat -p local4.err 'configbond: network subnet or netmask not set.'"); + exit 1; + } + system("logger -t xcat -p local4.err 'configbond: network subnet and netmask: $subnet, $netmask'"); + system("logger -t xcat -p local4.err 'configbond: $specific_nic, $nic_ips[$i]'"); + + # Write the master info to the ifcfg file + if (-d "/etc/sysconfig/network-scripts") { + # rhel/centos/fedora + my $dir = "/etc/sysconfig/network-scripts"; + if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; } + + print FILE "DEVICE=$bond\n"; + print FILE "BOOTPROTO=none\n"; + print FILE "IPADDR=$nic_ips[$i]\n"; + print FILE "NETMASK=$netmask\n"; + print FILE "ONBOOT=yes\n"; + print FILE "USERCTL=no\n"; + print FILE qq(BONDING_OPTS="$bondingopts"\n); + close FILE; + + # Configure slaves + foreach my $dev (@devs) { + system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'"); + if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; } + print FILE "DEVICE=$dev\n"; + print FILE "BOOTPROTO=none\n"; + print FILE "MASTER=$bond\n"; + print FILE "ONBOOT=yes\n"; + print FILE "SLAVE=yes\n"; + print FILE "USERCTL=no\n"; + close FILE; + } + } + elsif (-d "/etc/sysconfig/network") { + # sles + my $dir = "/etc/sysconfig/network"; + if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; } + + print FILE "BOOTPROTO=static\n"; + print FILE "BONDING_MASTER=yes\n"; + print FILE "BONDING_MODULE_OPTS='$bondingopts'\n"; + print FILE "NAME='Bonded Interface'\n"; + print FILE "IPADDR=$nic_ips[$i]\n"; + print FILE "NETMASK=$netmask\n"; + print FILE "STARTMODE=onboot\n"; + print FILE "USERCONTROL=no\n"; + my $devnum = 0; + foreach my $dev (@devs) { + print FILE "BONDING_SLAVE_$devnum=$dev\n"; + $devnum++; + } + close FILE; + + # Configure slaves + foreach my $dev (@devs) { + system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'"); + if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; } + print FILE "BOOTPROTO=none\n"; + print FILE "STARTMODE=hotplug\n"; + close FILE; + } + } + else { + # do not recognize this distro + system("logger -t xcat -p local4.err 'configbond: network directory is not either the Red Hat or SuSE format.'"); + exit 1; + } + + # Apply the changes. Since we are only doing bond1 right now, lets not restart the whole network + # so we dont disrupt the installnic connection. Instead we just need to bring down the slave nics, + # and then bring up the bond nic. + #runcmd("service network restart"); + foreach my $dev (@devs) { + runcmd("ifdown $dev"); + } + runcmd("ifdown $bond"); # in case it was already up + runcmd("ifup $bond"); # note: this wont reload the bonding kernel module, so we are depending on the provisioning process to already have set the correct bonding options + system("logger -t xcat -p local4.info 'configbond: successfully configured $specific_nic.'"); + +} +exit 0; + +sub runcmd { + my $cmd = shift @_; + $cmd .= ' 2>&1'; + my @output = `$cmd`; + my $rc = $? >> 8; + if ($rc) { + system("logger -t xcat -p local4.err 'configeth: command $cmd failed with rc $rc: " . join('',@output) . "'"); + my $errout= "configeth: command $cmd failed with rc $rc."; + `echo $errout`; + exit $rc; + } +} diff --git a/xCAT-SoftLayer/si-post-install/16all.updatenetwork b/xCAT-SoftLayer/si-post-install/16all.updatenetwork index 2d80690aa..db6830859 100755 --- a/xCAT-SoftLayer/si-post-install/16all.updatenetwork +++ b/xCAT-SoftLayer/si-post-install/16all.updatenetwork @@ -1,9 +1,12 @@ #!/bin/bash -# Configure network settings after SI has installed the OS +# SI post-install script to configure network settings after SI has installed the OS +# SI post-install scripts run in a chroot environment of the final OS image . /tmp/post-install/variables.txt +bondingopts='mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1' + # determine if we should be using a static ip or dhcp staticIP () { # Eventually we should use the SI variable IP_ASSIGNMENT_METHOD below to determine this. @@ -35,11 +38,13 @@ if [ -n "$rule_file" ];then fi hostname $HOSTNAME +bond=bond0 device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'` str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat + dir="/etc/sysconfig/network-scripts" grep -i HOSTNAME /etc/sysconfig/network if [ $? -eq 0 ];then sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network @@ -47,21 +52,44 @@ if [ -d "/etc/sysconfig/network-scripts/" ];then echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network fi if staticIP; then + # delete all nic cfg files left over from the golden node + for i in $device_names;do + rm -f "$dir/ifcfg-$i" + done + # set static ip from variables in variables.txt - i="$DEVICE" - str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i" + # write ifcfg-bond0. For now we assume the installnic should be part of bond0, + # because in SL i think that is always the case. + i="$bond" + str_cfg_file="$dir/ifcfg-$i" echo "DEVICE=$i" > $str_cfg_file - echo "BOOTPROTO=static" >> $str_cfg_file + echo "BOOTPROTO=none" >> $str_cfg_file echo "ONBOOT=yes" >> $str_cfg_file + echo "USERCTL=no" >> $str_cfg_file + echo 'BONDING_OPTS="'$bondingopts'"' >> $str_cfg_file echo "IPADDR=$IPADDR" >> $str_cfg_file echo "NETMASK=$NETMASK" >> $str_cfg_file echo "NETWORK=$NETWORK" >> $str_cfg_file echo "BROADCAST=$BROADCAST" >> $str_cfg_file #todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway + + # write ifcfg-eth0 + i="$DEVICE" + str_cfg_file="$dir/ifcfg-$i" + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=none" >> $str_cfg_file + echo "MASTER=$bond" >> $str_cfg_file + echo "ONBOOT=yes" >> $str_cfg_file + echo "SLAVE=yes" >> $str_cfg_file + echo "USERCTL=no" >> $str_cfg_file + + # write modprobe alias config + str_cfg_file="/etc/modprobe.d/$bond.conf" + echo "alias $bond bonding" > $str_cfg_file else # use dhcp for all nics for i in $device_names;do - str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i" + str_cfg_file="$dir/ifcfg-$i" echo "DEVICE=$i" > $str_cfg_file echo "BOOTPROTO=dhcp" >> $str_cfg_file echo "NM_CONTROLLED=yes" >> $str_cfg_file @@ -70,23 +98,54 @@ if [ -d "/etc/sysconfig/network-scripts/" ];then fi elif [ -d "/etc/sysconfig/network/" ];then #suse + dir="/etc/sysconfig/network" echo "$HOSTNAME" > /etc/HOSTNAME if staticIP; then + # delete all nic cfg files left over from the golden node + for i in $device_names;do + rm -f "$dir/ifcfg-$i" + done + # set static ip from variables in variables.txt - i="$DEVICE" - str_cfg_file="/etc/sysconfig/network/ifcfg-$i" - echo "DEVICE=$i" > $str_cfg_file - echo "BOOTPROTO=static" >> $str_cfg_file + # write ifcfg-bond0. For now we assume the installnic should be part of bond0, + # because in SL i think that is always the case. + i="$bond" + str_cfg_file="$dir/ifcfg-$i" + echo "BOOTPROTO=static" > $str_cfg_file echo "STARTMODE=onboot" >> $str_cfg_file + echo "BONDING_MASTER=yes" >> $str_cfg_file + echo "BONDING_MODULE_OPTS='$bondingopts'" >> $str_cfg_file + echo "NAME='Bonded Interface'" >> $str_cfg_file echo "IPADDR=$IPADDR" >> $str_cfg_file echo "NETMASK=$NETMASK" >> $str_cfg_file echo "NETWORK=$NETWORK" >> $str_cfg_file echo "BROADCAST=$BROADCAST" >> $str_cfg_file + echo "USERCONTROL=no" >> $str_cfg_file + echo "BONDING_SLAVE_0=$DEVICE" >> $str_cfg_file + + # write ifcfg-eth0 + i="$DEVICE" + str_cfg_file="$dir/ifcfg-$i" + echo "BOOTPROTO=none" > $str_cfg_file + echo "STARTMODE=hotplug" >> $str_cfg_file + + # write modprobe alias config + str_cfg_file="/etc/modprobe.d/$bond.conf" + echo "alias $bond bonding" > $str_cfg_file + + # this was the original config of the eth0 nic (without bonding) + #echo "DEVICE=$i" > $str_cfg_file + #echo "BOOTPROTO=static" >> $str_cfg_file + #echo "STARTMODE=onboot" >> $str_cfg_file + #echo "IPADDR=$IPADDR" >> $str_cfg_file + #echo "NETMASK=$NETMASK" >> $str_cfg_file + #echo "NETWORK=$NETWORK" >> $str_cfg_file + #echo "BROADCAST=$BROADCAST" >> $str_cfg_file #todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway else # use dhcp for all nics for i in $device_names;do - str_cfg_file="/etc/sysconfig/network/ifcfg-$i" + str_cfg_file="$dir/ifcfg-$i" echo "DEVICE=$i" > $str_cfg_file echo "BOOTPROTO=dhcp" >> $str_cfg_file echo "STARTMODE=onboot" >> $str_cfg_file From 8071c719c6645ac74186f988708378aa910aa081 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2014 10:43:52 -0400 Subject: [PATCH 19/26] defect 4076 --- xCAT-rmc/xCAT-rmc.spec | 2 +- xCAT-server/lib/xcat/plugins/imgport.pm | 2 +- xCAT-server/lib/xcat/plugins/kit.pm | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-rmc/xCAT-rmc.spec b/xCAT-rmc/xCAT-rmc.spec index 6262886df..d7c6f6e73 100644 --- a/xCAT-rmc/xCAT-rmc.spec +++ b/xCAT-rmc/xCAT-rmc.spec @@ -106,7 +106,7 @@ fi %ifos linux if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then - /etc/init.d/xcatd reload + /etc/init.d/xcatd restart fi fi %else diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm index c5a88e336..cec8609d2 100644 --- a/xCAT-server/lib/xcat/plugins/imgport.pm +++ b/xCAT-server/lib/xcat/plugins/imgport.pm @@ -1901,7 +1901,7 @@ sub make_files { } if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); $hasplugin=0; } diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 0d6912c54..0a074fa70 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1411,7 +1411,7 @@ sub addkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); } } } @@ -1716,7 +1716,7 @@ sub rmkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); } } From 1700471ada3cdff742c337fa11ecb8c45db0178d Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2014 10:46:39 -0400 Subject: [PATCH 20/26] defect 4076 --- xCAT-OpenStack/xCAT-OpenStack.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-OpenStack/xCAT-OpenStack.spec b/xCAT-OpenStack/xCAT-OpenStack.spec index d0ff64bab..7f1817951 100644 --- a/xCAT-OpenStack/xCAT-OpenStack.spec +++ b/xCAT-OpenStack/xCAT-OpenStack.spec @@ -89,7 +89,7 @@ rm -rf $RPM_BUILD_ROOT %ifos linux if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then - /etc/init.d/xcatd reload + /etc/init.d/xcatd restart fi fi %endif From d8431f4fd32e9048f9e52c287bb6aeb2929227c6 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2014 12:48:04 -0400 Subject: [PATCH 21/26] defect 4124 --- xCAT/postscripts/setupnfsv4replication | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/setupnfsv4replication b/xCAT/postscripts/setupnfsv4replication index 092007aef..663fcd1cf 100755 --- a/xCAT/postscripts/setupnfsv4replication +++ b/xCAT/postscripts/setupnfsv4replication @@ -10,7 +10,7 @@ # Change these two parameters according to your requirements $::NFSRETRIES = 3; -$::NFSTIMEO = 10; +$::NFSTIMEO = 50; # Candidate commands: mount, df, lsfs, nfs4cl showfs # Only the mount command could list all file systems From 0e21fa39310f4d3d623d74205b69fe787c34e1e4 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2014 13:25:44 -0400 Subject: [PATCH 22/26] backup 4091, not correct --- xCAT/postscripts/setupesx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 xCAT/postscripts/setupesx diff --git a/xCAT/postscripts/setupesx b/xCAT/postscripts/setupesx old mode 100644 new mode 100755 index 3f6a9f09e..0e062cd60 --- a/xCAT/postscripts/setupesx +++ b/xCAT/postscripts/setupesx @@ -43,9 +43,9 @@ cat >/tmp/esxcfg.sh < Date: Tue, 13 May 2014 05:37:14 -0700 Subject: [PATCH 23/26] Modify flag and help information --- xCAT-test/restapitest | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest index 425ef7b2a..df87c9068 100755 --- a/xCAT-test/restapitest +++ b/xCAT-test/restapitest @@ -14,7 +14,7 @@ # -n hostname # Flags are used for check output: # -o expected output -# -l logical operator +# -O logical operator # # Expected result format is '{ANY:{ANY:content}}' # These steps are used to explain how to scan result @@ -64,7 +64,7 @@ if ( "c=s" => \$cert, "n=s" => \$hostname, "o=s" => \$output, - "l=s" => \$loperator, + "O=s" => \$loperator, "debug" => \$debug, ) ) { @@ -181,7 +181,7 @@ sub usage print " testrestapi [-m method] [-r resource] [-t tocken]\n"; print " [-h host] [-P port][-u user] [-p passwd]\n"; print " [-d data] [-c cert] [-n hostname]\n"; - print " [-o expect_output] [-l logical_operator] [-debug]\n"; + print " [-o expect_output] [-O logical_operator] \n"; print " [-debug]\n"; print "\n"; return; From e4befe9959542bce6d569c9b0a658d8bf72fe4b8 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 13 May 2014 09:06:51 -0400 Subject: [PATCH 24/26] defect 4091 --- xCAT/postscripts/updatenetwork | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index 40d76a51d..d1bcd6a4c 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -11,7 +11,8 @@ hostname $HOSTNAME #write the config files, the device name may change after reboot #so use the dhcp for all interface -device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'` +#device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'` +device_names=`ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://` str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat From 231dbd84f5affd0d940ffd87c7ee4c4b8b81ff16 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 14 May 2014 08:03:35 -0400 Subject: [PATCH 25/26] use ip command to replace ifconfig in xcatroot for diskless on rh3 --- .../share/xcat/netboot/rh/dracut_033/xcatroot | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 4cde3f1ca..feed0dcd3 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -218,6 +218,25 @@ else fi cd / +function getdevfrommac() { + boothwaddr=$1 + ip link show | while read line + do + dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1` + if [ "X$dev" != "X" ]; then + devname=$dev + fi + + if [ "X$devname" != "X" ]; then + hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'` + if [ "X$hwaddr" = "X$boothwaddr" ]; then + echo $devname + fi + fi + done +} + + if [ -z $STATEMNT ]; then for lf in /tmp/dhclient.*.lease; do netif=${lf#*.} @@ -233,7 +252,7 @@ if [ -z $STATEMNT ]; then MACX=`ip link show $netdev | grep ether | awk '{print $2}'` elif [ ! -z "$BOOTIF" ]; then MACX=$BOOTIF - ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` + ETHX=$(getdevfrommac $BOOTIF) fi if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then From 269ef4d95042c4196ceb80e4cd64090efe8a984a Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 14 May 2014 08:01:41 -0400 Subject: [PATCH 26/26] defect 4091 --- xCAT/postscripts/hardeths | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index 68e963c22..b29e2953c 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -1,4 +1,4 @@ -#!/bin/sh +PREFIXMASK#!/bin/sh # pmatch determines if 1st argument string is matched by 2nd argument pattern pmatch () @@ -9,6 +9,18 @@ pmatch () return 1 # non-zero return code means string not matched by pattern } +# converts netmask CIDR fromat to x.x.x.x mask value +maskfromprefix () +{ + prefixlen=$1 + maskval=$((0xffffffff>>(32-prefixlen)<<(32-prefixlen))) + mask1=$((maskval >> 24)) + mask2=$((maskval >> 16 & 0xff)) + mask3=$((maskval >> 8 & 0xff)) + mask4=$((maskval & 0xff)) + echo $mask1.$mask2.$mask3.$mask4 + NETMASK=$mask1.$mask2.$mask3.$mask4 +} network_ipv4calc () { @@ -56,9 +68,12 @@ else echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi fi -for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do - IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'` - NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'` +for nic in `ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://`; do + IPADDRMASK=`ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1` + IPADDR=`echo $IPADDRMASK | awk -F'/' '{print $1}'` + PREFIXMASK=`echo $IPADDRMASK | awk -F'/' '{print $2}'` + # converts to x.x.x.x mask value + maskfromprefix $PREFIXMASK if ( pmatch $OSVER "ubuntu*" ) then NETWORK=`network_ipv4calc $IPADDR $NETMASK` @@ -69,7 +84,7 @@ for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep else gateway_line="" fi - + # add info to interfaces file on ubuntu, TBD does unbuntu change to systemd, this will not exist cat >>/etc/network/interfaces <