From ff49bb5e074fa9b3401090023184f524cf431e15 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 7 May 2014 14:17:00 -0400 Subject: [PATCH 01/13] 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 bfefa58be..d76f863e6 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -736,6 +736,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 cb0f268589c4d40c6778a0ca536f71c0f4fb0b2f Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 May 2014 04:48:33 -0400 Subject: [PATCH 02/13] defect 4116: fix the issue that send_response subroutine doesnot exist in xcatd 2.8.4 but was used. --- xCAT-server/sbin/xcatd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index efd402948..b971854c6 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1998,7 +1998,7 @@ sub service_connection { $resp={error=>["Authentication failure"],errorcode=>[1]}; } $resp->{serverdone}=[ undef ] ; - send_response($resp,$sock); + print $sock XMLout($resp,RootName => 'xcatresponse',NoAttr=>1); return; } @@ -2009,7 +2009,7 @@ sub service_connection { unless (defined $peername) { my $resp={error=>["Authentication failure"],errorcode=>[1]}; $resp->{serverdone}=[ undef ] ; - send_response($resp,$sock); + print $sock XMLout($resp,RootName => 'xcatresponse',NoAttr=>1); return; } delete($req->{tokenid}); From bd70bdd89e57a799f975c383ba505557f03650c7 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 05:03:03 -0700 Subject: [PATCH 03/13] Add a new restapitest script --- 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 a8835bef34f7e2755a72b298afab39f54bc76aa4 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 05:15:30 -0700 Subject: [PATCH 04/13] 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 854f6fde3bab5772d59ca6b2b8f6119adbda051d Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 06:09:20 -0700 Subject: [PATCH 05/13] 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 467d54c4a318666c1233d1166fe2b5b78798df65 Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 8 May 2014 08:02:30 -0700 Subject: [PATCH 06/13] 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 f3f19a6ff6c3a53b58147575231801b0aa7537e7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 May 2014 03:22:23 -0700 Subject: [PATCH 07/13] 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 82dc54ce5..3ba3117c4 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; @@ -248,6 +243,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']); @@ -619,6 +615,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; @@ -686,7 +698,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 b94432d9f16740d0c5ba91afb81efd0fb5602b0c Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 May 2014 03:45:39 -0700 Subject: [PATCH 08/13] 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 9f0fddf60..c77177ae7 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 ed76d20ea9fcfddc610884b2294277e52a456da7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 9 May 2014 02:02:45 -0700 Subject: [PATCH 09/13] 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 d3a3a29fc..786dcbfd0 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1183,11 +1183,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: Thu, 8 May 2014 00:38:30 -0700 Subject: [PATCH 10/13] 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 1a936d5c8..22c6dcdb6 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 30d891e34162146a92b6817d5342f3e5d59a0f24 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 12 May 2014 01:46:04 -0700 Subject: [PATCH 11/13] fix defect #4123 [fvt]2.8.4:ubuntu 12.04 diskfull install failed --- xCAT/debian/dirs | 1 + xCAT/debian/install | 2 +- xCAT/debian/postinst | 10 ++++------ 3 files changed, 6 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 bf457cc40..6e6d4cebc 100644 --- a/xCAT/debian/postinst +++ b/xCAT/debian/postinst @@ -40,12 +40,10 @@ 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/xcat.conf - 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 ded873f998a889c91a169d3f870efdbebfb66243 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 12 May 2014 02:06:08 -0700 Subject: [PATCH 12/13] 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 5451c4eb599786426c6064dd775588f5876a00b0 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2014 12:47:14 -0400 Subject: [PATCH 13/13] 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