From f5c07589210fcd55a7eb2768aa89c3303477be56 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Tue, 15 Apr 2014 01:23:08 -0700 Subject: [PATCH 01/28] add powerkvm VM support for mkvm,chvm,rmvm,rpower --- xCAT-server/lib/xcat/plugins/kvm.pm | 75 ++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 20463759c..ee2b58052 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -470,26 +470,7 @@ sub build_diskstruct { my $currdev; my @suffixes=('a','b','d'..'zzz'); my $suffidx=0; - if ($cdloc) { - my $cdhash; - $cdhash->{device}='cdrom'; - if ($cdloc =~ /^\/dev/) { - $cdhash->{type}='block'; - } else { - $cdhash->{type}='file'; - } - $cdhash->{source}->{file}=$cdloc; - $cdhash->{readonly}; - $cdhash->{target}->{dev}='hdc'; - push @returns,$cdhash; - } else { #give the VM an empty optical drive, to allow chvm live attach/remove - my $cdhash; - $cdhash->{device}='cdrom'; - $cdhash->{type}='file'; - $cdhash->{readonly}; - $cdhash->{target}->{dev}='hdc'; - push @returns,$cdhash; - } + my $storagemodel = $confdata->{vm}->{$node}->[0]->{storagemodel}; my $cachemethod = "none"; if ( $confdata->{vm}->{$node}->[0]->{storagecache}) { $cachemethod = $confdata->{vm}->{$node}->[0]->{storagecache}; @@ -506,7 +487,7 @@ sub build_diskstruct { my $model = $1; unless ($model) { #if not defined, model will stay undefined like above - $model = $confdata->{vm}->{$node}->[0]->{storagemodel}; + $model = $storagemodel; unless ($model) { $model = 'ide'; } #if still not defined, ide } my $prefix='hd'; @@ -574,6 +555,34 @@ sub build_diskstruct { push @returns,$diskhash; } } + my $cdprefix='hd'; + if ($storagemodel eq 'virtio') { + $cdprefix='vd'; + } elsif ($storagemodel eq 'scsi') { + $cdprefix='sd'; + } + $suffidx += 1; + if ($cdloc) { + my $cdhash; + $cdhash->{device}='cdrom'; + if ($cdloc =~ /^\/dev/) { + $cdhash->{type}='block'; + } else { + $cdhash->{type}='file'; + } + $cdhash->{source}->{file}=$cdloc; + $cdhash->{readonly}; + $cdhash->{target}->{dev}=$cdprefix.$suffixes[$suffidx]; + push @returns,$cdhash; + } else { #give the VM an empty optical drive, to allow chvm live attach/remove + my $cdhash; + $cdhash->{device}='cdrom'; + $cdhash->{type}='file'; + $cdhash->{readonly}; + $cdhash->{target}->{dev}=$cdprefix.$suffixes[$suffidx]; + push @returns,$cdhash; + } + return \@returns; } sub getNodeUUID { @@ -654,10 +663,16 @@ sub build_xmldesc { my %args=@_; my $cdloc=$args{cd}; my %xtree=(); + my $hypcpumodel = $confdata->{$confdata->{vm}->{$node}->[0]->{host}}->{cpumodel}; $xtree{type}='kvm'; $xtree{name}->{content}=$node; $xtree{uuid}->{content}=getNodeUUID($node); $xtree{os} = build_oshash(); + if (defined($hypcpumodel) and $hypcpumodel eq "ppc64") { + $xtree{os}->{type}->{arch} = "ppc64"; + $xtree{os}->{type}->{machine} = "pseries"; + delete $xtree{os}->{bios}; + } if ($args{memory}) { $xtree{memory}->{content}=getUnits($args{memory},"M",1024); if ($confdata->{vm}->{$node}->[0]->{memory}) { @@ -723,8 +738,12 @@ sub build_xmldesc { } else { $xtree{devices}->{graphics}->{password}=genpassword(20); } - $xtree{devices}->{sound}->{model}='ac97'; - + if (defined($hypcpumodel) and $hypcpumodel eq 'ppc64') { + $xtree{devices}->{emulator}->{content} = "/usr/bin/qemu-system-ppc64"; + } else { + $xtree{devices}->{sound}->{model}='ac97'; + } + $xtree{devices}->{console}->{type}='pty'; $xtree{devices}->{console}->{target}->{port}='1'; return XMLout(\%xtree,RootName=>"domain"); @@ -2988,7 +3007,17 @@ sub dohyp { return 1,"General error establishing libvirt communication"; } } + if (($command eq 'mkvm' or $command eq 'chvm') and $hypconn) { + my $nodeinfo = $hypconn->get_node_info(); + if (exists($nodeinfo->{model})) { + $confdata->{$hyp}->{cpumodel} = $nodeinfo->{model}; + } + } + foreach $node (sort (keys %{$hyphash{$hyp}->{nodes}})) { + if ($confdata->{$hyp}->{cpumodel} and $confdata->{$hyp}->{cpumodel} =~ /ppc64/i) { + $confdata->{vm}->{$node}->[0]->{storagemodel} = "scsi"; + } my ($rc,@output) = guestcmd($hyp,$node,$command,@$args); foreach(@output) { From a2b241d6d3dc8d91ff67f609139ef26c2f167814 Mon Sep 17 00:00:00 2001 From: yinle Date: Tue, 15 Apr 2014 07:38:28 -0700 Subject: [PATCH 02/28] Adjust formate, add fork progress, move code into sub-routines --- xCAT-server/share/xcat/tools/xCATreg | 735 +++++++++++++++------------ 1 file changed, 404 insertions(+), 331 deletions(-) mode change 100755 => 100644 xCAT-server/share/xcat/tools/xCATreg diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg old mode 100755 new mode 100644 index 14cfe2151..a9f19badd --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -35,6 +35,7 @@ BEGIN $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } use lib "$::XCATROOT/lib/perl"; +my %confhash; my $rootdir = "$::XCATROOT/share/xcat/tools/autotest"; my $needhelp = 0; my $branch = 0; @@ -66,7 +67,7 @@ my $dsklscnsninst=0; my $fullcnsninst=0; my $statelitecnsninst=0; my %confkeys; -my $confile; +my %results; ####################################### # usage for arguments @@ -95,13 +96,13 @@ sub config_rhppc64 { send_msg("******************************"); send_msg("Reading Configure"); send_msg("******************************"); -#if(!(-e $configfile)){ - # send_msg("Warning: The xCAT test Configure file doesn't exist!"); - # send_msg("Warning: The xCAT test Configure file doesn't exist!"); - # return 0; - # } - my $type = undef; - my $sub_type = undef; # The string after $type_ + #if(!(-e $configfile)){ + #send_msg("Warning: The xCAT test Configure file doesn't exist!"); + #send_msg("Warning: The xCAT test Configure file doesn't exist!"); + #return 0; + #} + my $type = undef; + my $sub_type = undef; # The string after $type_ # Script--> # Script_Prev # Script_Post @@ -143,7 +144,7 @@ sub config_rhppc64 { $name = $value; $rhppc64config{table}{$sub_type}{$name}{__KEY__}=$attr; } - } + } }elsif ($type eq "rhppc64Object") { ##OBJECT BLOCK## if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { @@ -178,8 +179,8 @@ sub config_rhppc64 { print "var $1,$2\n"; } } -} - if(exists $rhppc64config{object}){ + } + if(exists $rhppc64config{object}){ foreach my $type (keys %{$rhppc64config{object}}){ foreach my $name (keys %{$rhppc64config{object}{$type}}){ send_msg("OBJECT:$name,TYPE:$type"); @@ -188,26 +189,26 @@ sub config_rhppc64 { #print "$name,TYPE:$type \n"; foreach my $attr (keys %{$rhppc64config{object}{$type}{$name}}){ send_msg(" $attr = $rhppc64config{object}{$type}{$name}{$attr};"); - &runcmd( " echo $attr=$rhppc64config{object}{$type}{$name}{$attr}>>default.conf"); + &runcmd( " echo $attr=$rhppc64config{object}{$type}{$name}{$attr}>>default.conf"); } } } } - if(exists $rhppc64config{table}){ - foreach my $type (keys %{$rhppc64config{table}}){ + if(exists $rhppc64config{table}){ + foreach my $type (keys %{$rhppc64config{table}}){ send_msg("TABLE:$type"); &runcmd( " echo [Table_$type]>>default.conf"); - # &runcmd( " echo key=$type>>default.conf"); - #&runcmd( " echo [Table_site]>>default.conf"); - # &runcmd( " echo key=$type>>default.conf"); + #&runcmd( " echo key=$type>>default.conf"); + #&runcmd( " echo [Table_site]>>default.conf"); + #&runcmd( " echo key=$type>>default.conf"); foreach my $name (keys %{$rhppc64config{table}{$type}}){ - send_msg(" $rhppc64config{table}{$type}{$name}{__KEY__} = $name"); + send_msg(" $rhppc64config{table}{$type}{$name}{__KEY__} = $name"); &runcmd( " echo $rhppc64config{table}{$type}{$name}{__KEY__}=$name>>default.conf"); - foreach my $attr (keys %{$rhppc64config{table}{$type}{$name}}){ - if($attr ne '__KEY__'){ - send_msg(" $attr = $rhppc64config{table}{$type}{$name}{$attr}"); - &runcmd( " echo $attr=$rhppc64config{table}{$type}{$name}{$attr}>>default.conf"); - } + foreach my $attr (keys %{$rhppc64config{table}{$type}{$name}}){ + if($attr ne '__KEY__'){ + send_msg(" $attr = $rhppc64config{table}{$type}{$name}{$attr}"); + &runcmd( " echo $attr=$rhppc64config{table}{$type}{$name}{$attr}>>default.conf"); + } } send_msg("\n"); } @@ -220,31 +221,141 @@ sub config_rhppc64 { } } - if(exists $rhppc64config{script_post}){ - send_msg("Script_Post:"); + if(exists $rhppc64config{script_post}){ + send_msg("Script_Post:"); foreach $cmd (@{$rhppc64config{script_post}}){ send_msg(" $cmd"); } } -if (exists $rhppc64config{var}){ -#my $MN=$rhppc64config{var}{MN}; -#my $MNIP=$rhppc64config{var}{MNIP}; -#&runcmd( "echo $MN $MN.$DOMAIN $MNIP>>/etc/hosts"); -#print "MN is $MN\n";} - send_msg("Varible:"); - &runcmd( " echo [System]>>default.conf"); - foreach my $varname (keys %{$rhppc64config{var}}){ - send_msg(" $varname = $rhppc64config{var}{$varname}"); - &runcmd( " echo $varname=$rhppc64config{var}{$varname}>>default.conf"); -#print "var is $rhppc64config{var}\n"; + if (exists $rhppc64config{var}){ + #my $MN=$rhppc64config{var}{MN}; + #my $MNIP=$rhppc64config{var}{MNIP}; + #&runcmd( "echo $MN $MN.$DOMAIN $MNIP>>/etc/hosts"); + #print "MN is $MN\n";} + send_msg("Varible:"); + &runcmd( " echo [System]>>default.conf"); + foreach my $varname (keys %{$rhppc64config{var}}){ + send_msg(" $varname = $rhppc64config{var}{$varname}"); + &runcmd( " echo $varname=$rhppc64config{var}{$varname}>>default.conf"); + #print "var is $rhppc64config{var}\n"; } -} + } -close FILE; + close FILE; return 0; } +####################################### +# git update +####################################### +sub git_update { + send_msg("begin to do git update"); + + my $gitup; + $gitup="/tmp/gitup"; + + #Do checkout in git repo + #$res = system("cd $confkeys{srcdir}"); + #if ($res !=0) { + # send_msg("no source code directory,exit"); + # + # exit; + #} + + $res = system("git checkout $branch"); + if ($res != 0){ + send_msg("git checkout failed"); + exit 1; + } + + $res = system("git pull >$gitup"); + if ($res != 0){ + send_msg("git pull failed"); + exit 1; + } + + $res = system("grep 'Already up-to-date' $gitup"); + if (($res == 0)&&( $updates_regression == 1)) { + send_msg("code is already at latest version. exit regresson\n"); + exit 1; + } + return 0; +} +####################################### +# copy code +####################################### +sub copy_code { + my $codedir = $confhash{srcdir}; + send_msg("src code directory is $confhash{srcdir}"); + + ##will modify to $rhppc64config{var}{MNIP} + my $mn = $management_node; + send_msg("mn is $mn"); + + #install dep for buildlocal + send_msg("begin to install build required packages on mn"); + $res = system("xdsh $mn yum install -y rpm-build perl-Time-HiRes perl-DBI createrepo"); + + + #need to copy /etc/hosts to mn + send_msg("copy /etc/hosts to mn"); + system("scp /etc/hosts $mn:/etc"); + + send_msg("begin to copy code"); + $res = system("scp -r $codedir root\@$mn:/"); + if ($res != 0){ + send_msg("code copy failed"); + exit 1; + } + return 0; +} + + + +####################### +# build xcat +####################### +sub build_xcat { + my $mn = shift; + #for temp usage + send_msg("========= began build xcat on mn ========"); + #will changed /code/xcat-core to $confkeys{srcdir} + $res = system("xdsh $mn /xcat-core/buildlocal.sh CURDIR=/xcat-core"); + if ($res != 0){ + send_msg("build failed on mn"); + exit 1; + } + + send_msg("====================build done============================"); + sleep 20; + return 0; +} + +####################################### +# config mn +####################################### +sub config_mn { + my $mn = shift; + send_msg("begin read configuration file for mn"); + mkdir $resultdir unless -d $resultdir; + $timestamp = `date +"%Y%m%d%H%M%S"`; + my @osname = &runcmd("uname -a"); + #if ( $osname [0] =~ /^Linux\s*/ && -f "/etc/redhat-release" && $osname [0] =~ /ppc64/){ + #print "ppc64 redhat env\n"; + #$os="rhels6.4"; + #$arch="ppc64"; + #print "os is $os,arch is $arch\n"; + $res = &config_rhppc64(); + if ($res) { + send_msg("CONFIGURE MN returns error, exit"); + exit 1; + } + #} + + send_msg("step 6 : reading mn configuration done====="); + return 0; +} ####################################### # install xcat and init rhppc64 env ####################################### @@ -281,10 +392,10 @@ sub init print "[OK]\n"; print "--get the latest XCAT tarball.......\n"; system("xdsh $MN rm -rf /etc/yum.repos.d/*"); - $res = system("scp -r $nodedir/xcat-dep $MN:/"); + $res = system("scp -r $nodedir/xcat-dep $MN:/"); system("scp -r /etc/yum.repos.d/rhel6.4.repo $MN:/etc/yum.repos.d/rhel6.4.repo"); ######## redhat 6.4 -# system("scp -r default.conf $MN:$rhppc64configfile"); -# system("xdsh $MN perl $nodedir/xcatbuild/xcat-core/mklocalrepo.sh"); + #system("scp -r default.conf $MN:$rhppc64configfile"); + #system("xdsh $MN perl $nodedir/xcatbuild/xcat-core/mklocalrepo.sh"); system("xdsh $MN perl /xcat-dep/rh6/ppc64/mklocalrepo.sh"); print "--install XCAT .......\n"; @@ -298,143 +409,152 @@ sub init system("xdsh $MN yum -y install xCAT-test"); print "--install createrepo .......\n"; -# system("xdsh $MN yum -y install createrepo"); + #system("xdsh $MN yum -y install createrepo"); system("xdsh $MN yum -y install screen"); system("xdsh $MN yum -y install mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc"); system("xdsh $MN mkdir -p /autotest/result"); - # system("xdsh $MN sysctl -n net.ipv4.ip_forward=1"); - $res = system("xdsh $MN source /etc/profile.d/xcat.sh"); - # if ($res != 0){ - # send_msg("install xCAT failed on rhpmn"); - # exit 1; - #} + #system("xdsh $MN sysctl -n net.ipv4.ip_forward=1"); + $res = system("xdsh $MN source /etc/profile.d/xcat.sh"); + #if ($res != 0){ + #send_msg("install xCAT failed on rhpmn"); + #exit 1; + #} send_msg( " rhppc64 env is ready\n"); -} + } return 0; } +####################################### +# do test +####################################### +sub do_test { + # step 7.1 Install xcat and init mn + send_msg("began to install xCAT and initialize mn"); + $res = &init; + if ($res != 0){ + exit 1; + } + + send_msg("Begin to do test"); + $res = &do_test1; + if ($res) { + send_msg("DO TEST returns error, exit"); + exit 1; + } + return 0; +} ####################################### # run all test ####################################### -sub do_test +sub do_test1 { -my $MN=$rhppc64config{var}{MN}; -my $nodedir=$rhppc64config{var}{nodedir}; -print "copy config file "; -system("scp -r default.conf $MN:$rhppc64configfile"); - -print "Start to run diskless installation ...\n"; - send_msg("******************************"); - send_msg("start diskless test"); - send_msg("******************************"); -#if($dsklsinst){ - system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t /opt/xcat/share/xcat/tools/autotest/testcase/installation/linux_diskless_installation"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); -exit 1; - -#} -#if($bundlerun){ - print "Start to run the automation test bucket ....\n"; - # system("xdsh $MN mkdir -p /autotest/result"); - system("xdsh $MN /opt/xcat/bin/xcattest -b /opt/xcat/share/xcat/tools/autotest/bundle/bat.bundle"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); -# $output = ("xdsh $MN tail /autotest/result/xcattest.log.$timestamp"); -#if($output =~ /Total: (\d+) , Failed: (\d+)/){ - # send_msg{command}{total} = $1; - # send_msg{command}{fail} = $2; - # send_msg{command}{timestamp} = $timestamp; - # if(send_msg{command}{fail} != 0){ - # send_msg{command}{failcase} = "| | | Failed cases:"."\n"; - # $output = (xdsh $MN cat /autotest/result/failedcases.$timestamp | grep END); - # while($output =~ /END::(\w+)/g){ - # send_msg{command}{failcase} = $send_msg{command}{failcase}."| | | ".$1."\n"; -# print "$msg{command}{failcase}"; - - # } - # print "$send_msg{command}{failcase}"; - #} -#} -#} -#if($stateliteinst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_statelite_installation_flat_ppc64"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); - #$output = system(" xdsh $MN tail /autotest/result/xcattest.log.$timestamp"); - #if($output =~ /Failed: (\d+)/){ - # if($1 != 0){ - # send_msg{linux_statelite_installation_flat}{pass} = 0; - # send_msg{linux_statelite_installation_flat}{timestamp} = $timestamp; - # } else { - # send_msg{linux_statelite_installation_flat}{pass} = 1; - #} + my $MN=$rhppc64config{var}{MN}; + my $nodedir=$rhppc64config{var}{nodedir}; + print "copy config file "; + system("scp -r default.conf $MN:$rhppc64configfile"); + + print "Start to run diskless installation ...\n"; + send_msg("******************************"); + send_msg("start diskless test"); + send_msg("******************************"); + #if($dsklsinst){ + system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t /opt/xcat/share/xcat/tools/autotest/testcase/installation/linux_diskless_installation"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # exit 1; #} - -#} -#if($fullinst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_full_installation_flat_ppc64"); - - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); - #$output = xdsh $MN tail /autotest/result/xcattest.log.$timestamp; - # if($output =~ /Failed: (\d+)/){ - # if($1 != 0){ - # send_msg{linux_full_installation_flat}{pass} = 0; - # send_msg{linux_full_installation_flat}{timestamp} = $timestamp; - # } else { - # send_msg{linux_full_installation_flat}{pass} = 1; - #} + #if($bundlerun){ + print "Start to run the automation test bucket ....\n"; + # system("xdsh $MN mkdir -p /autotest/result"); + system("xdsh $MN /opt/xcat/bin/xcattest -b /opt/xcat/share/xcat/tools/autotest/bundle/bat.bundle"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + # $output = ("xdsh $MN tail /autotest/result/xcattest.log.$timestamp"); + # if($output =~ /Total: (\d+) , Failed: (\d+)/){ + # send_msg{command}{total} = $1; + # send_msg{command}{fail} = $2; + # send_msg{command}{timestamp} = $timestamp; + # if(send_msg{command}{fail} != 0){ + # send_msg{command}{failcase} = "| | | Failed cases:"."\n"; + # $output = (xdsh $MN cat /autotest/result/failedcases.$timestamp | grep END); + # while($output =~ /END::(\w+)/g){ + # send_msg{command}{failcase} = $send_msg{command}{failcase}."| | | ".$1."\n"; + # print "$msg{command}{failcase}"; + # } + # print "$send_msg{command}{failcase}"; + # } + # } + # } + #if($stateliteinst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_statelite_installation_flat_ppc64"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + # $output = system(" xdsh $MN tail /autotest/result/xcattest.log.$timestamp"); + # if($output =~ /Failed: (\d+)/){ + # if($1 != 0){ + # send_msg{linux_statelite_installation_flat}{pass} = 0; + # send_msg{linux_statelite_installation_flat}{timestamp} = $timestamp; + # } else { + # send_msg{linux_statelite_installation_flat}{pass} = 1; + # } + # } #} - -#} -#if($snfullinst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_sn_installation_flat_x86_vm"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - #system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); - # $output = xdsh $MN tail /autotest/result/xcattest.log.$timestamp; - # if($output =~ /Failed: (\d+)/){ - # if($1 != 0){ - # send_msg{linux_sn_installation_flat}{pass} = 0; - # send_msg{linux_sn_installation_flat}{timestamp} = $timestamp; - # } else { - # send_msg{linux_sn_installation_flat}{pass} = 1; - #} + #if($fullinst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_full_installation_flat_ppc64"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + # $output = xdsh $MN tail /autotest/result/xcattest.log.$timestamp; + # if($output =~ /Failed: (\d+)/){ + # if($1 != 0){ + # send_msg{linux_full_installation_flat}{pass} = 0; + # send_msg{linux_full_installation_flat}{timestamp} = $timestamp; + # } else { + # send_msg{linux_full_installation_flat}{pass} = 1; + # } + # } #} - -#} -#if($dsklscnsninst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_diskless_installation_flat_x86_vm"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); - # if($output =~ /Failed: (\d+)/){ - # if($1 != 0){ - # send_msg{linux_cn_with_sn_diskless_installation_flat}{pass} = 0; - # send_msg{linux_cn_with_sn_diskless_installation_flat}{timestamp} = $timestamp; - # } else { - # send_msg{linux_cn_with_sn_diskless_installation_flat}{pass} = 1; - #} + #if($snfullinst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_sn_installation_flat_x86_vm"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + # $output = xdsh $MN tail /autotest/result/xcattest.log.$timestamp; + # if($output =~ /Failed: (\d+)/){ + # if($1 != 0){ + # send_msg{linux_sn_installation_flat}{pass} = 0; + # send_msg{linux_sn_installation_flat}{timestamp} = $timestamp; + # } else { + # send_msg{linux_sn_installation_flat}{pass} = 1; + # } + # } #} - -#} -#if($statelitecnsninst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_statelite_installation_flat_x86_vm"); - system(" xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - #system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); -#} -#if($fullcnsninst){ - system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_full_installation_flat_x86_vm"); - system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); - # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); - -#} -#system("mkdir -p $nodedir/result"); -system("scp -r $MN:/autotest/result /regression/rhppc64"); - - + #if($dsklscnsninst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_diskless_installation_flat_x86_vm"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + # if($output =~ /Failed: (\d+)/){ + # if($1 != 0){ + # send_msg{linux_cn_with_sn_diskless_installation_flat}{pass} = 0; + # send_msg{linux_cn_with_sn_diskless_installation_flat}{timestamp} = $timestamp; + # } else { + # send_msg{linux_cn_with_sn_diskless_installation_flat}{pass} = 1; + # } + # } + #} + #if($statelitecnsninst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_statelite_installation_flat_x86_vm"); + system(" xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + #} + #if($fullcnsninst){ + system("xdsh $MN /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_cn_with_sn_full_installation_flat_x86_vm"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + # system("xdsh $MN cp /autotest/result/xcattest.log.$timestamp /autotest/result/log/xcattest.log.$timestamp.current"); + #} + #system("mkdir -p $nodedir/result"); + system("scp -r $MN:/autotest/result /regression/rhppc64"); } ####################################### @@ -468,7 +588,6 @@ sub mn_install { # runcmd ####################################### sub runcmd { - my ($cmd) = @_; my $rc = 0; $::RUNCMD_RC = 0; @@ -481,7 +600,6 @@ sub runcmd { } chomp(@$outref); return @$outref; - } ####################################### @@ -491,9 +609,9 @@ sub trim { my $str = shift @_; if($str){ -# $str =~ s/\#/__wellnumber__/g; + #$str =~ s/\#/__wellnumber__/g; $str =~ s/^\s+|#.+|\s+$//g; - # $str =~ s/__wellnumber__/#/g; + #$str =~ s/__wellnumber__/#/g; } return $str; } @@ -503,58 +621,60 @@ sub trim { ####################################### sub send_msg { my $msg = shift; - print "xcatreg message: $msg.\n"; + print "xcatreg message: $msg.\n"; } ####################################### # read_conf ####################################### sub read_conf{ - my $keys; - if (!open($keys, "<$confile")) { - send_msg("Open configuration file error"); - } - my $line; - while ($line = <$keys>) { - if ($line =~ /end/) { - last; - } - if ($line =~ /^\s*log\s*=\s*(\S*)\s*/) { - $confkeys{log} = $1; - } - if ($line =~ /^\s*mailgroup\s*=\s*(\S*)\s*/) { - $confkeys{mailgroup} = $1; - } - if ($line =~ /^\s*srcdir\s*=\s*(\S*)\s*/) { - $confkeys{srcdir} = $1; - } - if ($line =~ /^\s*rhpdir\s*=\s*(\S*)\s*/) { - $confkeys{rhpdir} = $1; - } - if ($line =~ /^\s*slespdir\s*=\s*(\S*)\s*/) { - $confkeys{slespdir} = $1; - } - if ($line =~ /^\s*aixdir\s*=\s*(\S*)\s*/) { - $confkeys{aixdir} = $1; - } - if ($line =~ /^\s*rhxdir\s*=\s*(\S*)\s*/) { - $confkeys{rhxdir} = $1; - } - if ($line =~ /^\s*slesxdir\s*=\s*(\S*)\s*/) { - $confkeys{slesxdir} = $1; - } - if ($line =~ /^\s*ubuntudir\s*=\s*(\S*)\s*/) { - $confkeys{ubuntudir} = $1; - } - if ($line =~ /^\s*xcattestconf\s*=\s*(\S*)\s*/) { - $confkeys{xcattestconf} = $1; - } - + my $keys; + if (!open($keys, "<$configfile")) { + send_msg("Open configuration file error"); } + my $line; + while ($line = <$keys>) { + if ($line =~ /end/) { + last; + } + if ($line =~ /^\s*log\s*=\s*(\S*)\s*/) { + $confkeys{log} = $1; + } + if ($line =~ /^\s*mailgroup\s*=\s*(\S*)\s*/) { + $confkeys{mailgroup} = $1; + } + if ($line =~ /^\s*srcdir\s*=\s*(\S*)\s*/) { + $confkeys{srcdir} = $1; + } + if ($line =~ /^\s*rhpdir\s*=\s*(\S*)\s*/) { + $confkeys{rhpdir} = $1; + } + if ($line =~ /^\s*slespdir\s*=\s*(\S*)\s*/) { + $confkeys{slespdir} = $1; + } + if ($line =~ /^\s*aixdir\s*=\s*(\S*)\s*/) { + $confkeys{aixdir} = $1; + } + if ($line =~ /^\s*rhxdir\s*=\s*(\S*)\s*/) { + $confkeys{rhxdir} = $1; + } + if ($line =~ /^\s*slesxdir\s*=\s*(\S*)\s*/) { + $confkeys{slesxdir} = $1; + } + if ($line =~ /^\s*ubuntudir\s*=\s*(\S*)\s*/) { + $confkeys{ubuntudir} = $1; + } + if ($line =~ /^\s*xcattestconf\s*=\s*(\S*)\s*/) { + $confkeys{xcattestconf} = $1; + } + } + send_msg("finish reading global vars"); return %confkeys; } -################################################################Main function###################################################################################### +############################################################### +# Mainfunction +############################################################### ####################################### @@ -583,150 +703,103 @@ if ($needhelp) ####################################### # step 1. Read configuration files ####################################### -$confile = $configfile; -my %confhash = read_conf(); +%confhash = read_conf(); unless (%confhash) { - send_msg(" returns error, exit"); - exit; + send_msg("READ CONF returns error, exit"); + exit 1; } -send_msg("finish reading global variable"); + ####################################### # step 2. git update ####################################### -send_msg("begin to do git update"); - -my $gitup; -$gitup="/tmp/gitup"; - -#Do checkout in git repo -#$res = system("cd $confkeys{srcdir}"); -#if ($res !=0) { -# send_msg("no source code directory,exit"); -# -# exit; -#} - -$res = system("git checkout $branch"); -if ($res != 0){ - send_msg("git checkout failed"); - exit 1; -} - -$res = system("git pull >$gitup"); -if ($res != 0){ - send_msg("git pull failed"); - exit 1; -} - -$res = system("grep 'Already up-to-date' $gitup"); -if (($res == 0)&&( $updates_regression == 1)) { - send_msg("code is already at latest version. exit regresson\n"); - exit 1; -} - - -####################################### -# step 3. Install MNs -####################################### -#$res = mn_install(); -#if ($res) { -# send_msg("INSTALL MNS returns error, exit"); -# exit; -#} - -####################################### -# step 4. Copy code to MNs -####################################### -my $codedir = $confhash{srcdir}; -send_msg("src code directory is $confhash{srcdir}"); - -##will modify to $rhppc64config{var}{MNIP} -my $mn = $management_node; -send_msg("mn is $mn"); - -#install dep for buildlocal -send_msg("begin to install build required packages on mn"); -$res = system("xdsh $mn yum install -y rpm-build perl-Time-HiRes perl-DBI createrepo"); - - -#need to copy /etc/hosts to mn -send_msg("copy /etc/hosts to mn"); -system("scp /etc/hosts $mn:/etc"); - -send_msg("begin to copy code"); -$res = system("scp -r $codedir root\@$mn:/"); -if ($res != 0){ - send_msg("code copy failed"); - exit 1; -} - - -####################################### -# step 5. Build xcat code in MNs -####################################### -#for temp usage -send_msg("========= began build xcat on mn ========"); -#will changed /code/xcat-core to $confkeys{srcdir} -$res = system("xdsh $mn /xcat-core/buildlocal.sh CURDIR=/xcat-core"); -if ($res != 0){ - send_msg("build failed on mn"); - exit 1; - } - -send_msg("====================build done============================"); - -sleep 20; - - -####################################### -# step 6. Read xCAT MN's configuration -####################################### -send_msg("begin read configuration file for mn"); -mkdir $resultdir unless -d $resultdir; -$timestamp = `date +"%Y%m%d%H%M%S"`; -my @osname = &runcmd("uname -a"); -#if ( $osname [0] =~ /^Linux\s*/ && -f "/etc/redhat-release" && $osname [0] =~ /ppc64/){ - # print "ppc64 redhat env\n"; - # $os="rhels6.4"; - # $arch="ppc64"; - #print "os is $os,arch is $arch\n"; - $res = &config_rhppc64(); +$res = git_update(); if ($res) { - send_msg("CONFIGURE MN returns error, exit"); - exit; + send_msg("GIT UPDATE returns error, exit"); + exit 1; } -#} - -send_msg("step 6 : reading mn configuration done====="); - ####################################### -# step 7. Genrate local configuration file for xcattest -# Do test -# Write log +# begin child process, until return log ####################################### -# step 7.1 Install xcat and init mn -send_msg("began to install xCAT and initialize mn"); -$res = &init; -if ($res != 0){ - exit; -} - - -$res = &do_test; -if ($res) { - send_msg("DO TEST returns error, exit"); - exit; -} +my @mns; +pipe CREAD,PWRITE; +foreach my $mn (@mns) { + my $pid = fork(); + if ( !defined($pid) ) { + send_msg("Fork error: $!"); + exit 1; + } elsif ( $pid == 0 ) { # child process + close CREAD; + ####################################### + # step 3. Install MNs, + ####################################### + #$res = mn_install(); + #if ($res) { + # send_msg("INSTALL MNS returns error, exit"); + # exit 1; + #} + ####################################### + # step 4. Copy code to MNs + ####################################### + $res = copy_code(); + if ($res) { + send_msg("COPY CODE returns error, exit"); + exit 1; + } + ####################################### + # step 5. Build xcat code in MNs + ####################################### + $res = build_xcat($mn); + if ($res) { + send_msg("BUILD XCAT returns error, exit"); + exit 1; + } + ####################################### + # step 6. Read xCAT MN's configuration + ####################################### + $res = config_mn($mn); + if ($res) { + send_msg("CONFIGURE MN returns error, exit"); + exit 1; + } + ####################################### + # step 7. Genrate local configuration file for xcattest + # Do test + # Write log + ####################################### + $res = do_test(); + if ($res) { + send_msg("DO TEST returns error, exit"); + exit 1; + } + syswrite PWRITE,"$mn succeed\n"; + exit 0; + } # end of child process +} #end of foreach mn, begin parent process +close PWRITE; +my $time = time(); +while (1) { + while(){ + chomp; + my $result = $_; + if ($result =~ /(\w*) succeed/){ + $results{$1} = 1; + } + } + last if((keys %results) == @mns); + last if(time() - $time > 28800); #wait 8 hours at most +} ####################################### # step 8. process result ####################################### $res = pro_result(); if ($res) { send_msg("PROCESS RESULT returns error, exit"); - exit; + exit 1; } +exit 0; + From 758235d4ddd81120a3332a3eb456e3e603ea65b8 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 15 Apr 2014 09:53:08 -0400 Subject: [PATCH 03/28] restructure the xcatws-test.sh to make it can handle server certificate checking and token checking --- xCAT-server/xCAT-wsapi/xcatws-test.sh | 304 ++++++++++++++++---------- 1 file changed, 183 insertions(+), 121 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.sh b/xCAT-server/xCAT-wsapi/xcatws-test.sh index a7bca7c6c..cbf8ebb4f 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.sh +++ b/xCAT-server/xCAT-wsapi/xcatws-test.sh @@ -1,135 +1,197 @@ -#!/bin/bash -# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html +#! /bin/sh -# Test driver for xcatws.cgi, pass 3 arguments to it: user, password, noderange -# This test driver will create to dummy nodes, wstest1 and wstest2, so make sure those -# names don't conflict with your nodes on this MN. -# You also have to pass in a noderange of 2 real system x nodes that can be used -# to test some of the r cmds, xdsh, xdcp, nodestat. -user=$1 -pw=$2 -nr=$3 -if [ -z "$3" ]; then - echo "Usage: chkrc " - exit -fi +# Get all the parameters +for i in $@ +do + if [ "$paramname" = "USER" ]; then + USER=$i + paramname= + fi + if [ "$paramname" = "PW" ]; then + PW=$i + paramname= + fi + if [ "$paramname" = "HOST" ]; then + HOST=$i + paramname= + fi -format='format=json&pretty=1' -ctype='-H Content-Type:application/json' + if [ $i = '-u' ]; then + paramname=USER + fi + if [ $i = '-p' ]; then + paramname=PW + fi + if [ $i = '-h' ]; then + paramname=HOST + fi + if [ $i = '-c' ]; then + cert=yes + fi + if [ $i = '-t' ]; then + token=yes + fi + +done -function chkrc -{ - rc=$? - { set +x; } 2>/dev/null - if [[ $1 == "not" ]]; then - if [[ $rc -eq 0 ]]; then - echo "Test failed!" - exit - fi - else - if [[ $rc -gt 0 ]]; then - echo "Test failed!" - exit - fi - fi - echo '' - set -x +# display the usage message +function usage { + echo "Usage:" + echo " xcatws-test.sh -u -p [-t]" + echo " xcatws-test.sh -u -p -h [-c] [-t]" + echo " -u The username of xCAT user which is used to access xCAT resource" + echo " -p The password of username" + echo " The fully qualified hostname of xCAT management node. It can be an IP if using -k." + echo " -c Check the server identity. The server certificate authentication must be enabled." + echo " -t Using token authentication method." } -# pcregrep -M 'abc.*(\n|.)*efg' test.txt +if [ "$USER" = "" ] || [ "$PW" = "" ]; then + echo "Error: Miss username or password" + usage + exit 1 +fi -#todo: add a test case for every api call that is documented -set -x -# clean up from last time -curl -# -X DELETE -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw" >/dev/null; echo '' +if [ "$cert" = "yes" ] && [ "$HOST" = "" ]; then + echo "Error: -c must be used with -h that user needs specify the FQDN of xCAT MN" + usage + exit 1 +fi -# create test nodes -curl -# -X POST -k "https://127.0.0.1/xcatws/node/wstest1-wstest2?userName=$user&password=$pw&$format" $ctype --data '{"groups":"wstest","netboot":"xnba"}' \ - | grep -q '2 object definitions have been created'; chkrc - -# list all nodes and make sure they are in the list -curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&$format" \ - | pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc - -# list all node's group and netboot attributes -curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&field=groups&field=netboot" \ - | grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc - -# list all attributes of all nodes -curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&field=ALL" \ - | grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc - -# list the noderange and make sure they are in the list -curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" \ - | pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc - -# list all node's group and netboot attributes -curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=groups&field=netboot" \ - | grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc - -# list all attributes of all nodes -curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=ALL" \ - | grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc - -# change some attributes -curl -# -X PUT -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" $ctype --data '{"room":"222","netboot":"pxe"}' \ - | grep -q '2 object definitions have been created or modified'; chkrc - -# verify they got the new values -curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=room&field=netboot" \ - | grep -qE '"nodename":"wstest1".*"room":"222"'; chkrc - -# delete the nodes -curl -# -X DELETE -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" \ - | grep -q '2 object definitions have been removed'; chkrc - -# list all nodes and make sure they are not in the list -curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&$format" \ - | pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc not - -# list the power state of the noderange -curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/power?userName=$user&password=$pw&$format" \ - | grep -q '"power":"on"'; chkrc - -# list the nodestat state of the noderange -curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/status?userName=$user&password=$pw&$format" \ - | grep -q '":"sshd"'; chkrc - -# list the node inventory of the noderange -curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/inventory?userName=$user&password=$pw&$format" \ - | grep -q '"Board manufacturer":"IBM"'; chkrc - -# list the node vitals of the noderange -curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/vitals?userName=$user&password=$pw&$format" \ - | grep -q '"Cooling Fault":"false"'; chkrc - -# list the node energy settings of the noderange -curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/energy?userName=$user&password=$pw&$format&field=cappingstatus&field=cappingmaxmin" \ - | grep -q '"cappingstatus":"off"'; chkrc - -# run a cmd on the noderange -curl -# -X POST -k "https://127.0.0.1/xcatws/node/$nr/dsh?userName=$user&password=$pw&$format" $ctype --data '{"command":"pwd"}' \ - | grep -q '"/root"'; chkrc - -# copy a file to the noderange -curl -# -X POST -k "https://127.0.0.1/xcatws/node/$nr/dcp?userName=$user&password=$pw&$format" $ctype --data '{"source":"/root/.bashrc","target":"/tmp/"}' \ - | grep -q '"errorcode":"0"'; chkrc - -# test the table calls -curl -# -X GET -k "https://127.0.0.1/xcatws/table/nodelist/wstest?userName=$user&password=$pw&$format" +if [ "$HOST" = "" ]; then + HOST="127.0.0.1" +fi -exit +ctype='-H Content-Type:application/json' + +# Perform the REST API request +function REST { + METHOD=$1 # it should be GET/PUT/POST/DELETE + SRC=$2 # The resource path like /nodes/node1 + DATA=$3 # The operation data for PUT/POST/DELETE + if [ "$DATA" != "" ]; then + datamsg="$ctype -d $DATA" + fi + if [ "$cert" = "yes" ]; then + if [ "$token" = "yes" ]; then + CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1" + else + CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW" + fi + else + if [ "$token" = "yes" ]; then + CMD="curl -X $METHOD -k -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1" + else + CMD="curl -X $METHOD -k $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW" + fi + fi + + echo "-------------------------------------------------------------------------------" + echo "Run: [$RESTMSG]" + echo " $CMD" + echo "Output:" + `$CMD 2>/dev/null >/tmp/xcatws-test.log` + cat "/tmp/xcatws-test.log" + echo "" + + ERROR=`grep "errorcode" "/tmp/xcatws-test.log"` + if [ "$ERROR" != "" ]; then + echo "FAILED to continue. See the error message in 'error' section." + echo "" + exit 2 + fi +} + +function PUT { + SRC=$1 +} + +# echo debug message +echo "***********************************************************" +echo "** Username: $USER" +echo "** Password: $PW" +echo "** Hostname: $HOST" -#curl -X GET -k "https://127.0.0.1/xcatws/groups?userName=$user&password=$pw&$format" +# get the CA of server certificate +if [ "$cert" = "yes" ]; then + rm -f /tmp/ca-cert.pem + cd /tmp + wget http://$HOST/install/postscripts/ca/ca-cert.pem 2>1 1>/dev/null + echo "** Using CA /tmp/ca-cert.pem for server certificate checking" +fi -#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format" -#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format&field=osvers" -#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format" -#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format&field=osvers" +# get a token +if [ "$token" = "yes" ]; then + TOKENID=$(curl -X POST -k "https://$HOST/xcatws/tokens?pretty=1" -H Content-Type:application/json --data "{\"userName\":\"$USER\",\"password\":\"$PW\"}" 2>/dev/null | grep '"id"' | awk -F: {'print $2'} | awk -F \" {'print $2'}) + echo "** Using Token: $TOKENID to authenticate" +fi + +echo "***********************************************************" +echo "" + +# clean the env +rmdef -t node restapinode[1-9] 1>/dev/null 2>1 +rmdef -t group restapi 1>/dev/null 2>1 + +# get all resources +RESTMSG="Get all available resource" +REST GET "/" + +# test global conf +RESTMSG="Get all global configuration resource" +REST GET "/globalconf" + +RESTMSG="Change the global configuration domain to cluster.com" +REST PUT "/globalconf/attrs/domain" '{"domain":"cluster.com"}' + +RESTMSG="Get the global configuration domain" +REST GET "/globalconf/attrs/domain" + +# test node create/change/list/delete +RESTMSG="Create node restapinode1" +REST POST "/nodes/restapinode1" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}' + +RESTMSG="Display the node restapinode1" +REST GET "/nodes/restapinode1" + +RESTMSG="Change the attributes for node restapinode1" +REST PUT "/nodes/restapinode1" '{"mgt":"fsp","netboot":"yaboot"}' + +RESTMSG="Display the node restapinode1" +REST GET "/nodes/restapinode1" + +RESTMSG="Delete node restapinode1" +REST DELETE "/nodes/restapinode1" + +# test multiple nodes manipulation +RESTMSG="Create node restapinode1 and restapinode2" +REST POST "/nodes/restapinode1,restapinode2" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}' + +RESTMSG="Display the node restapinode1 and restapinode2" +REST GET "/nodes/restapinode1,restapinode2" + +RESTMSG="Change the attributes for node restapinode1 and restapinode2" +REST PUT "/nodes/restapinode1,restapinode2" '{"mgt":"hmc","netboot":"grub2"}' + +RESTMSG="Display the node restapinode1 and restapinode2" +REST GET "/nodes/restapinode1,restapinode2" + +RESTMSG="Display all the nodes in the cluster" +REST GET "/nodes" + +# test group +RESTMSG="Display the group restapi" +REST GET "/groups/restapi" + +RESTMSG="Change attributes for group restapi" +REST PUT "/groups/restapi" '{"os":"rh7"}' + +RESTMSG="Display the group restapi" +REST GET "/groups/restapi" + +RESTMSG="Display the nodes in group restapi" +REST GET "/nodes/restapi" -#todo: remove when these test cases are in xcatws-test.pl -#./xcatws-test.pl -u "https://127.0.0.1/xcatws/node/test001?userName=$user&password=$pw" -m GET -#./xcatws-test.pl -u "https://127.0.0.1/xcatws/node/test001?userName=$user&password=$pw" -m PUT "nodepos.room=foo" From 2e24d9a00811d63c0bfc40fdde31fdcbaffbbb0c Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 15 Apr 2014 13:12:45 -0400 Subject: [PATCH 04/28] add the site description for externaldns attribute --- perl-xCAT/xCAT/Schema.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 8f6ed715b..1c70b5f9c 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -941,6 +941,8 @@ site => { " \"\" to mean the DNS server for each node should be the\n". " node that is managing it (either its service node or the management\n". " node).\n\n". + " externaldns: To specify that external dns is used. If any value is set to externaldns,\n". + " makedns command will not start the local dns on xCAT MN.\n\n". " -------------------------\n". "HARDWARE CONTROL ATTRIBUTES\n". " -------------------------\n". From 3ea7bafb9a17c95387825c410b45f557b3f52e35 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 15 Apr 2014 09:11:47 -0400 Subject: [PATCH 05/28] Revert "Use sha256 by default in openssl.cnf" This reverts commit e02a913e869c34a73edc94f5299e008dd8bef336. --- xCAT-server/share/xcat/ca/openssl.cnf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/ca/openssl.cnf.tmpl b/xCAT-server/share/xcat/ca/openssl.cnf.tmpl index f7a0200ec..1bd074cc6 100644 --- a/xCAT-server/share/xcat/ca/openssl.cnf.tmpl +++ b/xCAT-server/share/xcat/ca/openssl.cnf.tmpl @@ -67,7 +67,7 @@ cert_opt = ca_default # Certificate field options default_days = 7300 # how long to certify for default_crl_days= 30 # how long before next CRL -default_md = sha256 # which md to use. +default_md = sha1 # which md to use. preserve = no # keep passed DN ordering # A few difference way of specifying how similar the request should look From 0ee24e839ad996d34be9a0b69cc9c39bd604ec3a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 15 Apr 2014 09:12:00 -0400 Subject: [PATCH 06/28] Revert "Have openssl req use better message digest" This reverts commit 98bc65838549d9bf2fa10ceddd06e37d1090131c. --- xCAT-server/share/xcat/ca/openssl.cnf.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-server/share/xcat/ca/openssl.cnf.tmpl b/xCAT-server/share/xcat/ca/openssl.cnf.tmpl index 1bd074cc6..4aa8fd733 100644 --- a/xCAT-server/share/xcat/ca/openssl.cnf.tmpl +++ b/xCAT-server/share/xcat/ca/openssl.cnf.tmpl @@ -98,7 +98,6 @@ emailAddress = optional #################################################################### [ req ] -default_md = sha256 default_bits = 2048 default_keyfile = private/ca-key.pem distinguished_name = req_distinguished_name From e850c050ef4df0674e117c4f5f2203f7477b17bf Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 15 Apr 2014 10:02:17 -0400 Subject: [PATCH 07/28] defect 4064 --- xCAT-server/share/xcat/scripts/setup-local-client.sh | 2 +- xCAT-server/share/xcat/scripts/setup-server-cert.sh | 2 +- xCAT-server/share/xcat/scripts/setup-xcat-ca.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/scripts/setup-local-client.sh b/xCAT-server/share/xcat/scripts/setup-local-client.sh index 329cf5789..ff929d253 100755 --- a/xCAT-server/share/xcat/scripts/setup-local-client.sh +++ b/xCAT-server/share/xcat/scripts/setup-local-client.sh @@ -60,7 +60,7 @@ cd $XCATDIR/ca # - seems to be a problem with the use of the wildcard in the Makefile # - calling cmds directly instead - should be safe # make sign -openssl ca -startdate 19600101010101Z -config openssl.cnf -in root.csr -out root.cert +openssl ca -startdate 600101010101Z -config openssl.cnf -in root.csr -out root.cert if [ -f root.cert ]; then rm root.csr fi diff --git a/xCAT-server/share/xcat/scripts/setup-server-cert.sh b/xCAT-server/share/xcat/scripts/setup-server-cert.sh index 42cb46767..77993358b 100755 --- a/xCAT-server/share/xcat/scripts/setup-server-cert.sh +++ b/xCAT-server/share/xcat/scripts/setup-server-cert.sh @@ -33,7 +33,7 @@ cd $XCATDIR/ca # - call cmds directly instead - seems safe # make sign -openssl ca -startdate 19600101010101Z -config openssl.cnf -in `hostname`.csr -out `hostname`.cert -extensions server +openssl ca -startdate 600101010101Z -config openssl.cnf -in `hostname`.csr -out `hostname`.cert -extensions server if [ -f `hostname`.cert ]; then rm `hostname`.csr fi diff --git a/xCAT-server/share/xcat/scripts/setup-xcat-ca.sh b/xCAT-server/share/xcat/scripts/setup-xcat-ca.sh index cd13882db..463613d2b 100755 --- a/xCAT-server/share/xcat/scripts/setup-xcat-ca.sh +++ b/xCAT-server/share/xcat/scripts/setup-xcat-ca.sh @@ -34,5 +34,5 @@ make init openssl genrsa -out private/ca-key.pem 2048 chmod 600 private/ca-key.pem openssl req -new -key private/ca-key.pem -config openssl.cnf -out ca-req.csr -subj /CN="$CNA" -outform PEM -openssl ca -selfsign -keyfile private/ca-key.pem -in ca-req.csr -startdate 19700101010101Z -days 7305 -extensions v3_ca -config openssl.cnf -out ca-cert.pem +openssl ca -selfsign -keyfile private/ca-key.pem -in ca-req.csr -startdate 700101010101Z -days 7305 -extensions v3_ca -config openssl.cnf -out ca-cert.pem cd - From 553aa59bb1ae545234c2b66f24d969e7a5d9f996 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 15 Apr 2014 11:39:28 -0400 Subject: [PATCH 08/28] defect 4061 --- perl-xCAT/xCAT/DSHCLI.pm | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index fc86ae999..05103330e 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -4972,7 +4972,8 @@ sub parse_rsync_input_file_on_MN $::process_line = 0; my $destfileisdir; my $clause=0; - + my $addmergescript =0; + my $addappendscript =0; open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n"; while (my $line = ) { @@ -5013,12 +5014,16 @@ sub parse_rsync_input_file_on_MN # this triggers the running of the appendscript $::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; } + # add the append script to the sync - my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; - my $appendscriptline = "$appscript -> $appscript"; - $syncappendscript=1; # syncing the xdcpappend.sh script - &build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); - } + if ($addappendscript == 0) { # only add once + my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + my $appendscriptline = "$appscript -> $appscript"; + $syncappendscript=1; # syncing the xdcpappend.sh script + &build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); + $addappendscript=1; + } + } # end APPEND clause if ($clause =~ /MERGE:/) { # location of the base merge script # for MERGE we have to sync the mergescript and the @@ -5030,12 +5035,16 @@ sub parse_rsync_input_file_on_MN # this triggers the running of the mergescript $::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; } + # add the merge script to the sync - my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; - my $mergescriptline = "$mergescript -> $mergescript"; - $syncmergescript=1; # syncing the xdcpmerge.sh script - &build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); - } + if ($addmergescript == 0) { # only add once + my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + my $mergescriptline = "$mergescript -> $mergescript"; + $syncmergescript=1; # syncing the xdcpmerge.sh script + &build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); + $addmergescript=1; + } + } # end MERGE clause } } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND From b0d5cd593f938be9a87b66d6c7c335661f58abee Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 15 Apr 2014 13:26:00 -0400 Subject: [PATCH 09/28] add more comments about externaldns --- perl-xCAT/xCAT/Schema.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 1c70b5f9c..d97eca393 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -941,8 +941,8 @@ site => { " \"\" to mean the DNS server for each node should be the\n". " node that is managing it (either its service node or the management\n". " node).\n\n". - " externaldns: To specify that external dns is used. If any value is set to externaldns,\n". - " makedns command will not start the local dns on xCAT MN.\n\n". + " externaldns: To specify that an external dns is used. If externaldns is set to any value then ,\n". + " makedns command will not start the local nameserver on xCAT MN. Default is to start local nameserver.\n\n". " -------------------------\n". "HARDWARE CONTROL ATTRIBUTES\n". " -------------------------\n". From 87947d7fca81a60728083afa3326fdf9c41cd5fa Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 16 Apr 2014 04:12:56 -0400 Subject: [PATCH 10/28] Fixed that is external dns is used, don't try to start local dns; refine the ddns.pm that replace the tab with 4spaces. --- xCAT-server/lib/xcat/plugins/ddns.pm | 373 ++++++++++++++------------- 1 file changed, 187 insertions(+), 186 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 2b2f930a1..5d7f90473 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -51,7 +51,7 @@ sub getzonesfornet { die "Not supporting having a mask like $mask on an ipv6 network like $net"; } my $netnum= getipaddr($net,GetNumber=>1); - unless ($netnum) { return (); } + unless ($netnum) { return (); } $netnum->brsft(128-$maskbits); my $prefix=$netnum->as_hex(); my $nibbs=$maskbits/4; @@ -229,7 +229,7 @@ sub process_request { } } if ($::XCATSITEVALS{externaldns}) { - $external=1; + $external=1; } if ($help) @@ -325,73 +325,73 @@ sub process_request { if ($allnodes) { #read all nodelist specified nodes } else { - if (not $request->{node} and $deletemode) { - #when this was permitted, it really ruined peoples' days - xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback); - umask($oldmask); - return; - } - my @contents; - my $domain; - if ($request->{node}) { #leverage makehosts code to flesh out the options - require xCAT_plugin::hosts; - my @content1; - my @content2; - xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1); - xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2); + if (not $request->{node} and $deletemode) { + #when this was permitted, it really ruined peoples' days + xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback); + umask($oldmask); + return; + } + my @contents; + my $domain; + if ($request->{node}) { #leverage makehosts code to flesh out the options + require xCAT_plugin::hosts; + my @content1; + my @content2; + xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1); + xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2); @contents = (@content1, @content2); - } else { - #legacy behavior, read from /etc/hosts - my $hostsfile; - open($hostsfile,"<","/etc/hosts"); - flock($hostsfile,LOCK_SH); - @contents = <$hostsfile>; - flock($hostsfile,LOCK_UN); - close($hostsfile); - } + } else { + #legacy behavior, read from /etc/hosts + my $hostsfile; + open($hostsfile,"<","/etc/hosts"); + flock($hostsfile,LOCK_SH); + @contents = <$hostsfile>; + flock($hostsfile,LOCK_UN); + close($hostsfile); + } my $addr; my $name; my $canonical; my $aliasstr; my @aliases; my $names; - my @hosts; - my %nodehash; - + my @hosts; + my %nodehash; + foreach (@contents) { - chomp; #no newline - s/#.*//; #strip comments; - s/^[ \t\n]*//; #remove leading whitespace - next unless ($_); #skip empty lines - ($addr,$names) = split /[ \t]+/,$_,2; + chomp; #no newline + s/#.*//; #strip comments; + s/^[ \t\n]*//; #remove leading whitespace + next unless ($_); #skip empty lines + ($addr,$names) = split /[ \t]+/,$_,2; + + if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) { + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback); + next; + } + unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) { + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback); + next; + } + + my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr); + push @hosts, $host; + $nodehash{$addr}{names}=$names; + $nodehash{$addr}{host}=$host; + } - if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) { - xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback); - next; - } - unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) { - xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback); - next; - } - - my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr); - push @hosts, $host; - $nodehash{$addr}{names}=$names; - $nodehash{$addr}{host}=$host; - } - - # get the domains for each node - one call for all nodes in hosts file - my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts); - my %nodedomains = %$nd; - - foreach my $n (keys %nodehash) { - $addr=$n; - $names=$nodehash{$n}{names}; - # - need domain for this node - my $host = $nodehash{$n}{host}; - $domain=$nodedomains{$host}; - # remove the first . at domain name since it's not accepted by high dns parser - if ($domain =~ /^\./) { $domain =~ s/^\.//;; } + # get the domains for each node - one call for all nodes in hosts file + my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts); + my %nodedomains = %$nd; + + foreach my $n (keys %nodehash) { + $addr=$n; + $names=$nodehash{$n}{names}; + # - need domain for this node + my $host = $nodehash{$n}{host}; + $domain=$nodedomains{$host}; + # remove the first . at domain name since it's not accepted by high dns parser + if ($domain =~ /^\./) { $domain =~ s/^\.//;; } ($canonical,$aliasstr) = split /[ \t]+/,$names,2; if ($aliasstr) { @@ -407,7 +407,7 @@ sub process_request { unless ($canonical =~ /$domain/) { $canonical.=".".$domain; } - # for only the sake of comparison, ensure consistant dot suffix + # for only the sake of comparison, ensure consistant dot suffix unless ($canonical =~ /\.\z/) { $canonical .= '.' } foreach my $alias (@aliases) { unless ($alias =~ /$domain/) { @@ -419,13 +419,13 @@ sub process_request { if ($alias eq $canonical) { next; } - # remember alias for CNAM records later + # remember alias for CNAM records later $ctx->{aliases}->{$node}->{$alias}=1; } - + # exclude the nodes not belong to any nets defined in networks table # because only the nets defined in networks table will be add - # zones later. + # zones later. my $found = 0; foreach (@networks) { @@ -508,13 +508,13 @@ sub process_request { $ctx->{domain} =~ s/^\.//; # remove . if it's the first char of domain name $ctx->{zonestotouch}->{$ctx->{domain}}=1; - foreach (@networks) { - if ($_->{domain}) { - $_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name - $ctx->{zonestotouch}->{$_->{domain}}=1; - } - } - + foreach (@networks) { + if ($_->{domain}) { + $_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name + $ctx->{zonestotouch}->{$_->{domain}}=1; + } + } + xCAT::SvrUtils::sendmsg("Getting reverse zones, this may take several minutes for a large cluster.", $callback); foreach (@nodes) { @@ -528,10 +528,10 @@ sub process_request { xCAT::SvrUtils::sendmsg("Completed getting reverse zones.", $callback); if (1) { - #TODO: function to detect and return 1 if the master server is - # DNS SOA for all the zones we care about here, we are examining + #TODO: function to detect and return 1 if the master server is + # DNS SOA for all the zones we care about here, we are examining # files to assure that our key is in named.conf, the zones we - # care about are there, and that if active directory is in use, + # care about are there, and that if active directory is in use, # allow the domain controllers to update specific zones @entries = xCAT::TableUtils->get_site_attribute("directoryprovider"); $site_entry = $entries[0]; @@ -541,13 +541,13 @@ sub process_request { if ( defined($site_entry)) { my @dservers = split /[ ,]/,$site_entry; $ctx->{adservers} = \@dservers; - - ############################ - # - should this include all domains? - # - multi-domains not supported with activedirectory - # - TODO in future release - ################### - + + ############################ + # - should this include all domains? + # - multi-domains not supported with activedirectory + # - TODO in future release + ################### + $ctx->{adzones} = { "_msdcs.". $ctx->{domain} => 1, "_sites.". $ctx->{domain} => 1, @@ -556,51 +556,51 @@ sub process_request { }; } } - + @entries = xCAT::TableUtils->get_site_attribute("dnsupdaters"); $site_entry = $entries[0]; if ( defined($site_entry) ) { - my @nservers = split /[ ,]/,$site_entry; - $ctx->{dnsupdaters} = \@nservers; + my @nservers = split /[ ,]/,$site_entry; + $ctx->{dnsupdaters} = \@nservers; } - unless ($external) { - if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh - if (xCAT::Utils->isAIX()) - { - system("/usr/bin/stopsrc -s $service"); - } - else - { - system("service $service stop"); #named may otherwise hold on to stale journal filehandles - } - my $conf = get_conf(); - unlink $conf; - my $DBDir = get_dbdir(); - foreach (<$DBDir/db.*>) { - unlink $_; - } - } - #We manipulate local namedconf - $ctx->{dbdir} = get_dbdir(); - $ctx->{zonesdir} = get_zonesdir(); - chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory - - update_namedconf($ctx, $slave); - - unless ($slave) + unless ($external) { # only generate the named.conf and zone files for xCAT dns when NOT using external dns + if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh + if (xCAT::Utils->isAIX()) { - update_zones($ctx); + system("/usr/bin/stopsrc -s $service"); } + else + { + system("service $service stop"); #named may otherwise hold on to stale journal filehandles + } + my $conf = get_conf(); + unlink $conf; + my $DBDir = get_dbdir(); + foreach (<$DBDir/db.*>) { + unlink $_; + } + } + #We manipulate local namedconf + $ctx->{dbdir} = get_dbdir(); + $ctx->{zonesdir} = get_zonesdir(); + chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory + + update_namedconf($ctx, $slave); + + unless ($slave) + { + update_zones($ctx); + } - if ($ctx->{restartneeded}) { - xCAT::SvrUtils::sendmsg("Restarting $service", $callback); - + if ($ctx->{restartneeded}) { + xCAT::SvrUtils::sendmsg("Restarting $service", $callback); + if (xCAT::Utils->isAIX()) { #try to stop named my $cmd = "/usr/bin/stopsrc -s $service"; my @output=xCAT::Utils->runcmd($cmd, 0); - + $cmd = "/usr/bin/startsrc -s $service"; @output=xCAT::Utils->runcmd($cmd, 0); my $outp = join('', @output); @@ -624,7 +624,7 @@ sub process_request { xCAT::MsgUtils->message("E", $rsp, $callback); return; } - + $cmd = "service $service start"; @output=xCAT::Utils->runcmd($cmd, 0); $outp = join('', @output); @@ -636,56 +636,57 @@ sub process_request { return; } } - - xCAT::SvrUtils::sendmsg("Restarting named complete", $callback); - } - - } + + xCAT::SvrUtils::sendmsg("Restarting named complete", $callback); + } + } } else { unless ($ctx->{privkey}) { xCAT::SvrUtils::sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"], $callback); } } - + if ($slave) { return; } # check if named is active before update dns records. - if (xCAT::Utils->isAIX()) - { - my $cmd = "/usr/bin/lssrc -s $service |grep active"; - my @output=xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + unless ($external) { # only start xCAT local dns when NOT using external dns + if (xCAT::Utils->isAIX()) { - $cmd = "/usr/bin/startsrc -s $service"; - @output=xCAT::Utils->runcmd($cmd, 0); - my $outp = join('', @output); + my $cmd = "/usr/bin/lssrc -s $service |grep active"; + my @output=xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - my $rsp = {}; - $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return; + $cmd = "/usr/bin/startsrc -s $service"; + @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } } } - } - else - { - my $cmd = "service $service status|grep running"; - my @output=xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + else { - $cmd = "service $service start"; - @output=xCAT::Utils->runcmd($cmd, 0); - my $outp = join('', @output); + my $cmd = "service $service status|grep running"; + my @output=xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - my $rsp = {}; - $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return; + $cmd = "service $service start"; + @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } } } } @@ -693,12 +694,12 @@ sub process_request { #now we stick to Net::DNS style updates, with TSIG if possible. TODO: kerberized (i.e. Windows) DNS server support, maybe needing to use nsupdate -g.... if ($external) { - # based on /etc/resolv.conf + # based on /etc/resolv.conf $ctx->{resolver} = Net::DNS::Resolver->new(); } else { - # default to localhost + # default to localhost $ctx->{resolver} = Net::DNS::Resolver->new(nameservers=>['127.0.0.1']); } @@ -716,9 +717,9 @@ sub get_zonesdir { my @entries = xCAT::TableUtils->get_site_attribute("bindzones"); my $site_entry = $entries[0]; - if ( defined($site_entry) ) { - $ZonesDir= $site_entry; - } + if ( defined($site_entry) ) { + $ZonesDir= $site_entry; + } return "$ZonesDir"; } @@ -727,16 +728,16 @@ sub get_conf { my $conf="/etc/named.conf"; # is this ubuntu ? - if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ + if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ $conf="/etc/bind/named.conf"; } my @entries = xCAT::TableUtils->get_site_attribute("bindconf"); my $site_entry = $entries[0]; - if ( defined($site_entry) ) { - $conf= $site_entry; - } + if ( defined($site_entry) ) { + $conf= $site_entry; + } return "$conf"; } @@ -746,9 +747,9 @@ sub get_dbdir { my @entries = xCAT::TableUtils->get_site_attribute("binddir"); my $site_entry = $entries[0]; - if ( defined($site_entry) ) { - $DBDir = $site_entry; - } + if ( defined($site_entry) ) { + $DBDir = $site_entry; + } if ( -d "$DBDir" ) { return "$DBDir" @@ -789,13 +790,13 @@ sub update_zones { my $name = hostname; my $node = $name; - # get the domain for the node - which is the local hostname - my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node); - my @hosts; - push (@hosts, $host); - my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts); - my %nodedomains = %$nd; - my $domain = $nodedomains{$host}; + # get the domain for the node - which is the local hostname + my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node); + my @hosts; + push (@hosts, $host); + my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts); + my %nodedomains = %$nd; + my $domain = $nodedomains{$host}; xCAT::SvrUtils::sendmsg("Updating zones.", $callback); @@ -829,7 +830,7 @@ sub update_zones { my $serial = ($mday * 100) + (($mon + 1) * 10000) + (($year + 1900) * 1000000); foreach $currzone (@neededzones) { - my $zonefilename = $currzone; + my $zonefilename = $currzone; if ($currzone =~ /IN-ADDR\.ARPA/) { $currzone =~ s/\.IN-ADDR\.ARPA.*//; my @octets = split/\./,$currzone; @@ -853,7 +854,7 @@ sub update_zones { } flock($zonehdl,LOCK_UN); close($zonehdl); - if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ + if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ chown(scalar(getpwnam('root')),scalar(getgrnam('bind')),$dbdir."/db.$zonefilename"); } else{ @@ -889,7 +890,7 @@ sub update_namedconf { $gotoptions=1; my $skip=0; do { - #push @newnamed,"\t\t//listen-on-v6 { any; };\n"; + #push @newnamed,"\t\t//listen-on-v6 { any; };\n"; if ($ctx->{forwarders} and $line =~ /forwarders {/) { push @newnamed,"\tforwarders \{\n"; $skip=1; @@ -1005,11 +1006,11 @@ sub update_namedconf { } } unless ($gotoptions) { - push @newnamed,"options {\n"; + push @newnamed,"options {\n"; unless ($slave && xCAT::Utils->isLinux()) { push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n"; } - push @newnamed,"\t\t//listen-on-v6 { any; };\n"; + push @newnamed,"\t\t//listen-on-v6 { any; };\n"; if ($ctx->{forwarders}) { push @newnamed,"\tforwarders {\n"; foreach (@{$ctx->{forwarders}}) { @@ -1128,7 +1129,7 @@ sub update_namedconf { for my $l (@newnamed) { print $newnameconf $l; } flock($newnameconf,LOCK_UN); close($newnameconf); - if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ + if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ chown (scalar(getpwnam('root')),scalar(getgrnam('bind')),$namedlocation); } else{ @@ -1156,9 +1157,9 @@ sub add_or_delete_records { $ctx->{nsmap} = {}; #will store a map to known NS records to avoid needless redundant queries to sort nodes into domains $ctx->{updatesbyzone}={}; #sort all updates into their respective zones for bulk update for fewer DNS transactions - # get node domains - my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}}); - my %nodedomains = %{$nd}; + # get node domains + my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}}); + my %nodedomains = %{$nd}; foreach $node (@{$ctx->{nodes}}) { my $name = $node; @@ -1168,8 +1169,8 @@ sub add_or_delete_records { next; } - my $domain = $nodedomains{$node}; - if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name + my $domain = $nodedomains{$node}; + if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name unless ($name =~ /$domain/) { $name .= ".".$domain } # $name needs to represent fqdn, but must preserve $node as a nodename for cfg lookup @@ -1177,9 +1178,9 @@ sub add_or_delete_records { @ips = ($ctx->{hoststab}->{$node}->[0]->{ip}); } else { @ips = getipaddr($node,GetAllAddresses=>1); - if (not @ips and keys %{$ctx->{nodeips}->{$node}}) { - @ips = keys %{$ctx->{nodeips}->{$node}}; - } + if (not @ips and keys %{$ctx->{nodeips}->{$node}}) { + @ips = keys %{$ctx->{nodeips}->{$node}}; + } if (!defined($ips[0])) { xCAT::SvrUtils::sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts)"], $callback); next; @@ -1214,7 +1215,7 @@ sub add_or_delete_records { } my $zone; foreach $zone (keys %{$ctx->{updatesbyzone}}) { - my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone}); + my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone}); if( !defined $ip) { xCAT::SvrUtils::sendmsg([1,"Please make sure $ctx->{nsmap}->{$zone} exist either in /etc/hosts or DNS."], $callback); return 1; @@ -1296,9 +1297,9 @@ sub find_nameserver_for_dns { } if (defined $ctx->{aliases}->{$node}) { - foreach (keys %{$ctx->{aliases}->{$node}}) { - push @rrcontent, "$_ IN CNAME $name"; - } + foreach (keys %{$ctx->{aliases}->{$node}}) { + push @rrcontent, "$_ IN CNAME $name"; + } } if ($ctx->{deletemode}) { push @rrcontent,"$name TXT"; @@ -1311,7 +1312,7 @@ sub find_nameserver_for_dns { unless (defined $ctx->{nsmap}->{$zone}) { #ok, we already thought about this zone and made a decision if ($zone =~ /^\.*192.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*172.IN-ADDR.ARPA\.*/ or $zone =~ /127.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*IN-ADDR.ARPA\.*/ or $zone =~ /^\.*ARPA\.*/) { $ctx->{nsmap}->{$zone} = 0; #ignore zones that are likely to appear, but probably not ours - } elsif ($::XCATSITEVALS{ddnsserver}) { + } elsif ($::XCATSITEVALS{ddnsserver}) { $ctx->{nsmap}->{$zone} = $::XCATSITEVALS{ddnsserver}; } else { my $reply = $ctx->{resolver}->query($zone,'NS'); @@ -1392,9 +1393,9 @@ sub get_dns_slave foreach my $sn (@ents) { if ($sn->{'nameserver'} == 2) - { + { push @sns, $sn->{'node'}; - } + } } @slaves = xCAT::NodeRange::noderange(join(',',@sns)); From c1bdc749b864fd5ba83aaffd9bec73e40a569f94 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Tue, 15 Apr 2014 22:07:55 -0700 Subject: [PATCH 11/28] The HMC version 8 drop the prompt space when log on to it --- perl-xCAT/xCAT/PPCcli.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/PPCcli.pm b/perl-xCAT/xCAT/PPCcli.pm index b76a34c4d..f995daf92 100644 --- a/perl-xCAT/xCAT/PPCcli.pm +++ b/perl-xCAT/xCAT/PPCcli.pm @@ -156,7 +156,7 @@ sub connect { # Shell prompt regexp based on HW Type ################################################## my %prompt = ( - hmc => "~> \$", + hmc => "~>\s*\$", ivm => "\\\$ \$" ); ################################################## From 4ed50aeb3ca583427e8d4a691f351463de856c3b Mon Sep 17 00:00:00 2001 From: yinle Date: Wed, 16 Apr 2014 04:48:18 -0700 Subject: [PATCH 12/28] Add debug mode. --- xCAT-server/share/xcat/tools/xCATreg | 181 +++++++++++++++++++++------ 1 file changed, 140 insertions(+), 41 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index a9f19badd..96cf7d3a4 100644 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -68,7 +68,7 @@ my $fullcnsninst=0; my $statelitecnsninst=0; my %confkeys; my %results; - +my %mns; ####################################### # usage for arguments ####################################### @@ -93,7 +93,7 @@ sub usage # config for rhppc64env ####################################### sub config_rhppc64 { - send_msg("******************************"); + send_msg("******************************"); send_msg("Reading Configure"); send_msg("******************************"); #if(!(-e $configfile)){ @@ -279,7 +279,7 @@ sub git_update { send_msg("code is already at latest version. exit regresson\n"); exit 1; } - return 0; + return 0; } ####################################### @@ -308,7 +308,7 @@ sub copy_code { send_msg("code copy failed"); exit 1; } - return 0; + return 0; } @@ -328,8 +328,8 @@ sub build_xcat { } send_msg("====================build done============================"); - sleep 20; - return 0; + sleep 20; + return 0; } ####################################### @@ -354,7 +354,7 @@ sub config_mn { #} send_msg("step 6 : reading mn configuration done====="); - return 0; + return 0; } ####################################### # install xcat and init rhppc64 env @@ -621,7 +621,10 @@ sub trim { ####################################### sub send_msg { my $msg = shift; - print "xcatreg message: $msg.\n"; + my $data = `date`; + open (LOGFILE, ">> xcatreg.lob"); + print LOGFILE "$data : $msg.\n"; + close LOGFILE; } ####################################### # read_conf @@ -666,6 +669,31 @@ sub read_conf{ if ($line =~ /^\s*xcattestconf\s*=\s*(\S*)\s*/) { $confkeys{xcattestconf} = $1; } + if ($line =~ /^\s*rhpmn\s*=\s*(\S*)\s*/) { + $confkeys{rhpmn} = $1; + $mns{rhpmn} = $confkeys{rhpmn}; + } + if ($line =~ /^\s*slespmn\s*=\s*(\S*)\s*/) { + $confkeys{slespmn} = $1; + $mns{slespmn} = $confkeys{slespmn}; + } + if ($line =~ /^\s*aixmn\s*=\s*(\S*)\s*/) { + $confkeys{aixmn} = $1; + $mns{aixmn} = $confkeys{aixmn}; + + } + if ($line =~ /^\s*rhxmn\s*=\s*(\S*)\s*/) { + $confkeys{rhxmn} = $1; + $mns{rhxmn} = $confkeys{rhxmn}; + } + if ($line =~ /^\s*slesxmn\s*=\s*(\S*)\s*/) { + $confkeys{slesxmn} = $1; + $mns{slesxmn} = $confkeys{slesxmn}; + } + if ($line =~ /^\s*ubuntumn\s*=\s*(\S*)\s*/) { + $confkeys{ubuntumn} = $1; + $mns{ubuntumn} = $confkeys{ubuntumn}; + } } send_msg("finish reading global vars"); return %confkeys; @@ -680,6 +708,7 @@ sub read_conf{ ####################################### # step 0. Parse input arguments ####################################### +send_msg("\n\n\n== Running step 0..............."); if ( !GetOptions("h|?" => \$needhelp, "f=s" => \$configfile, @@ -700,9 +729,19 @@ if ($needhelp) exit 0; } +# begin to find which mn should be used +if ($management_node) { + foreach my $k (keys %confkeys) { + if ($confkeys{$k} eq $management_node) { + $mns{$k} = $management_node; + send_msg("specify mn $management_node"); + } + } +} ####################################### # step 1. Read configuration files ####################################### +send_msg("\n\n\n== Running read_conf..............."); %confhash = read_conf(); unless (%confhash) { send_msg("READ CONF returns error, exit"); @@ -713,6 +752,7 @@ unless (%confhash) { ####################################### # step 2. git update ####################################### +send_msg("\n\n\n== Running git_update..............."); $res = git_update(); if ($res) { send_msg("GIT UPDATE returns error, exit"); @@ -720,19 +760,88 @@ if ($res) { } ####################################### # begin child process, until return log -####################################### -my @mns; -pipe CREAD,PWRITE; -foreach my $mn (@mns) { - my $pid = fork(); - if ( !defined($pid) ) { - send_msg("Fork error: $!"); - exit 1; - } elsif ( $pid == 0 ) { # child process - close CREAD; +####################################### +unless ($ENV{'REGDEBUG'}) { #used for debug. + pipe CREAD,PWRITE; + foreach my $m (keys %mns) { + my $mn = $mns{$m}; + my $pid = fork(); + if ( !defined($pid) ) { + send_msg("Fork error: $!"); + exit 1; + } elsif ( $pid == 0 ) { # child process + close CREAD; + ####################################### + # step 3. Install MNs, + ####################################### + #send_msg("\n\n\n== Running mn_install..............."); + #$res = mn_install(); + #if ($res) { + # send_msg("INSTALL MNS returns error, exit"); + # exit 1; + #} + ####################################### + # step 4. Copy code to MNs + ####################################### + send_msg("\n\n\n== Running copy_code..............."); + $res = copy_code(); + if ($res) { + send_msg("COPY CODE returns error, exit"); + exit 1; + } + ####################################### + # step 5. Build xcat code in MNs + ####################################### + send_msg("\n\n\n== Running build_xcat..............."); + $res = build_xcat($mn); + if ($res) { + send_msg("BUILD XCAT returns error, exit"); + exit 1; + } + ####################################### + # step 6. Read xCAT MN's configuration + ####################################### + send_msg("\n\n\n== Running config_mn..............."); + $res = config_mn($mn); + if ($res) { + send_msg("CONFIGURE MN returns error, exit"); + exit 1; + } + ####################################### + # step 7. Genrate local configuration file for xcattest + # Do test + # Write log + ####################################### + send_msg("\n\n\n== Running do_test..............."); + $res = do_test(); + if ($res) { + send_msg("DO TEST returns error, exit"); + exit 1; + } + syswrite PWRITE,"$mn succeed\n"; + exit 0; + } # end of child process + } # end of foreach + close PWRITE; + my $time = time(); + while (1) { + while(){ + chomp; + my $result = $_; + if ($result =~ /(\w*) succeed/){ + $results{$1} = 1; + } + } + last if((keys %results) == keys %mns); + last if(time() - $time > 28800); #wait 8 hours at most + } +} else { + foreach my $m (keys %mns) { + my $mn = $mns{$m}; ####################################### # step 3. Install MNs, - ####################################### + ####################################### + #send_msg("\n\n\n== Running mn_install..............."); #$res = mn_install(); #if ($res) { # send_msg("INSTALL MNS returns error, exit"); @@ -741,65 +850,55 @@ foreach my $mn (@mns) { ####################################### # step 4. Copy code to MNs ####################################### + send_msg("\n\n\n== Running copy_code..............."); $res = copy_code(); if ($res) { send_msg("COPY CODE returns error, exit"); exit 1; - } + } ####################################### # step 5. Build xcat code in MNs ####################################### + send_msg("\n\n\n== Running build_xcat..............."); $res = build_xcat($mn); if ($res) { send_msg("BUILD XCAT returns error, exit"); exit 1; - } + } ####################################### # step 6. Read xCAT MN's configuration ####################################### + send_msg("\n\n\n== Running config_mn..............."); $res = config_mn($mn); if ($res) { send_msg("CONFIGURE MN returns error, exit"); exit 1; - } + } ####################################### # step 7. Genrate local configuration file for xcattest # Do test # Write log ####################################### + send_msg("\n\n\n== Running do_test..............."); $res = do_test(); if ($res) { send_msg("DO TEST returns error, exit"); exit 1; } - syswrite PWRITE,"$mn succeed\n"; - exit 0; - } # end of child process -} #end of foreach mn, begin parent process - -close PWRITE; -my $time = time(); -while (1) { - while(){ - chomp; - my $result = $_; - if ($result =~ /(\w*) succeed/){ - $results{$1} = 1; - } - } - last if((keys %results) == @mns); - last if(time() - $time > 28800); #wait 8 hours at most -} + }# end of foreach mn, begin parent process +}# end of debug + ####################################### # step 8. process result ####################################### +send_msg("\n\n\n== Running pro_result..............."); $res = pro_result(); if ($res) { send_msg("PROCESS RESULT returns error, exit"); exit 1; } exit 0; - + From ae95af8dbb724bca92206ca47b1df05f6b5bf6a4 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 16 Apr 2014 08:43:37 -0400 Subject: [PATCH 13/28] add the site attribute description for dnsupdaters and persistkvmguests --- perl-xCAT/xCAT/Schema.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index d97eca393..1cd4017db 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -941,8 +941,12 @@ site => { " \"\" to mean the DNS server for each node should be the\n". " node that is managing it (either its service node or the management\n". " node).\n\n". - " externaldns: To specify that an external dns is used. If externaldns is set to any value then ,\n". - " makedns command will not start the local nameserver on xCAT MN. Default is to start local nameserver.\n\n". + " externaldns: To specify that external dns is used. If externaldns is set to any value\n". + " then, makedns command will not start the local nameserver on xCAT MN. \n". + " Default is to start the local nameserver.\n\n". + " dnsupdaters: The value are \',\' separated string which will be added to the zone config\n". + " section. This is an interface for user to add configuration entries to\n". + " the zone sections in named.conf.\n\n". " -------------------------\n". "HARDWARE CONTROL ATTRIBUTES\n". " -------------------------\n". @@ -1098,6 +1102,10 @@ site => { " will not interfere.\n\n". " vmwarereconfigonpower: When set to no, the VMWare plugin will make no effort to\n". " push vm.cpus/vm.memory updates from xCAT to VMWare.\n\n". + " persistkvmguests: Keep the kvm definition on the kvm hypervisor when you power off\n". + " the kvm guest node. This is useful for you to manually change the \n". + " kvm xml definition file in virsh for debugging. Set anything means\n". + " enable.\n\n". " --------------------\n". "XCAT DAEMON ATTRIBUTES\n". " --------------------\n". From e93507ecbde0c24a64aff40d70f2e42cebdab465 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 16 Apr 2014 10:13:31 -0400 Subject: [PATCH 14/28] defect 4071 --- xCAT-client/bin/pping | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/pping b/xCAT-client/bin/pping index 6df6936c4..e08755fe5 100755 --- a/xCAT-client/bin/pping +++ b/xCAT-client/bin/pping @@ -65,7 +65,7 @@ else { # the normal case of the user running the cmd - expand the noderange us SSL_cert_file=> xCAT::Utils->getHomeDir()."/.xcat/client-cred.pem", SSL_ca_file => xCAT::Utils->getHomeDir()."/.xcat/ca.pem", SSL_use_cert => 1, - #SSL_verify_mode => 1, + SSL_verify_mode => 1, ); die "Connection failure: $!\n" unless ($client); my %cmdref = (command => 'noderange', noderange => $noderange); From 2b4a12d785947730b485cbe4190fea00270a2b33 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 16 Apr 2014 10:17:05 -0400 Subject: [PATCH 15/28] defect 4072 --- perl-xCAT/xCAT/DSHCLI.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 05103330e..cf67de367 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -3994,7 +3994,7 @@ sub parse_and_run_dsh $options{'user'} = $ENV{'DSH_TO_USERID'}; } - if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'})))) + if ((!(@$nodes)) && (!(defined($options{'rootimg'})))) { # no nodes and not -i option, error my $rsp = (); $rsp->{error}->[0] = "Unless using -i option, noderange is required."; @@ -4033,7 +4033,7 @@ sub parse_and_run_dsh { # from sinv, discard this name undef @$nodes; } - if (defined(@$nodes)) + if (@$nodes) { my $rsp = {}; $rsp->{error}->[0] = @@ -4405,7 +4405,7 @@ sub parse_and_run_dcp return; } } - if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'})))) + if ((!(@$nodes)) && (!(defined($options{'rootimg'})))) { # no nodes and not -i option, error my $rsp = {}; $rsp->{error}->[0] = "Unless using -i option, noderange is required."; @@ -4502,7 +4502,7 @@ sub parse_and_run_dcp # # build list of nodes my @nodelist; - if (defined(@$nodes)) + if (@$nodes) { # there are nodes @nodelist = @$nodes; $options{'nodes'} = join(',', @nodelist); From 02749374788acd3146e0ee985a0b2301f5689f6c Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 16 Apr 2014 12:34:09 -0400 Subject: [PATCH 16/28] defect 4072 --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 9 ++++--- xCAT-server/lib/xcat/plugins/FIP.pm | 3 +-- xCAT-server/lib/xcat/plugins/aixinstall.pm | 26 ++++++++++---------- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- xCAT-server/lib/xcat/plugins/kit.pm | 7 +++--- xCAT-server/lib/xcat/plugins/kmodules.pm | 2 +- xCAT-server/lib/xcat/plugins/rollupdate.pm | 2 +- xCAT-server/lib/xcat/plugins/xcat2nim.pm | 4 +-- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 16f11296e..a5a75d23b 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -379,8 +379,7 @@ sub parse_attr_for_osimage{ sub processArgs { my $gotattrs = 0; - - if (defined(@{$::args})) { + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } else { if ($::command eq "lsdef") { @@ -391,8 +390,9 @@ sub processArgs return 2; } } - if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S') - { + if ( defined ($::args) && @{$::args} ) { + if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S') + { if ($::command eq "lsdef") { push @ARGV, "-t"; push @ARGV, "node"; @@ -400,6 +400,7 @@ sub processArgs } else { return 2; } + } } if ($::command eq "lsdef") { diff --git a/xCAT-server/lib/xcat/plugins/FIP.pm b/xCAT-server/lib/xcat/plugins/FIP.pm index 144de0c9c..343b64a80 100644 --- a/xCAT-server/lib/xcat/plugins/FIP.pm +++ b/xCAT-server/lib/xcat/plugins/FIP.pm @@ -232,8 +232,7 @@ sub parse_args my $args = $request->{arg}; my $gotattrs = 0; my %opt =(); - - if (defined(@{$args})) { + if ( defined ($args) && @{$args}) { @ARGV = @{$args}; } else { return 2; diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index a2da8b590..bc678607b 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -624,7 +624,7 @@ sub nimnodeset my $Sname = xCAT::InstUtils->myxCATname(); - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -1800,7 +1800,7 @@ sub chkosimage my $image_name; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -2267,7 +2267,7 @@ sub mknimimage my $dump_name; my $install_dir = xCAT::TableUtils->getInstallDir(); - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -5705,7 +5705,7 @@ sub prermnimimage my @servicenodes = (); # pass back list of service nodes my %imagedef; # pass back image def hash - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -6215,7 +6215,7 @@ sub rmnimimage %allsn = %{$nodehash}; } - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -7822,7 +7822,7 @@ sub prenimnodecust @nodelist = @$nodes; } - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -8060,7 +8060,7 @@ sub nimnodecust @nodelist = @$nodes; } - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -8217,7 +8217,7 @@ sub prenimnodeset my $subreq = shift; my $error = 0; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -9944,7 +9944,7 @@ sub define_SN_resource } my %attrs; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -10983,7 +10983,7 @@ sub mkdsklsnode # - just set global for now $::callback = $callback; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -12993,7 +12993,7 @@ sub make_SN_resource } my %attrs; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -13653,7 +13653,7 @@ sub prermdsklsnode { my $callback = shift; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } @@ -13763,7 +13763,7 @@ sub rmdsklsnode # - just set global for now $::callback = $callback; - if (defined(@{$::args})) + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 67631c59b..bac6e2880 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1332,7 +1332,7 @@ sub fpc_firmxfer_watch { return; } my $percent = 0; - if ($rsp->{data} and (length(@{$rsp->{data}}) > 0)) { + if ($rsp->{data} and (scalar(@{$rsp->{data}}) > 0)) { $percent = $rsp->{data}->[0]; } #$callback->({sinfo=>"$percent%"}); diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index ab46f7d58..0d6912c54 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -3563,8 +3563,7 @@ sub create_error_response { #----------------------------------------------------------------------------- sub lskit_processargs { - - if ( defined( @{$::args} ) ) { + if ( defined ($::args) && @{$::args} ){ @ARGV = @{$::args}; } @@ -3665,7 +3664,7 @@ sub lskit_processargs { #----------------------------------------------------------------------------- sub lskitcomp_processargs { - if ( defined( @{$::args} ) ) { + if ( defined ($::args) && @{$::args} ){ @ARGV = @{$::args}; } @@ -3758,7 +3757,7 @@ sub lskitcomp_processargs { #----------------------------------------------------------------------------- sub lskitdeployparam_processargs { - if ( defined( @{$::args} ) ) { + if ( defined ($::args) && @{$::args} ){ @ARGV = @{$::args}; } diff --git a/xCAT-server/lib/xcat/plugins/kmodules.pm b/xCAT-server/lib/xcat/plugins/kmodules.pm index 15a769427..3b350ae2f 100644 --- a/xCAT-server/lib/xcat/plugins/kmodules.pm +++ b/xCAT-server/lib/xcat/plugins/kmodules.pm @@ -192,7 +192,7 @@ sub lskmodules_usage { #----------------------------------------------------------------------------- sub processArgs { - if ( defined( @{$::args} ) ) { + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } diff --git a/xCAT-server/lib/xcat/plugins/rollupdate.pm b/xCAT-server/lib/xcat/plugins/rollupdate.pm index c038d371b..52f4d49ce 100644 --- a/xCAT-server/lib/xcat/plugins/rollupdate.pm +++ b/xCAT-server/lib/xcat/plugins/rollupdate.pm @@ -250,7 +250,7 @@ sub runrollupdate_usage { sub processArgs { my $gotattrs = 0; - if ( defined( @{$::args} ) ) { + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } else { diff --git a/xCAT-server/lib/xcat/plugins/xcat2nim.pm b/xCAT-server/lib/xcat/plugins/xcat2nim.pm index f1ea2b4cc..38c72cbc7 100644 --- a/xCAT-server/lib/xcat/plugins/xcat2nim.pm +++ b/xCAT-server/lib/xcat/plugins/xcat2nim.pm @@ -199,7 +199,7 @@ sub prexcat2nim my @nodelist=(); # pass back list of nodes - if applicable my @servicenodes=(); # pass back list of service nodes - if applicable - if (defined(@{$::args})) { + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } else { &xcat2nim_usage($callback); @@ -359,7 +359,7 @@ sub processArgs my $gotattrs = 0; - if (defined(@{$::args})) { + if ( defined ($::args) && @{$::args} ) { @ARGV = @{$::args}; } else { return 3; From f90cdb8a1bdd93fd29bd2d6b032535399da877ae Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 16 Apr 2014 15:10:16 -0400 Subject: [PATCH 17/28] defect 4072 --- perl-xCAT/xCAT/DSHCLI.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index cf67de367..fa3467597 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -3993,8 +3993,7 @@ sub parse_and_run_dsh { $options{'user'} = $ENV{'DSH_TO_USERID'}; } - - if ((!(@$nodes)) && (!(defined($options{'rootimg'})))) + if ((!(defined($nodes))) && (!(defined($options{'rootimg'})))) { # no nodes and not -i option, error my $rsp = (); $rsp->{error}->[0] = "Unless using -i option, noderange is required."; @@ -4405,7 +4404,7 @@ sub parse_and_run_dcp return; } } - if ((!(@$nodes)) && (!(defined($options{'rootimg'})))) + if ((!(defined($nodes))) && (!(defined($options{'rootimg'})))) { # no nodes and not -i option, error my $rsp = {}; $rsp->{error}->[0] = "Unless using -i option, noderange is required."; From a221d8698dca2d531fdfe89f38562bcee40c1f2d Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Wed, 16 Apr 2014 19:54:00 -0700 Subject: [PATCH 18/28] for bug 4070 --- perl-xCAT/xCAT/PPCcli.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/PPCcli.pm b/perl-xCAT/xCAT/PPCcli.pm index f995daf92..f625560bc 100644 --- a/perl-xCAT/xCAT/PPCcli.pm +++ b/perl-xCAT/xCAT/PPCcli.pm @@ -156,7 +156,7 @@ sub connect { # Shell prompt regexp based on HW Type ################################################## my %prompt = ( - hmc => "~>\s*\$", + hmc => "~>\\s*\$", ivm => "\\\$ \$" ); ################################################## From e0bd4322016039a5af8d1e100d8fa7ebeb72f7f8 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 16 Apr 2014 23:27:41 -0400 Subject: [PATCH 19/28] fix for bug 4084: AIX should not require grub2-xcat --- xCAT-server/xCAT-server.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xCAT-server/xCAT-server.spec b/xCAT-server/xCAT-server.spec index 70e80fa12..de05d73ac 100755 --- a/xCAT-server/xCAT-server.spec +++ b/xCAT-server/xCAT-server.spec @@ -27,11 +27,10 @@ AutoReqProv: no BuildArch: noarch Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser Obsoletes: atftp-xcat -%endif - %if %notpcm Requires: grub2-xcat %endif +%endif %if %fsm # nothing needed here From ca0101fec18f31e143ce34b2c673b89ceff46e3e Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Wed, 16 Apr 2014 20:34:58 -0700 Subject: [PATCH 20/28] issue for pkvm host not use eth0 --- xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl b/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl index b2c2e099f..3b09adb42 100644 --- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl +++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm2.ppc64.tmpl @@ -27,7 +27,7 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# #partition / --ondisk=/dev/mapper/ibmpkvm_vg_root-ibmpkvm_lv_root partition / --ondisk=/dev/sda -network --device eth0 --bootproto dhcp +network --bootproto dhcp %post touch "/startpost" From 8e0ac00c379e439732f7ace7d2edf995d7036ba0 Mon Sep 17 00:00:00 2001 From: litingt Date: Wed, 16 Apr 2014 21:43:12 -0700 Subject: [PATCH 21/28] packimage osimage --- .../autotest/testcase/installation/linux_diskless_installation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/installation/linux_diskless_installation b/xCAT-test/autotest/testcase/installation/linux_diskless_installation index 757b341e6..8665f6588 100644 --- a/xCAT-test/autotest/testcase/installation/linux_diskless_installation +++ b/xCAT-test/autotest/testcase/installation/linux_diskless_installation @@ -25,7 +25,7 @@ cmd:copycds $$ISO check:rc==0 cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 From 747d5cef6e43e00068969745b28b3c5c4008b318 Mon Sep 17 00:00:00 2001 From: litingt Date: Wed, 16 Apr 2014 23:51:21 -0700 Subject: [PATCH 22/28] minor changes --- xCAT-server/share/xcat/tools/xCATreg | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 96cf7d3a4..9bfc217db 100644 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -378,22 +378,16 @@ sub init system("xdsh $MN mkdir -p /iso/mountpoint"); print "--prepareing redhat iso file.......\n"; print "--mount NF ......."; - system ("scp -r /iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso $MN:/iso"); + system ("scp -r /iso/*.iso $MN:/iso"); system("xdsh $MN mount -o loop /iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso /iso/mountpoint"); - &runcmd("echo 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4>/etc/hosts.rhppc64"); - &runcmd( " echo $HMCIP $HMC.$DOMAIN $HMC>>/etc/hosts.rhppc64"); - &runcmd( " echo $MNIP $MN.$DOMAIN $MN>>/etc/hosts.rhppc64"); - &runcmd( " echo $CNIP $CN.$DOMAIN $CN>>/etc/hosts.rhppc64"); - &runcmd( " echo $SNCNIP $SNCN.$DOMAIN $SNCN>>/etc/hosts.rhppc64"); - system ("scp -r /etc/hosts.rhppc64 $MN:/etc/hosts"); - &runcmd(" cp /etc/resolv.conf /etc/resolv.rhppc64"); - &runcmd(" echo nameserver $MNIP >>/etc/resolv.rhppc64"); - system ("scp -r /etc/resolv.rhppc64 $MN:/etc/resolv.conf"); + system ("scp -r /etc/hosts $MN:/etc/hosts"); + system ("scp -r /etc/resolv.conf $MN:/etc/resolv.conf"); print "[OK]\n"; print "--get the latest XCAT tarball.......\n"; system("xdsh $MN rm -rf /etc/yum.repos.d/*"); $res = system("scp -r $nodedir/xcat-dep $MN:/"); - system("scp -r /etc/yum.repos.d/rhel6.4.repo $MN:/etc/yum.repos.d/rhel6.4.repo"); ######## redhat 6.4 + &repo(); + system("scp -r rhel6.4.repo $MN:/etc/yum.repos.d/rhel6.4.repo"); #system("scp -r default.conf $MN:$rhppc64configfile"); #system("xdsh $MN perl $nodedir/xcatbuild/xcat-core/mklocalrepo.sh"); system("xdsh $MN perl /xcat-dep/rh6/ppc64/mklocalrepo.sh"); @@ -407,6 +401,7 @@ sub init system("xdsh $MN yum -y install perl-xCAT xCAT-client xCAT-server xCAT"); print "--install XCATTEST .......\n"; system("xdsh $MN yum -y install xCAT-test"); + system("scp -r default.conf $MN:$rhppc64configfile"); print "--install createrepo .......\n"; #system("xdsh $MN yum -y install createrepo"); @@ -462,7 +457,7 @@ sub do_test1 send_msg("start diskless test"); send_msg("******************************"); #if($dsklsinst){ - system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t /opt/xcat/share/xcat/tools/autotest/testcase/installation/linux_diskless_installation"); + system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_diskless_installation_flat_ppc64"); system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); # exit 1; #} @@ -812,6 +807,7 @@ unless ($ENV{'REGDEBUG'}) { #used for debug. # Do test # Write log ####################################### + exit 1; send_msg("\n\n\n== Running do_test..............."); $res = do_test(); if ($res) { From d5877d2db5a97675af31b30588aa534dafc7cde7 Mon Sep 17 00:00:00 2001 From: litingt Date: Thu, 17 Apr 2014 00:15:21 -0700 Subject: [PATCH 23/28] modify log file location --- xCAT-server/share/xcat/tools/xCATreg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 xCAT-server/share/xcat/tools/xCATreg diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg old mode 100644 new mode 100755 index 9bfc217db..70953d9b2 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -617,7 +617,7 @@ sub trim { sub send_msg { my $msg = shift; my $data = `date`; - open (LOGFILE, ">> xcatreg.lob"); + open (LOGFILE, ">> /home/xcatreg.lob"); print LOGFILE "$data : $msg.\n"; close LOGFILE; } From 74ab5d1110758189c52732d2c458926e1763a894 Mon Sep 17 00:00:00 2001 From: Lei Ai Date: Thu, 17 Apr 2014 15:56:59 +0800 Subject: [PATCH 24/28] Merge fix for 2.8 branch about node status update for profiled nodes into mainline --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 98db27939..3e47c5bb0 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -482,6 +482,8 @@ Usage: $warnstr = "Warning: failed to import some nodes."; setrsp_progress($warnstr); } + # setup node provisioning status. + xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2); setrsp_progress("Configuring nodes..."); my $retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2); @@ -726,9 +728,6 @@ Usage: # Update nodes' attributes foreach (@$nodes) { $updatenodeshash{$_}{'groups'} .= $profile_groups; - if ($profile_status){ - $updatenodeshash{$_}{'status'} = $profile_status; - } } #update DataBase. @@ -737,6 +736,11 @@ Usage: $nodetab->setNodesAttribs(\%updatenodeshash); $nodetab->close(); + #update node's status: + if($profile_status eq "defined"){ + xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>$nodes, arg=>['defined']}, $request_command, -1, 2); + } + my $retref; my $retstrref; # Call update plugins first. @@ -1154,17 +1158,7 @@ Usage: # Update node's status. setrsp_progress("Updating node status..."); - my $nodelisttab = xCAT::Table->new('nodelist',-create=>1); - my ( - $sec, $min, $hour, $mday, $mon, - $year, $wday, $yday, $isdst - ) = localtime(time); - my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d", - $mon + 1, $mday, $year + 1900, - $hour, $min, $sec); - - $nodelisttab->setNodeAttribs($hostname, {status=>'defined', statustime=>$currtime}); - $nodelisttab->close(); + xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>[$hostname], arg=>['defined']}, $request_command, -1, 2); setrsp_progress("Updated MAC address."); } @@ -1440,7 +1434,9 @@ Usage: my $mactab = xCAT::Table->new("mac"); my $macsref = $mactab->getNodesAttribs(\@nodes, ['mac']); my $nodelisttab = xCAT::Table->new("nodelist"); - my $statusref = $nodelisttab->getNodesAttribs(\@nodes, ['status']); + # Get node current provisioning status. + my $provisionapp = "provision"; + my $provision_status = xCAT::TableUtils->getAppStatus(\@nodes,$provisionapp); my $rspentry; my $i = 0; @@ -1461,8 +1457,8 @@ Usage: } } - if ($statusref->{$_}->[0]){ - $rspentry->{node}->[$i]->{"status"} = $statusref->{$_}->[0]->{status}; + if ($provision_status->{$_}){ + $rspentry->{node}->[$i]->{"status"} = $provision_status->{$_}; } else{ $rspentry->{node}->[$i]->{"status"} = "defined"; } @@ -1626,6 +1622,8 @@ sub findme{ } my @nodelist = keys %hostinfo_dict; + # setup node provisioning status. + xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2); # call makehosts to get the IP by resolving the name my $retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>\@nodelist, sequential=>[1]}, $request_command, 0, 2); From e5717781182b14e0a15114f0d3fd94c5b1d7fbc3 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 17 Apr 2014 01:44:40 -0700 Subject: [PATCH 25/28] fix bug 3893:rpower man page should note the need for the required ASU Power.S3Enable setting --- xCAT-client/pods/man1/rpower.1.pod | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xCAT-client/pods/man1/rpower.1.pod b/xCAT-client/pods/man1/rpower.1.pod index 0ca1458cc..3dc70e7e1 100644 --- a/xCAT-client/pods/man1/rpower.1.pod +++ b/xCAT-client/pods/man1/rpower.1.pod @@ -123,6 +123,28 @@ Wake up the target nodes which is in B state. Don't try to run B against the 'on' state node, it would cause the node gets to 'off' state. +For some of xCAT hardware such as NeXtScale, it may need to enable S3 before using B. The following steps can be used to enable S3. Please reference L for "pasu" usage. + + [root@xcatmn home]# echo "set Power.S3Enable Enable" > power-setting + [root@xcatmn home]# pasu -b power-setting feihunode02 + feihunode02: Batch mode start. + feihunode02: [set Power.S3Enable Enable] + feihunode02: Power.S3Enable=Enable + feihunode02: + feihunode02: Beginning intermediate batch update. + feihunode02: Waiting for command completion status. + feihunode02: Command completed successfully. + feihunode02: Completed intermediate batch update. + feihunode02: Batch mode completed successfully. + + [root@xcatmn home]# pasu feihunode02 show all|grep -i s3 + feihunode02: IMM.Community_HostIPAddress3.1= + feihunode02: IMM.Community_HostIPAddress3.2= + feihunode02: IMM.Community_HostIPAddress3.3= + feihunode02: IMM.DNS_IP_Address3=0.0.0.0 + feihunode02: IMM.IPv6DNS_IP_Address3=:: + feihunode02: Power.S3Enable=Enable + =item B|B Print the current power state/status. From a4fb3664855401d5dd10fc84113666c89cf1c213 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 17 Apr 2014 01:49:47 -0700 Subject: [PATCH 26/28] modify the manpage of rpower not to use internal node names --- xCAT-client/pods/man1/rpower.1.pod | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/xCAT-client/pods/man1/rpower.1.pod b/xCAT-client/pods/man1/rpower.1.pod index 3dc70e7e1..f11a59b0f 100644 --- a/xCAT-client/pods/man1/rpower.1.pod +++ b/xCAT-client/pods/man1/rpower.1.pod @@ -126,24 +126,24 @@ Don't try to run B against the 'on' state node, it would cause the node ge For some of xCAT hardware such as NeXtScale, it may need to enable S3 before using B. The following steps can be used to enable S3. Please reference L for "pasu" usage. [root@xcatmn home]# echo "set Power.S3Enable Enable" > power-setting - [root@xcatmn home]# pasu -b power-setting feihunode02 - feihunode02: Batch mode start. - feihunode02: [set Power.S3Enable Enable] - feihunode02: Power.S3Enable=Enable - feihunode02: - feihunode02: Beginning intermediate batch update. - feihunode02: Waiting for command completion status. - feihunode02: Command completed successfully. - feihunode02: Completed intermediate batch update. - feihunode02: Batch mode completed successfully. + [root@xcatmn home]# pasu -b power-setting node01 + node01: Batch mode start. + node01: [set Power.S3Enable Enable] + node01: Power.S3Enable=Enable + node01: + node01: Beginning intermediate batch update. + node01: Waiting for command completion status. + node01: Command completed successfully. + node01: Completed intermediate batch update. + node01: Batch mode completed successfully. - [root@xcatmn home]# pasu feihunode02 show all|grep -i s3 - feihunode02: IMM.Community_HostIPAddress3.1= - feihunode02: IMM.Community_HostIPAddress3.2= - feihunode02: IMM.Community_HostIPAddress3.3= - feihunode02: IMM.DNS_IP_Address3=0.0.0.0 - feihunode02: IMM.IPv6DNS_IP_Address3=:: - feihunode02: Power.S3Enable=Enable + [root@xcatmn home]# pasu node01 show all|grep -i s3 + node01: IMM.Community_HostIPAddress3.1= + node01: IMM.Community_HostIPAddress3.2= + node01: IMM.Community_HostIPAddress3.3= + node01: IMM.DNS_IP_Address3=0.0.0.0 + node01: IMM.IPv6DNS_IP_Address3=:: + node01: Power.S3Enable=Enable =item B|B From 723538741766cb9259ea2a59f0ddb297e89825d9 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 17 Apr 2014 03:04:54 -0700 Subject: [PATCH 27/28] enhance the dhcp unicast for some specific cases on nameservers and gateway value --- perl-xCAT/xCAT/NetworkUtils.pm | 56 ++++++++++++++++++++++++ xCAT-server/lib/perl/xCAT/Template.pm | 50 ++++++++++++++------- xCAT-server/lib/xcat/plugins/anaconda.pm | 48 ++++++++++++++------ xCAT-server/lib/xcat/plugins/sles.pm | 49 ++++++++++++++------- 4 files changed, 158 insertions(+), 45 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 92eee296b..c76cef6ff 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -19,6 +19,7 @@ use File::Path; use Math::BigInt; use Socket; use xCAT::GlobalDef; +use Data::Dumper; use strict; use warnings "all"; my $socket6support = eval { require Socket6 }; @@ -2028,6 +2029,61 @@ sub getSubnetGateway } +#------------------------------------------------------------------------------- +=head3 getNodeNameservers + Description: + Get nameservers of specified nodes. + The priority: noderes.nameservers > networks.nameservers > site.nameservers + Arguments: + node: node name list + Returns: + Return a hash ref, of the $nameservers{$node} + undef - Failed to get the nameservers + Globals: + none + Error: + none + Example: + my $nameservers = xCAT::NetworkUtils::getNodeNameservers(\@node); + Comments: + none + +=cut +#------------------------------------------------------------------------------- +sub getNodeNameservers{ + my $nodes=shift; + if( $nodes =~ /xCAT::NetworkUtils/) + { + $nodes=shift; + } + my @nodelist = @$nodes; + my %nodenameservers; + my $nrtab = xCAT::Table->new('noderes',-create=>0); + my %nrhash = %{$nrtab->getNodesAttribs(\@nodelist,['nameservers'])}; + + my $nettab = xCAT::Table->new("networks"); + my %nethash = xCAT::DBobjUtils->getNetwkInfo( \@nodelist ); + + my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers"); + my $sitenameservers=$nameservers[0]; + + + foreach my $node (@nodelist){ + if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers}) + { + $nodenameservers{$node}=$nrhash{$node}->[0]->{nameservers}; + }elsif($nethash{$node}{nameservers}) + { + $nodenameservers{$node}=$nethash{$node}{nameservers}; + }elsif($sitenameservers) + { + $nodenameservers{$node}=$sitenameservers; + } + } + + return \%nodenameservers; +} + #------------------------------------------------------------------------------- =head3 getNodeNetworkCfg diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 5e9a75e21..592941823 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -660,6 +660,9 @@ sub esxipv6setup { return 'esxcfg-vmknic -i '.$v6addr.'/64 "Management Network"'." #ESXISTATICV6\n"; } + + + sub kickstartnetwork { my $line = "network --onboot=yes --bootproto="; my $hoststab; @@ -678,18 +681,26 @@ sub kickstartnetwork { } elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) { my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node); unless($ipaddr) { die "cannot resolve the network configuration of $node"; } + + if($gateway eq ''){ + $gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr); + } + $line .="static --device=$suffix --ip=$ipaddr --netmask=$netmask --gateway=$gateway --hostname=$hostname "; - my $nrtab = xCAT::Table->new('noderes',-create=>0); - unless ($nrtab) { die "noderes table should always exist prior to template processing"; } - my $ent = $nrtab->getNodeAttribs($node,['nameservers'],prefetchcache=>1); - unless ($ent and $ent->{nameservers}) { die "attribute nameservers not set for $node"; } - my @nameserverARR=split (",",$ent->{nameservers}); + my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])}; + my @nameserverARR=split (",",$nameservers{$node}); my @nameserversIP; foreach (@nameserverARR) { - my ($host,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + my $ip; + if($_ eq ''){ + $ip = xCAT::NetworkUtils->my_ip_facing($gateway); + }else{ + (undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + } push @nameserversIP, $ip; + } if (scalar @nameserversIP) { @@ -721,19 +732,27 @@ sub yast2network { my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node); unless($ipaddr) { die "cannot resolve the network configuration of $node"; } - my $nrtab = xCAT::Table->new('noderes',-create=>0); - unless ($nrtab) { die "noderes table should always exist prior to template processing"; } - my $ent = $nrtab->getNodeAttribs($node,['nameservers'],prefetchcache=>1); - unless ($ent and $ent->{nameservers}) { die "attribute nameservers not set for $node"; } - my @nameserverARR=split (",",$ent->{nameservers}); + if($gateway eq ''){ + $gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr); + } + + my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])}; + + my @nameserverARR=split (",",$nameservers{$node}); + my @nameserversIP; foreach (@nameserverARR) { - my ($host,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + my $ip; + if($_ eq ''){ + $ip = xCAT::NetworkUtils->my_ip_facing($gateway); + }else{ + (undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + } push @nameserversIP, $ip; + } - - + # get the domains for each node - one call for all nodes in hosts file my $nd = xCAT::NetworkUtils->getNodeDomains([$node]); my %nodedomains = %$nd; @@ -761,7 +780,7 @@ sub yast2network { 'nameservers' => [ { 'config:type' => 'list', - 'nameserver' => @nameserversIP + 'nameserver' => [@nameserversIP] } ], 'hostname' => [ @@ -908,6 +927,7 @@ sub yast2network { $line=$xml->XMLout($networkhash); } + return $line; } diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 7676f34d6..52229e21e 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1382,8 +1382,10 @@ sub mkinstall } if ($::XCATSITEVALS{managedaddressmode} =~ /static/){ - my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($instserver); - $instserver=$ip; + unless($instserver eq '!myipfn!'){ + my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($instserver); + $instserver=$ip; + } } my $httpprefix=$pkgdir; if ($installroot =~ /\/$/) { @@ -1455,20 +1457,38 @@ sub mkinstall #to avoid multicast dhcp if($::XCATSITEVALS{managedaddressmode} =~ /static/){ my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node); - unless($ipaddr) { die "cannot resolve the network configuration of $node"; } + unless($ipaddr) { + $callback->( + { + error => [ + "cannot resolve the ip address of $node" + ], + errorcode => [1] + } + ); + } + + if($gateway eq ''){ + $gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr); + } $kcmdline .=" ip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname "; - my $nrtab = xCAT::Table->new('noderes',-create=>0); - unless ($nrtab) { die "noderes table should always exist prior to template processing"; } - my $ent = $nrtab->getNodeAttribs($node,['nameservers'],prefetchcache=>1); - unless ($ent and $ent->{nameservers}) { die "attribute nameservers not set for $node"; } - my @nameserverARR=split (",",$ent->{nameservers}); - my @nameserversIP; - foreach (@nameserverARR) - { - my ($host,$ip) = xCAT::NetworkUtils->gethostnameandip($_); - push @nameserversIP, $ip; - } + + + my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])}; + my @nameserverARR=split (",",$nameservers{$node}); + my @nameserversIP; + foreach (@nameserverARR) + { + my $ip; + if($_ eq ''){ + $ip = xCAT::NetworkUtils->my_ip_facing($gateway); + }else{ + (undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + } + push @nameserversIP, $ip; + + } if(scalar @nameserversIP){ $kcmdline .=" dns=".join(",",@nameserversIP); diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 9d57e8867..d53db653b 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1075,10 +1075,11 @@ sub mkinstall $netserver = $ent->{nfsserver}; } - if ($::XCATSITEVALS{managedaddressmode} =~ /static/){ - my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($netserver); - $netserver=$ip; + unless($netserver eq '!myipfn!'){ + my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($netserver); + $netserver=$ip; + } } my $httpprefix = $pkgdir; @@ -1149,20 +1150,36 @@ sub mkinstall #to avoid multicast dhcp if($::XCATSITEVALS{managedaddressmode} =~ /static/){ my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node); - unless($ipaddr) { die "cannot resolve the network configuration of $node"; } - - $kcmdline .=" hostip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname "; - my $nrtab = xCAT::Table->new('noderes',-create=>0); - unless ($nrtab) { die "noderes table should always exist prior to template processing"; } - my $ent = $nrtab->getNodeAttribs($node,['nameservers'],prefetchcache=>1); - unless ($ent and $ent->{nameservers}) { die "attribute nameservers not set for $node"; } - my @nameserverARR=split (",",$ent->{nameservers}); - my @nameserversIP; - foreach (@nameserverARR) - { - my ($host,$ip) = xCAT::NetworkUtils->gethostnameandip($_); - push @nameserversIP, $ip; + unless($ipaddr) { + $callback->( + { + error => [ + "cannot resolve the ip address of $node" + ], + errorcode => [1] + } + ); } + if($gateway eq ''){ + $gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr); + } + $kcmdline .=" hostip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname "; + + + my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])}; + my @nameserverARR=split (",",$nameservers{$node}); + my @nameserversIP; + foreach (@nameserverARR) + { + my $ip; + if($_ eq ''){ + $ip = xCAT::NetworkUtils->my_ip_facing($gateway); + }else{ + (undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_); + } + push @nameserversIP, $ip; + + } if(scalar @nameserversIP){ $kcmdline .=" dns=".join(",",@nameserversIP); From eb381a3b96f8f3573b80abbb8cf97a4565c0a734 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 17 Apr 2014 03:15:26 -0700 Subject: [PATCH 28/28] add description of managedaddressmode --- perl-xCAT/xCAT/Schema.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 1cd4017db..7395dc68b 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -921,6 +921,11 @@ site => { " '0' value means include all the nodes in the subnet.\n\n". " pruneservices: Whether to enable service pruning when noderm is run (i.e.\n". " removing DHCP entries when noderm is executed)\n\n". + " managedaddressmode: The mode of networking configuration during node provision.\n". + " If set to 'static', the network configuration will be configured \n". + " in static mode based on the node and network definition on MN.\n". + " If set to 'dhcp', the network will be configured with dhcp protocol.\n". + " The default is 'dhcp'.\n\n". " ------------\n". "DNS ATTRIBUTES\n". " ------------\n".