diff --git a/makerpm b/makerpm index 5fa58918a..e48de76d5 100755 --- a/makerpm +++ b/makerpm @@ -85,6 +85,7 @@ function makexcat { cd `dirname $0`/$RPMNAME tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html cp xcat.conf $RPMROOT/SOURCES + cp xcat.conf.apach24 $RPMROOT/SOURCES cp xCATSN $RPMROOT/SOURCES cd - >/dev/null elif [ "$RPMNAME" = "xCAT-buildkit" ]; then diff --git a/perl-xCAT/xCAT/RemoteShellExp.pm b/perl-xCAT/xCAT/RemoteShellExp.pm index 90b15ed43..df62c73fa 100755 --- a/perl-xCAT/xCAT/RemoteShellExp.pm +++ b/perl-xCAT/xCAT/RemoteShellExp.pm @@ -810,6 +810,10 @@ sub senddeviceskeys # add to the command $setupcmd .=$key; $setupcmd .="\""; + # Special case for vios + if ($ENV{DEVICETYPE} eq 'vios') { + $setupcmd = "\"echo $key | tee -a ~/.ssh/authorized_keys2\""; + } # For each input device my @nodelist=split(/,/,$nodes); foreach my $node (@nodelist) { diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node index e516a138a..e67f48393 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node @@ -100,8 +100,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node index da148f47e..81ef22564 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node @@ -36,8 +36,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-server/lib/perl/xCAT/WinUtils.pm b/xCAT-server/lib/perl/xCAT/WinUtils.pm index 6c3d1ca23..23a2fd166 100644 --- a/xCAT-server/lib/perl/xCAT/WinUtils.pm +++ b/xCAT-server/lib/perl/xCAT/WinUtils.pm @@ -13,6 +13,13 @@ our %kmskeymap = ( "win8.professional_n" => "XCVCF-2NXM9-723PB-MHCB7-2RYQQ", "win8.enterprise" => "32JNW-9KQ84-P47T8-D8GGY-CWCK7", "win8.enterprise_n" => "JMNMF-RHW7P-DMY6X-RF3DR-X2BQT", + "win81.professional" => "GCRJD-8NW9H-F2CDX-CCM8D-9D6T9", + "win81.professional_n" => "HMCNV-VVBFX-7HMBH-CTY9B-B4FXY", + "win81.enterprise" => "MHF9N-XY6XB-WVXMC-BTDCT-MKKG7", + "win81.enterprise_n" => "TT4HM-HN7YT-62K67-RGRQJ-JFFXW", + "win2012r2.standard" => "D2N9P-3P6X9-2R39C-7RTCD-MDVJX", + "win2012r2.datacenter" => "W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9", + "win2012r2.essentials" => "KNC87-3J2TX-XB4WP-VCPJV-M4FWM", "win2012.standard" => "XC9B7-NBPP2-83J2H-RHMBY-92BT4", #note that core and non-core share KMS key "win2012.datacenter" => "48HP8-DN98B-MYWDG-T2DCC-8W83P", "win7.professional" => "FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4", diff --git a/xCAT-server/lib/xcat/plugins/confluent.pm b/xCAT-server/lib/xcat/plugins/confluent.pm index 1c9488ec8..006d00969 100644 --- a/xCAT-server/lib/xcat/plugins/confluent.pm +++ b/xCAT-server/lib/xcat/plugins/confluent.pm @@ -390,7 +390,7 @@ foreach my $node (sort keys %$cfgenthash) { } } else { $parameters{name} = $node; - $confluent->create('/nodes/bob/', parameters=>\%parameters); + $confluent->create('/nodes/', parameters=>\%parameters); my $rsp = $confluent->next_result(); while ($rsp) { if (exists $rsp->{error}) { diff --git a/xCAT-server/share/xcat/devicetype/vios/config b/xCAT-server/share/xcat/devicetype/vios/config new file mode 100644 index 000000000..da9165090 --- /dev/null +++ b/xCAT-server/share/xcat/devicetype/vios/config @@ -0,0 +1,5 @@ +[main] +ssh-setup-command=echo +[xdsh] +pre-command=NULL +post-command=NULL diff --git a/xCAT-server/share/xcat/hamn/deactivate-mn b/xCAT-server/share/xcat/hamn/deactivate-mn index da2f19dd2..9a4ab6ddf 100755 --- a/xCAT-server/share/xcat/hamn/deactivate-mn +++ b/xCAT-server/share/xcat/hamn/deactivate-mn @@ -251,7 +251,11 @@ then then BOOT_HOSTNAME=$(lsattr -El inet0 -a hostname | awk '{print $2}') else # Linux - BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + if [ -f "/etc/hostname" ]; then + BOOT_HOSTNAME=`cat /etc/hostname` + else + BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + fi fi hostname ${BOOT_HOSTNAME} fi diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 9e9038d31..5d54bc7d6 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -59,7 +59,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -72,7 +72,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 34f1f4a5f..618ae1aad 100644 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -61,7 +61,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -74,7 +74,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 054d74daa..10d406998 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -44,7 +44,7 @@ do if [ ! -x /xcatpost/mypostscript ]; then chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` @@ -59,7 +59,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index 452804038..aee31ff58 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -5,10 +5,8 @@ dhclient kernel openssh-server openssh-clients -busybox wget rsyslog -dash vim-minimal ntp rsyslog diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist index 18ceb3e33..410cd004c 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist @@ -6,8 +6,6 @@ dhclient kernel openssh-server openssh-clients -busybox -dash iputils bc irqbalance diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index e7361fdda..78d33e19f 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -39,12 +39,19 @@ my $start = Time::HiRes::gettimeofday(); $start =~ s/(\d.*)\.(\d.*)/$1/; if (!$nic) { print "specify a nic\n"; print $::USAGE; exit 1;} -my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +#my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +my $IPADDRMASK = `ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print \$2}' | head -n 1`; +my ($IP,$MASK)= split (/\//,$IPADDRMASK); my $MAC; +my $tmpMAC; +my @ipoutput; if ($::MACADD) { $MAC = $::MACADD; } else { - $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; +# $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; + $tmpMAC = `ip link show $nic | grep ether`; + @ipoutput= split (' ',$tmpMAC); + $MAC=$ipoutput[1]; } chomp($IP); @@ -313,4 +320,3 @@ sub kill_child { #print "try to kill $cpid\n"; } } - diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index dfdf2f3e2..aca5b80ca 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -39,8 +39,8 @@ my %confhash; my $rootdir = "$::XCATROOT/share/xcat/tools/autotest"; my $needhelp = 0; my $branch = 0; -my $rhppc64configfile = "$rootdir/default.conf"; -my $configfile = "/regression/rhppc64/default.conf"; +my $testconfigfile = "$rootdir/default.conf"; +my $configfile = "/regression/default.conf"; my $MN = undef; my $management_node = undef; my $CN = undef; @@ -92,7 +92,7 @@ sub usage ####################################### # config for rhppc64env ####################################### -sub config_rhppc64 { +sub config_test { send_msg("******************************"); send_msg("Reading Configure"); send_msg("******************************"); @@ -133,6 +133,15 @@ sub config_rhppc64 { }elsif($line =~ /\[\s*rhppc64System|Custom\s*\]/){ $type = "rhppc64Varible"; + }elsif($line =~ /\[\s*slesppc64System|Custom\s*\]/){ + + $type = "slesppc64Varible"; + }elsif($line =~ /\[\s*rhx8664System|Custom\s*\]/){ + + $type = "rhx8664Varible"; + }elsif($line =~ /\[\s*slesx8664System|Custom\s*\]/){ + + $type = "slesx8664Varible"; }elsif ($type eq "rhppc64Table") { ##TABLE BLOCK## if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { @@ -145,6 +154,43 @@ sub config_rhppc64 { $rhppc64config{table}{$sub_type}{$name}{__KEY__}=$attr; } } + }elsif ($type eq "slesppc64Table") { + ##TABLE BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + if($name&&($slesppc64config{table}{$sub_type}{$name}{__KEY__} ne $attr)){ + $slesppc64config{table}{$sub_type}{$name}{$attr}=$value; + } else { + $name = $value; + $slesppc64config{table}{$sub_type}{$name}{__KEY__}=$attr; + } + } + }elsif ($type eq "rhx8664Table") { + ##TABLE BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + if($name&&($rhx8664config{table}{$sub_type}{$name}{__KEY__} ne $attr)){ + $rhx8664config{table}{$sub_type}{$name}{$attr}=$value; + } else { + $name = $value; + $rhx8664config{table}{$sub_type}{$name}{__KEY__}=$attr; + } + } + }elsif ($type eq "slesx8664Table") { + ##TABLE BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + if($name&&($slesx8664config{table}{$sub_type}{$name}{__KEY__} ne $attr)){ + $slesx8664config{table}{$sub_type}{$name}{$attr}=$value; + } else { + $name = $value; + $slesx8664config{table}{$sub_type}{$name}{__KEY__}=$attr; + } + } + }elsif ($type eq "rhppc64Object") { ##OBJECT BLOCK## if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { @@ -162,6 +208,58 @@ sub config_rhppc64 { $rhppc64config{object}{$sub_type}{$name}{$attr}=$value; } } + }elsif ($type eq "slesppc64Object") { + ##OBJECT BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + #print "rhppc64node attr is $attr\n"; + #print "rhppc64node value is $value\n"; + if($attr eq "Name"){ + $name = $value; + } elsif(!defined($name)){ + print "Please give name for Object\n"; + close FILE; + return 1; + } else { + $slesppc64config{object}{$sub_type}{$name}{$attr}=$value; + } + } + }elsif ($type eq "rhx8664Object") { + ##OBJECT BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + #print "rhx8664node attr is $attr\n"; + #print "rhx8664node value is $value\n"; + if($attr eq "Name"){ + $name = $value; + } elsif(!defined($name)){ + print "Please give name for Object\n"; + close FILE; + return 1; + } else { + $rhx8664config{object}{$sub_type}{$name}{$attr}=$value; + } + } + }elsif ($type eq "slesx8664Object") { + ##OBJECT BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { + $attr = $1; + $value = $2; + #print "slesx8664node attr is $attr\n"; + #print "slesx8664node value is $value\n"; + if($attr eq "Name"){ + $name = $value; + } elsif(!defined($name)){ + print "Please give name for Object\n"; + close FILE; + return 1; + } else { + $slesx8664config{object}{$sub_type}{$name}{$attr}=$value; + } + } + }elsif ($type eq "rhppc64Script") { ##SCRIPT_BLOCK## if($sub_type eq "Prev") { @@ -172,14 +270,63 @@ sub config_rhppc64 { $rhppc64config{script_post}->[$c] = $line; $c = $c + 1; } + }elsif ($type eq "slesppc64Script") { + ##SCRIPT_BLOCK## + if($sub_type eq "Prev") { + $slesppc64config{script_prev}->[$c] = $line; + $c = $c + 1; + } + elsif ($sub_type eq "slesppc64Post") { + $slesppc64config{script_post}->[$c] = $line; + $c = $c + 1; + } + }elsif ($type eq "rhx8664Script") { + ##SCRIPT_BLOCK## + if($sub_type eq "Prev") { + $rhx8664config{script_prev}->[$c] = $line; + $c = $c + 1; + } + elsif ($sub_type eq "rhx8664Post") { + $rhx8664config{script_post}->[$c] = $line; + $c = $c + 1; + } + }elsif ($type eq "slesx8664Script") { + ##SCRIPT_BLOCK## + if($sub_type eq "Prev") { + $slesx8664config{script_prev}->[$c] = $line; + $c = $c + 1; + } + elsif ($sub_type eq "slesx8664Post") { + $slesx8664config{script_post}->[$c] = $line; + $c = $c + 1; + } + } elsif ($type eq "rhppc64Varible") { ##NODE_BLOCK## if($line =~ /(\w+)\s*=\s*([\w\.\-\/]+)/) { $rhppc64config{var}{$1} = $2; print "var $1,$2\n"; } + } elsif ($type eq "slesppc64Varible") { + ##NODE_BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-\/]+)/) { + $slesppc64config{var}{$1} = $2; + } + } elsif ($type eq "rhx8664Varible") { + ##NODE_BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-\/]+)/) { + $rhx8664config{var}{$1} = $2; + print "var $1,$2\n"; + } + } elsif ($type eq "slesx8664Varible") { + ##NODE_BLOCK## + if($line =~ /(\w+)\s*=\s*([\w\.\-\/]+)/) { + $slesx8664config{var}{$1} = $2; + print "var $1,$2\n"; + } } } + if(exists $rhppc64config{object}){ foreach my $type (keys %{$rhppc64config{object}}){ foreach my $name (keys %{$rhppc64config{object}{$type}}){ @@ -194,6 +341,49 @@ sub config_rhppc64 { } } } + if(exists $slesppc64config{object}){ + foreach my $type (keys %{$slesppc64config{object}}){ + foreach my $name (keys %{$slesppc64config{object}{$type}}){ + send_msg("OBJECT:$name,TYPE:$type"); + &runcmd( " echo [Object_$type]>>defaultslesppc64.conf"); + &runcmd( " echo Name=$name>>defaultslesppc64.conf"); + #print "$name,TYPE:$type \n"; + foreach my $attr (keys %{$slesppc64config{object}{$type}{$name}}){ + send_msg(" $attr = $slesppc64config{object}{$type}{$name}{$attr};"); + &runcmd( " echo $attr=$slesppc64config{object}{$type}{$name}{$attr}>>defaultslesppc64.conf"); + } + } + } + } + if(exists $rhx8664config{object}){ + foreach my $type (keys %{$rhx8664config{object}}){ + foreach my $name (keys %{$rhx8664config{object}{$type}}){ + send_msg("OBJECT:$name,TYPE:$type"); + &runcmd( " echo [Object_$type]>>defaultrhx8664.conf"); + &runcmd( " echo Name=$name>>defaultrhx8664.conf"); + #print "$name,TYPE:$type \n"; + foreach my $attr (keys %{$rhx8664config{object}{$type}{$name}}){ + send_msg(" $attr = $rhx8664config{object}{$type}{$name}{$attr};"); + &runcmd( " echo $attr=$rhx8664config{object}{$type}{$name}{$attr}>>defaultrhx8664.conf"); + } + } + } + } + if(exists $slesx8664config{object}){ + foreach my $type (keys %{$slesx8664config{object}}){ + foreach my $name (keys %{$slesx8664config{object}{$type}}){ + send_msg("OBJECT:$name,TYPE:$type"); + &runcmd( " echo [Object_$type]>>defaultslesx8664.conf"); + &runcmd( " echo Name=$name>>defaultslesx8664.conf"); + #print "$name,TYPE:$type \n"; + foreach my $attr (keys %{$slesx8664config{object}{$type}{$name}}){ + send_msg(" $attr = $slesx8664config{object}{$type}{$name}{$attr};"); + &runcmd( " echo $attr=$slesx8664config{object}{$type}{$name}{$attr}>>defaultslesx8664.conf"); + } + } + } + } + if(exists $rhppc64config{table}){ foreach my $type (keys %{$rhppc64config{table}}){ send_msg("TABLE:$type"); @@ -214,6 +404,67 @@ sub config_rhppc64 { } } } + if(exists $slesppc64config{table}){ + foreach my $type (keys %{$slesppc64config{table}}){ + send_msg("TABLE:$type"); + &runcmd( " echo [Table_$type]>>defaultslesppc64.conf"); + #&runcmd( " echo key=$type>>default.conf"); + #&runcmd( " echo [Table_site]>>default.conf"); + #&runcmd( " echo key=$type>>default.conf"); + foreach my $name (keys %{$slesppc64config{table}{$type}}){ + send_msg(" $slesppc64config{table}{$type}{$name}{__KEY__} = $name"); + &runcmd( " echo $slesppc64config{table}{$type}{$name}{__KEY__}=$name>>defaultslesppc64.conf"); + foreach my $attr (keys %{$slesppc64config{table}{$type}{$name}}){ + if($attr ne '__KEY__'){ + send_msg(" $attr = $slesppc64config{table}{$type}{$name}{$attr}"); + &runcmd( " echo $attr=$slesppc64config{table}{$type}{$name}{$attr}>>defaultslesppc64.conf"); + } + } + send_msg("\n"); + } + } + } + if(exists $rhx8664config{table}){ + foreach my $type (keys %{$rhx8664config{table}}){ + send_msg("TABLE:$type"); + &runcmd( " echo [Table_$type]>>defaultrhx8664.conf"); + #&runcmd( " echo key=$type>>default.conf"); + #&runcmd( " echo [Table_site]>>default.conf"); + #&runcmd( " echo key=$type>>default.conf"); + foreach my $name (keys %{$rhx8664config{table}{$type}}){ + send_msg(" $rhx8664config{table}{$type}{$name}{__KEY__} = $name"); + &runcmd( " echo $rhx8664config{table}{$type}{$name}{__KEY__}=$name>>defaultrhx8664.conf"); + foreach my $attr (keys %{$rhx8664config{table}{$type}{$name}}){ + if($attr ne '__KEY__'){ + send_msg(" $attr = $rhx8664config{table}{$type}{$name}{$attr}"); + &runcmd( " echo $attr=$rhx8664config{table}{$type}{$name}{$attr}>>defaultrhx8664.conf"); + } + } + send_msg("\n"); + } + } + } + if(exists $slesx8664config{table}){ + foreach my $type (keys %{$slesx8664config{table}}){ + send_msg("TABLE:$type"); + &runcmd( " echo [Table_$type]>>defaultslesx8664.conf"); + #&runcmd( " echo key=$type>>default.conf"); + #&runcmd( " echo [Table_site]>>default.conf"); + #&runcmd( " echo key=$type>>default.conf"); + foreach my $name (keys %{$slesx8664config{table}{$type}}){ + send_msg(" $slesx8664config{table}{$type}{$name}{__KEY__} = $name"); + &runcmd( " echo $slesx8664config{table}{$type}{$name}{__KEY__}=$name>>defaultslesx8664.conf"); + foreach my $attr (keys %{$slesx8664config{table}{$type}{$name}}){ + if($attr ne '__KEY__'){ + send_msg(" $attr = $slesx8664config{table}{$type}{$name}{$attr}"); + &runcmd( " echo $attr=$slesx8664config{table}{$type}{$name}{$attr}>>defaultslesx8664.conf"); + } + } + send_msg("\n"); + } + } + } + if(exists $rhppc64config{script_prev}){ send_msg("Script_Prev:"); foreach $cmd (@{$rhppc64config{script_prev}}){ @@ -240,7 +491,46 @@ sub config_rhppc64 { #print "var is $rhppc64config{var}\n"; } } - + if (exists $slesppc64config{var}){ + #my $MN=$slesppc64config{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]>>defaultslesppc64.conf"); + foreach my $varname (keys %{$slesppc64config{var}}){ + send_msg(" $varname = $slesppc64config{var}{$varname}"); + &runcmd( " echo $varname=$slesppc64config{var}{$varname}>>defaultslesppc64.conf"); + #print "var is $slesppc64config{var}\n"; + } + } + if (exists $rhx8664config{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]>>defaultrhx8664.conf"); + foreach my $varname (keys %{$rhx8664config{var}}){ + send_msg(" $varname = $rhx8664config{var}{$varname}"); + &runcmd( " echo $varname=$rhx8664config{var}{$varname}>>defaultrhx8664.conf"); + #print "var is $rhppc64config{var}\n"; + } + } + if (exists $slesx8664config{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]>>defaultslesx8664.conf"); + foreach my $varname (keys %{$slesx8664config{var}}){ + send_msg(" $varname = $slesx8664config{var}{$varname}"); + &runcmd( " echo $varname=$slesx8664config{var}{$varname}>>defaultslesx8664.conf"); + #print "var is $rhppc64config{var}\n"; + } + } + close FILE; return 0; @@ -295,14 +585,16 @@ sub copy_code { #send_msg("mn is $mn"); #install dep for buildlocal - send_msg("begin to install build required packages on mn $mn"); - $res = system("xdsh $mn yum install -y rpm-build perl-Time-HiRes perl-DBI createrepo"); - +# if(($confhash{rhpmn}==$mn)||($confhash{rhxmn}==$mn)){ +# send_msg("begin to install build required packages on mn $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 $mn"); system("scp /etc/hosts $mn:/etc"); + send_msg("begin to copy code to $mn"); $res = system("scp -r $codedir root\@$mn:/"); if ($res != 0){ @@ -359,38 +651,51 @@ sub config_mn { ####################################### # install xcat and init rhppc64 env ####################################### +sub gettestinfo { +my $mn = shift; +my $testenvinfo = undef; +my @osname = runcmd("xdsh $mn uname -a "); +my @release = runcmd("xdsh $mn cat /etc/*release"); +my @osinfo = runcmd("xdsh $mn lsb_release -a"); +if ( $osname [0] =~ /Linux/ && $osname [0] =~ /ppc64/ && $release [1] =~ /Red Hat Enterprise Linux Server release 6.5/){ + print "MN info is redhat ppc 64 "; + $testenvinfo = "rhppc64"; +}elsif ( $osinfo [2] =~ /SUSE Linux Enterprise Server 11/ && $osinfo [2] =~ /ppc64/){ + print " MN info is sles 11.3 ppc64 "; + $testenvinfo = "slesppc64"; +}elsif ( $osinfo [2] =~ /SUSE Linux Enterprise Server 11/ && $osinfo [2] =~ /x86_64/){ + print " MN info is sles 11.3 x86_64 "; + $testenvinfo = "slesx8664"; +}elsif ( $osinfo [0] =~ /amd64/ && $osinfo [2] =~ /Red Hat Enterprise Linux Server release 6.5/){ + print "MN info is redhat 6.5 x86_64 \n"; + $testenvinfo = "rhx8664"; +}else + {print "no machine info ";} + return $testenvinfo; +} + sub init { my $mn = shift; - if (exists $rhppc64config{var}){ + my $MN=$mn; + my $envoutput = &gettestinfo; + if ($envoutput eq 'rhppc64'){ #my $MN=$rhppc64config{var}{MN}; - my $MN=$mn; - my $MNIP=$rhppc64config{var}{MNIP}; - my $CN=$rhppc64config{var}{CN}; - my $CNIP=$rhppc64config{var}{CNIP}; - my $SN=$rhppc64config{var}{SN}; - my $SNIP=$rhppc64config{var}{SNIP}; - my $SNCN=$rhppc64config{var}{SNCN}; - my $SNCNIP=$rhppc64config{var}{SNCNIP}; - my $HMC=$rhppc64config{var}{HMC}; - my $HMCIP=$rhppc64config{var}{HMCIP}; - my $MOUNTIP=$rhppc64config{var}{MOUNTIP}; - my $DOMAIN=$rhppc64config{var}{DOMAIN}; my $nodedir=$rhppc64config{var}{nodedir}; system("xdsh $MN mkdir -p /iso/mountpoint"); print "--prepareing redhat iso file.......\n"; print "--mount NF ......."; -# system ("scp -r /iso/*.iso $MN:/iso"); -# system("xdsh $MN mount -o loop /iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso /iso/mountpoint"); + system ("scp -r /iso/*.iso $MN:/iso"); + system("xdsh $MN mount -o loop /iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso /iso/mountpoint"); 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:/"); + $res = system("scp -r $nodedir/xcat-dep $MN:/"); &repo(); - system("scp -r rhel6.4.repo $MN:/etc/yum.repos.d/rhel6.4.repo"); - #system("scp -r default.conf $MN:$rhppc64configfile"); + system("scp -r rhel6.5.repo $MN:/etc/yum.repos.d/rhel6.5.repo"); + #system("scp -r default.conf $MN:$testconfigfile"); #system("xdsh $MN perl $nodedir/xcatbuild/xcat-core/mklocalrepo.sh"); system("xdsh $MN perl /xcat-dep/rh6/ppc64/mklocalrepo.sh"); print "--install XCAT .......\n"; @@ -403,7 +708,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"); + system("scp -r default.conf $MN:$testconfigfile"); print "--install createrepo .......\n"; #system("xdsh $MN yum -y install createrepo"); @@ -418,11 +723,92 @@ sub init #} send_msg( " rhppc64 env is ready\n"); - } + }elsif ($envoutput eq 'slesppc64'){ + #my $MN=$slesppc64config{var}{MN}; + my $nodedir=$slesppc64config{var}{nodedir}; + system(" xdsh $MN mkdir -p /iso/mountpoint"); + print "--prepareing SLES iso file.......\n"; + system("scp -r /iso/SLES-11-SP3-DVD-ppc64-GM-DVD1.iso $MN:/iso/"); + system("xdsh $MN mount -o loop /iso/SLES-11-SP3-DVD-ppc64-GM-DVD1.iso /iso/mountpoint"); #### + print "[OK]\n"; - return 0; + print "--prepareing /etc/hosts /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:/"); + + print "[OK]\n--deploy zypper...."; + system("xdsh $MN rm -rf /etc/zypp/repos.d/*"); + # system(xdsh $MN zypper ar file:///autotest/wjx/xcat-core xCAT-core); + system("xdsh $MN zypper ar file:///xcat-dep/sles11/ppc64 xCAT-dep"); + system("xdsh $MN zypper ar file:///iso/mountpoint sles11"); + print "[OK]\n--install xcat...."; + system("xdsh $MN zypper sl -U"); + system("xdsh $MN zypper --gpg-auto-import-keys search --match-exact -s screen"); + system("xdsh $MN zypper -n install xCAT"); + system("xdsh $MN zypper -n install xCAT-test"); + system("scp -r defaultslesppc64.conf $MN:$testconfigfile"); + print "--prepare test environment....\n"; + print "[OK]\n"; +}elsif ($envoutput eq 'rhx8664'){ + system("xdsh $MN mkdir -p /iso/mountpoint"); + print "--prepareing redhat iso file.......\n"; + print "[OK]\n--copy ISO file....."; + system(" scp -r /iso/RHEL6.5-20131111.0-Server-x86_64-DVD1.iso $MN:/iso"); + print "--prepareing /etc/hosts /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("scp -r $nodedir/xcat-dep $MN:/"); + system("xdsh $MN rm -rf /etc/yum.repos.d/*"); + &repo(); + system("scp -r rhel6.5.repo $MN:/etc/yum.repos.d/"); + system("xdsh $MN perl /xcat-dep/rh6/ppc64/mklocalrepo.sh"); + print "--install XCAT .......\n"; + system("xdsh $MN yum clean metadata"); + system("xdsh $MN rpm --import /iso/RPM-GPG-KEY-redhat-release"); + system("xdsh $MN yum -y install xCAT"); + print "--install XCATTEST .......\n"; + 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 screen"); + system("xdsh $MN yum -y install mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc"); + system("xdsh $MN yum -y install iscsi-initiator-utils bridge-utils kvm perl-Sys-Virt perl-Sys-Virt.x86_64 libvirt.x86_64 qemu-kvm.x86_64 "); + system("scp -r defaultrhx8664.conf $MN:$testconfigfile"); +}elsif ($envoutput eq 'slesx8664'){ + system("xdsh $MN mkdir -p /iso/mountpoint"); + print "--prepareing SLES iso file.......\n"; + system(" scp -r /iso/SLES-11-SP3-DVD-x86_64-GM-DVD1.iso $MN:/iso"); + print "[OK]\n--mount ISO file....."; + system("mount -o loop /iso/SLES-11-SP3-DVD-x86_64-GM-DVD1.iso /iso/mountpoint"); #### + print "[OK]\n"; + print "--prepareing /etc/hosts /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"; + print "[OK]\n--deploy zypper...."; + system("xdsh $MN rm -rf /etc/zypp/repos.d/*"); + system("xdsh $MN zypper ar file:///xcat-dep/sles11/x86_64 xCAT-dep"); + system("xdsh $MN zypper ar file:///iso/mountpoint sles11"); + print "[OK]\n--install xcat...."; + system("xdsh $MN zypper sl -U"); + system("xdsh $MN zypper --gpg-auto-import-keys search --match-exact -s screen"); + system("xdsh $MN zypper -n install xCAT"); + system("xdsh $MN zypper -n xCAT-test*"); + print "--prepare test environment....\n"; + system("xdsh $MN zypper -n install iscsi-initiator-utils bridge-utils kvm perl-Sys-Virt perl-Sys-Virt.x86_64 libvirt.x86_64 qemu-kvm.x86_64"); + system("scp -r defaultslesx8664.conf $MN:$testconfigfile"); + print "--prepare vmtest environment....\n"; + print "[OK]\n";} + return 0; } ####################################### # do test @@ -431,6 +817,10 @@ sub do_test { my $mn = shift; # step 7.1 Install xcat and init mn send_msg("began to install xCAT and initialize mn"); + $res = &config_test(); + if ($res != 0){ + exit 1; + } $res = &init($mn); if ($res != 0){ exit 1; @@ -453,83 +843,26 @@ sub do_test1 my $mn = shift; #my $MN=$rhppc64config{var}{MN}; my $MN=$mn; + my $envoutput = &gettestinfo; + if ($envoutput eq 'rhppc64'){ my $nodedir=$rhppc64config{var}{nodedir}; print "copy config file "; - system("scp -r default.conf $MN:$rhppc64configfile"); + system("scp -r default.conf $MN:$testconfigfile"); - print "Start to run diskless installation $MN ...\n"; send_msg("******************************"); - send_msg("start diskless test"); + send_msg("start test"); send_msg("******************************"); - #if($dsklsinst){ -# 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; - #} - #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($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($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; - # } - # } - #} + 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/"); + + 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 /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 /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 /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/"); #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/"); @@ -555,6 +888,62 @@ sub do_test1 #} #system("mkdir -p $nodedir/result"); # system("scp -r $MN:/autotest/result /regression/rhppc64"); + }elsif ($envoutput eq 'slesppc64'){ + my $nodedir=$slesppc64config{var}{nodedir}; + print "copy config file "; + system("scp -r defaultslesppc64.conf $MN:$testconfigfile"); + send_msg("******************************"); + send_msg("start test"); + send_msg("******************************"); + system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_sles_diskless_installation_ppc64_flat"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /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 /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t Linux_sles_statelite_installation_flat_ppc64"); + system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /autotest/result/"); + 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 /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/"); + +}elsif ($envoutput eq 'rhx8664'){ + my $nodedir=$rhx8664config{var}{nodedir}; + print "copy config file "; + system("scp -r defaultrhx8664.conf $MN:$testconfigfile"); + send_msg("******************************"); + send_msg("start test"); + send_msg("******************************"); + #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/"); + + 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 /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 /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 /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/"); + +}elsif ($envoutput eq 'slesx8664'){ + my $nodedir=$slesx8664config{var}{nodedir}; + print "copy config file "; + system("scp -r defaultslesx8664.conf $MN:$testconfigfile"); + send_msg("******************************"); + send_msg("start test"); + send_msg("******************************"); + #system("xdsh $MN perl /opt/xcat/bin/xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t "); + #system("xdsh $MN mv /opt/xcat/share/xcat/tools/autotest/result/* /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 /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 /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 /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/"); + } } ####################################### @@ -620,21 +1009,13 @@ sub trim { #repo #################################### sub repo{ -my @osname = &runcmd("uname -a"); -if ( $osname [0] =~ /^Linux\s*/ && -f "/etc/redhat-release" && $osname [0] =~ /ppc64/){ - send_msg ("ppc64 redhat env\n"); - my $os="rhels6.4"; - my $arch="ppc64"; - send_msg ("os is $os,arch is $arch\n"); - &runcmd( " echo [rhe-6.4-server]>>rhel6.4.repo"); - &runcmd( " echo name=RHEL 6.4 SERVER packages>>rhel6.4.repo"); - &runcmd(" echo baseurl=file:///iso/mountpoint/Server/>>rhel6.4.repo"); - &runcmd(" echo enabled=1>>rhel6.4.repo"); - &runcmd(" echo gpgcheck=1>>rhel6.4.repo"); - # system("scp -r rhel6.4.repo $MN:/etc/yum.repos.d/rhel6.4.repo"); + &runcmd( " echo [rhe-6.5-server]>>rhel6.5.repo"); + &runcmd( " echo name=RHEL 6.5 SERVER packages>>rhel6.5.repo"); + &runcmd(" echo baseurl=file:///iso/mountpoint/Server/>>rhel6.5.repo"); + &runcmd(" echo enabled=1>>rhel6.5.repo"); + &runcmd(" echo gpgcheck=1>>rhel6.5.repo"); } -} ####################################### # send messages @@ -917,11 +1298,12 @@ unless ($ENV{'REGDEBUG'}) { #used for debug. # step 5. Build xcat code in MNs ####################################### send_msg("\n\n\n== Running build_xcat..............."); -# $res = build_xcat($mn); + $res = build_xcat($mn); if ($res) { send_msg("BUILD XCAT returns error, exit"); exit 1; } +exit 1; ####################################### # step 6. Read xCAT MN's configuration ####################################### diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index c63a2b164..bc29399a4 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -124,7 +124,7 @@ my %URIdef = ( GET => { desc => "Get the running status for the node {noderange}.", usage => "||$usagemsg{objreturn}|", - example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|x|", + example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|{\n \"node1\":{\n \"nodestat\":\"noping\"\n }\n}|", cmd => "nodestat", fhandler => \&actionhdl, outhdler => \&actionout, @@ -1401,6 +1401,9 @@ sub defout { $lines = \@alldata; } foreach my $l (@$lines) { + if ($l =~ /No responses/) { # handle the case that no output from lsslp command + return; + } if ($l =~ /^Object name: / || $l =~ /^\S+:$/) { # start new node if ($l =~ /^Object name:\s+(\S+)/) { # handle the output of lsdef -t $nodename = $1; diff --git a/xCAT-test/autotest/testcase/restapi/global/cases0 b/xCAT-test/autotest/testcase/restapi/global/cases0 new file mode 100644 index 000000000..d19bf7ea6 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/global/cases0 @@ -0,0 +1,42 @@ +start:globalconf_get +description: globalconf_get +cmd:restapitest -m GET -r /globalconf +check:rc==200 +cmdcheck:restapitest -o '{"clustersite":{"xcatdport":"3001"}}' -O == +end + +start:globalconf_get_attr +description: globalconf_get_attr +cmd:restapitest -m GET -r /globalconf/attrs/xcatdport,xcatiport +check:rc==200 +cmdcheck:restapitest -o '{"clustersite":{"xcatdport":"3001"}}' -O == +cmdcheck:restapitest -o '{"clustersite":{"xcatiport":"3002"}}' -O == +end + +start:globalconf_put +description: globalconf_put +cmd:restapitest -m PUT -r /globalconf/attrs/domain -d '{"domain":"cluster1.com"}' +check:rc==200 +end + +start:globalconf_put_checkresult +description: globalconf_put_checkresult +cmd:restapitest -m GET -r /globalconf/attrs/domain +check:rc==200 +cmdcheck:restapitest -o '{"clustersite":{"domain":"cluster1.com"}}' -O == +end + +start:globalconf_delete +description: globalconf_delete +cmd:restapitest -m DELETE -r /globalconf/attrs/domain +check:rc==200 +end + +start:globalconf_delete_checkresult +description: globalconf_delete_checkresult +cmd:restapitest -m GET -r /globalconf/attrs/domain +check:rc==200 +cmdcheck:restapitest -o '{"clustersite":{"domain":"cluster1.com"}}' -O != +end + + diff --git a/xCAT-test/autotest/testcase/restapi/group/cases0 b/xCAT-test/autotest/testcase/restapi/group/cases0 new file mode 100644 index 000000000..e7f170b66 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/group/cases0 @@ -0,0 +1,36 @@ +start:get_group_list +description: get_group_list +cmd:restapitest -m GET -r /groups +check:rc==200 +cmdcheck:restapitest -o '["all"]' -O == +end + +start:get_group_all +description: get_group_all +cmd:restapitest -m GET -r /groups/all +check:rc==200 +cmdcheck:restapitest -o '{"all":{"members":"virtualcn2"}}' -O == +end + +start:put_group_all +description: put_group_all +cmd:restapitest -m PUT -r /groups/all -d '{"mgt":"dfm","netboot":"yaboot"}' +check:rc==200 +end + +start:get_group_all_for_put +description: get_group_all_for_put +cmd:restapitest -m GET -r /groups/all +check:rc==200 +cmdcheck:restapitest -o '{"all":{"netboot":"yaboot"}}' -O == +end + +start:get_group_all_attrs +description: get_group_all_attrs +cmd:restapitest -m GET -r /groups/all/attrs/mgt,netboot +check:rc==200 +cmdcheck:restapitest -o '{"all":{"netboot":"yaboot"}}' -O == +end + + + diff --git a/xCAT-test/autotest/testcase/restapi/network/cases0 b/xCAT-test/autotest/testcase/restapi/network/cases0 new file mode 100644 index 000000000..2851f39b1 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/network/cases0 @@ -0,0 +1,74 @@ +start:get_networks +description: get_networks +cmd:restapitest -m GET -r /networks +check:rc==200 +cmdcheck:restapitest -o '["network1"]' -O == +end + +start:post_networks +description: post_networks +cmd:restapitest -m POST -r /networks +check:rc==201 +end + +start:get_networks_attr_for_post +description: get_networks_attr_for_post +cmd:restapitest -m GET -r /networks/network1 +check:rc==200 +cmdcheck:restapitest -o '{"network1":{"net":"10.1.0.0"}}' -O == +end + +start:post_networks_attr +description: post_networks_attr +cmd:restapitest -m GET -r /networks/network1 -d '{"gateway":"10.1.0.1","mask":"255.255.0.0"}' +check:rc==201 +end + +start:get_networks_all_attr +description: get_networks_all_attr +cmd:restapitest -m GET -r /networks/network1 +check:rc==200 +cmdcheck:restapitest -o '{"network1":{"net":"10.1.0.0"}}' -O == +end + +start:get_networks_attr +description: get_networks_attr +cmd:restapitest -m GET -r /networks/network1/attrs/net,mask +check:rc==200 +cmdcheck:restapitest -o '{"network1":{"net":"10.1.0.0"}}' -O == +end + +start:put_networks_attr +description: put_networks_attr +cmd:restapitest -m PUT -r /networks/network1 -d '{"mgtifname":"eth0","net":"10.1.0.0"}' +check:rc==200 +end + +start:get_networks_attr_for_put +description: get_networks_attr_for_put +cmd:restapitest -m GET -r /networks/network1 +check:rc==200 +cmdcheck:restapitest -o '{"network1":{"net":"10.1.0.0"}}' -O == +end + +start:delete_networks_attr_for_put +description: delete_networks_attr_for_put +cmd:restapitest -m DELETE -r /networks/network1 +check:rc==200 +end + +start:get_networks_for_delete +description: get_networks_for_delete +cmd:restapitest -m GET -r /networks +check:rc==200 +cmdcheck:restapitest -o '["network1"]' -O != +end + + + + + + + + + diff --git a/xCAT-test/autotest/testcase/restapi/node/cases0 b/xCAT-test/autotest/testcase/restapi/node/cases0 new file mode 100644 index 000000000..1920a0da7 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/node/cases0 @@ -0,0 +1,243 @@ +start:node_post +description: node_post +cmd:restapitest -m POST -r /nodes/node1 -d '{"groups":"all","mgt":"dfm","netboot":"yaboot"}' +check:rc==201 +end + +start:node_post2 +description: node_post2 +cmd:restapitest -m POST -r /nodes/node1 -d '{"groups":"all","mgt":"dfm","netboot":"yaboot"}' +check:rc==403 +cmdcheck:restapitest -o '{"errorcode":"1","error":["\nA definition for 'node1' already exists."]}' -O =~ +end + + +start:node_put +description: node_put +cmd:restapitest -m PUT -r /nodes/node1 -d '{"mgt":"hmc","netboot":"xnba"}' +check:rc==200 +end + + + +start:nodes_get +description: nodes_get +cmd:restapitest -m GET -r /nodes +check:rc==200 +cmdcheck:restapitest -o '["node1"]' -O == +end + +start:node_get +description: node_get +cmd:restapitest -m GET -r /nodes/node1 +check:rc==200 +cmdcheck:restapitest -o '{"node1":{"netboot":"xnba"}}' -O == +end + +start:node_delete +description: node_delete +cmd:restapitest -m GET -r /nodes/node1 +check:rc==200 +end + +start:nodes_get2 +description: nodes_get2 +cmd:restapitest -m GET -r /nodes +check:rc==200 +cmdcheck:restapitest -o '["node1"]' -O != +end + +start:node_get2 +description: node_get2 +cmd:restapitest -m GET -r /nodes/node1 +check:rc==403 +cmdcheck:restapitest -o '{"errorcode":"1","error":["Could not find an object named 'node1' of type 'node'."]}' -O =~ +end + +start:node_post3_for_get_test +description: node_post3_for_get_test +cmd:restapitest -m POST -r /nodes/node1 -d '{"groups":"all","mgt":"dfm","netboot":"yaboot"}' +check:rc==201 +end + +start:node_attr_get +description: node_get2 +cmd:restapitest -m GET -r /nodes/node1/attrs/mgt,groups,netboot +check:rc==200 +cmdcheck:restapitest -o '{"node1":{"netboot":"yaboot"}}' -O == +end + +###########此次需先添加networks表和hosts表的net和ip属性 +start:node_makehosts +description: node_makehosts +cmd:restapitest -m POST -r /nodes/node1/host +check:rc==201 +end + +start:node_makedns +description: node_makehosts +cmd:restapitest -m POST -r /nodes/node1/dns +check:rc==201 +end + + +start:node_delete_dns +description: node_delete_dns +cmd:restapitest -m DELETE -r /nodes/node1/dns +check:rc==200 +end + +start:node_put +description: node_put +cmd:restapitest -m PUT -r /nodes/node1 -d '{"mac":"00:1a:64:54:14:80"}' +check:rc==200 +end + +start:node_makedhcp +description: node_makedhcp +cmd:restapitest -m POST -r /nodes/node1/dhcp +check:rc==201 +end + +start:node_delete_dhcp +description: node_delete_dhcp +cmd:restapitest -m DELETE -r /nodes/node1/dhcp +check:rc==200 +end + +start:node_state +description: node_state +cmd:restapitest -m GET -r /nodes/node1/nodestat +check:rc==200 +cmdcheck:restapitest -o '{"node1":{"nodestat":"ANY"}}' -O == +end + + +#start:node_post4_for_scan_test +#description: node_post4_for_scan_test +#cmd:restapitest -m POST -r /nodes/e108m6hmc02 -d '{"groups":"all,hmc","mgt":"hmc","hwtype":"hmc","mtm":"7042CR4","serial":"1050FBB","nodetype":"ppc"}' +#check:rc==201 +#end + +start:node_scan +description: node_scan +cmd:restapitest -m GET -r /nodes/e108m6hmc02/subnodes +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m4hsp01":{"parent":"Server-9119-590-SN02C5F9E"}}' -O == +end + + +start:node_power_get +description: node_power_get +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/power +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"power":"ANY"}}' -O == +end + +start:node_power_put +description: node_power_put +cmd:restapitest -m PUT -r /nodes/Vc68m5sn01/power -d '{"action":"on"}' +check:rc==200 +end + +start:node_energy_put +description: node_energy_put +cmd:restapitest -m PUT -r /nodes/Vc68m5sn01/energy -d '{"cappingstatus":"on"}' +check:rc==200 +end + +start:node_energy_get +description: node_energy_get +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/energy +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"cappingmin":"on"}}' -O == +end + +start:node_energy_get_attr +description: node_energy_get_attr +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/energy/cappingmaxmin,cappingstatus +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"cappingmin":"ANY"}}' -O == +end + +start:node_get_attr +description: node_get_attr +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/sp/community +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"SP SNMP Community":"public"}}' -O == +end + +start:node_put_attr +description: node_put_attr +cmd:restapitest -m PUT -r /nodes/Vc68m5sn01/sp/community -d '{"value":"mycommunity"}'' +check:rc==200 +end + +start:node_put_nextboot +description: node_put_nextboot +cmd:restapitest -m PUT -r /nodes/Vc68m5sn01/nextboot -d '{"order":"net"}' +check:rc==201 +end + +start:node_get_nextboot +description: node_get_nextboot +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/nextboot +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"nextboot":"net"}}' -O == +end + +start:node_put_bootstate +description: node_put_bootstate +cmd:restapitest -m PUT -r /nodes/Vc68m5sn01/bootstate -d '{"osimage":"rhels6.4-x86_64-install-compute"}' +check:rc==201 +end + +start:node_get_bootstate +description: node_get_bootstate +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/bootstate +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"bootstat":"boot"}}' -O == +end + +start:node_get_vitals +description: node_get_vitals +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/vitals +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"SysBrd Fault":"0"}}' -O == +end + +start:node_get_vitals_attr +description: node_get_vitals_attr +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/vitals/fanspeed +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"Fan 1A Tach":"3219 RPM"}}' -O == +end + +start:node_get_inventory +description: node_get_inventory +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/inventory +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"Power Supply 2 Board FRU Number":"94Y8105"}}' -O == +end + +start:node_get_inventory_attr +description: node_get_inventory_attr +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/inventory/model +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"System Description":"System x3650 M4"}}' -O == +end + +start:node_get_eventlog +description: node_get_eventlog +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/eventlog +check:rc==200 +cmdcheck:restapitest -o '{"Vc68m5sn01":{"eventlog":"ANY"}}' -O == +end + +start:node_post_nodecopy +description: node_post_nodecopy +cmd:restapitest -m GET -r /nodes/Vc68m5sn01/nodecopy -d '{"src":["/tmp/f1","/tmp/f2"],"target":"/tmp"}' +check:rc==201 +end + + diff --git a/xCAT-test/autotest/testcase/restapi/osimage/cases0 b/xCAT-test/autotest/testcase/restapi/osimage/cases0 new file mode 100644 index 000000000..233acfe96 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/osimage/cases0 @@ -0,0 +1,93 @@ +start:get_images_all +description: get_images_all +cmd:restapitest -m GET -r /osimages +check:rc==200 +cmdcheck:restapitest -o '["rhels6.5-x86_64-install-compute"]' -O == +end + +start:post_images +description: post_images +cmd:restapitest -m POST -r /osimages -d '{"iso":"/iso/RHEL6.5-20131111.0-Server-x86_64-DVD1.iso"}' +check:rc==201 +end + +start:get_images +description: get_images +cmd:restapitest -m GET -r /osimages/rhels6.5-x86_64-install-compute +check:rc==200 +cmdcheck:restapitest -o '{"rhels6.5-x86_64-install-compute":{"provmethod":"install"}}' -O == +end + +start:put_images_attr +description: put_images_attr +cmd:restapitest -m PUT -r /osimages/rhels6.5-x86_64-install-hpc -d '{"osvers":"sles11.3","osarch":"x86_64"}' +check:rc==200 +end + +start:get_images_for_put +description: get_images_for_put +cmd:restapitest -m GET -r /osimages/rhels6.5-x86_64-install-hpc +check:rc==200 +cmdcheck:restapitest -o '{"rhels6.5-x86_64-install-hpc":{"osvers":"sles11.3"}}' -O == +end + +start:create_images +description: create_images +cmd:restapitest -m POST -r /osimages/rhels6.5-x86_64-install-hpc -d '{"profile":"compute","osarch":"x86_64"}' +check:rc==200 +end + +start:get_images_for_post +description: get_images_for_post +cmd:restapitest -m GET -r /osimages/rhels6.5-x86_64-install-hpc +check:rc==200 +cmdcheck:restapitest -o '{"rhels6.5-x86_64-install-hpc":{"profile":"compute"}}' -O == +end + +start:delete_images +description: delete_images +cmd:restapitest -m DELETE -r /osimages/rhels6.5-x86_64-install-hpc +check:rc==200 +end + +start:get_images_all_for_delete +description: get_images_all_for_delete +cmd:restapitest -m GET -r /osimages +check:rc==200 +cmdcheck:restapitest -o '["rhels6.5-x86_64-install-hpc"]' -O != +end + +start:get_images_attr +description: get_images_attr +cmd:restapitest -m GET -r /osimages/rhels6.5-x86_64-install-compute/attrs/imagetype,osarch,osname,provmethod +check:rc==200 +cmdcheck:restapitest -o '{"sles11.2-ppc64-install-compute":{osarch":"x86_64"}}' -O == +end + +start:post_images_attr_genimage +description: post_images_attr_genimage +cmd:restapitest -m POST -r /osimages/rhels6.5-x86_64-statelite-service/instance -d '{"action":"gen"}' +check:rc==200 +end + +start:post_images_attr_packimage +description: post_images_attr +cmd:restapitest -m POST -r /osimages/rhels6.5-x86_64-statelite-service/instance -d '{"action":"pack"}' +check:rc==200 +end + +start:post_images_attr_exportimage +description: post_images_attr +cmd:restapitest -m POST -r /osimages/rhels6.5-x86_64-statelite-service/instance -d '{"action":"export"}' +check:rc==200 +end + +start:delete_images +description: delete_images +cmd:restapitest -m DELETE -r /osimages/rhels6.5-x86_64-statelite-service/instance +check:rc==200 +end + + + + diff --git a/xCAT-test/autotest/testcase/restapi/policy/cases0 b/xCAT-test/autotest/testcase/restapi/policy/cases0 new file mode 100644 index 000000000..d007d40e3 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/policy/cases0 @@ -0,0 +1,65 @@ +start:get_policy_all +description: get_policy_all +cmd:restapitest -m GET -r /policy +check:rc==200 +cmdcheck:restapitest -o '["1"]' -O == +end + +start:get_policy_attr +description: get_policy_attr +cmd:restapitest -m GET -r /policy/1 +check:rc==200 +cmdcheck:restapitest -o '{"1":{"name":"root"}}' -O == +end + +start:put_policy_attr +description: put_policy_attr +cmd:restapitest -m PUT -r /policy/1 -d '{"name":"root1"}' +check:rc==200 +end + +start:get_policy_attr_for_put +description: get_policy_attr_for_put +cmd:restapitest -m GET -r /policy/1 +check:rc==200 +cmdcheck:restapitest -o '{"1":{"name":"root1"}}' -O == +end + +start:put_policy_attr_changeback +description: put_policy_attr_changeback +cmd:restapitest -m PUT -r /policy/1 -d '{"name":"root"}' +check:rc==200 +end + +start:post_policy +description: post_policy +cmd:restapitest -m POST -r /policy/11 -d '{"name":"root1",,"commands":"rpower"}' +check:rc==201 +end + +start:get_policy_attr_for_post +description: get_policy_attr_for_post +cmd:restapitest -m GET -r /policy/11 +check:rc==200 +cmdcheck:restapitest -o '{"11":{"name":"root1"}}' -O == +end + +start:delete_policy +description: delete_policy +cmd:restapitest -m DELETE -r /policy/11 +check:rc==200 +cmdcheck:restapitest -o '["11"]' -O != +end + +start:get_policy_attrs +description: get_policy_attrs +cmd:restapitest -m GET -r /policy/1/attrs/name,rule +check:rc==200 +cmdcheck:restapitest -o '{"1":{"name":"root"}}' -O == +end + + + + + + diff --git a/xCAT-test/autotest/testcase/restapi/service/cases0 b/xCAT-test/autotest/testcase/restapi/service/cases0 new file mode 100644 index 000000000..e9569fd69 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/service/cases0 @@ -0,0 +1,40 @@ +start:post_dns +description: post_dns +cmd:restapitest -m POST -r /services/dns +check:rc==201 +end + +start:post_dhcp +description: post_dhcp +cmd:restapitest -m POST -r /services/dns +check:rc==201 +end + +start:post_host +description: post_host +cmd:restapitest -m POST -r /services/host +check:rc==201 +end + +start:post_host +description: post_host +cmd:restapitest -m POST -r /services/host +check:rc==201 +end + +start:get_slpnodes +description: get_slpnodes +cmd:restapitest -m GET -r /services/slpnodes +check:rc==200 +cmdcheck:restapitest -o '{"ngpcmm01":{"mpa":"ngpcmm01"}}' -O == +end + +start:get_slpnodes_withst +description: get_slpnodes_withst +cmd:restapitest -m GET -r /services/slpnodes/FSP +check:rc==200 +cmdcheck:restapitest -o '{"Server--SNY014BG27A01K":{"mpa":"Server--SNY014BG27A01K"}}' -O == +end + + + diff --git a/xCAT-test/autotest/testcase/restapi/table/cases0 b/xCAT-test/autotest/testcase/restapi/table/cases0 new file mode 100644 index 000000000..8fd8a3955 --- /dev/null +++ b/xCAT-test/autotest/testcase/restapi/table/cases0 @@ -0,0 +1,101 @@ +start:node_post_for_table_get +description: node_for_table_get +cmd:restapitest -m POST -r /nodes/tnode1 -d '{"groups":"all","mgt":"dfm","netboot":"xnba","provmethod":"rhels6.4-x86_64-install-compute","profile":"compute","arch":"x86_64","os":"rhels6.4"}' +check:rc==201 +end + +start:node_post_for_table_get +description: node_for_table_get +cmd:restapitest -m POST -r /nodes/tnode2 -d '{"groups":"all","mgt":"dfm","netboot":"yaboot","provmethod":"rhels6.4-ppc64-install-compute","profile":"compute","arch":"ppc64","os":"rhels6.4"}' +check:rc==201 +end + +start:table_get +description: table_get +cmd:restapitest -m GET -r /tables/nodetype/nodes/tnode1,tnode2 +check:rc==200 +cmdcheck:restapitest -o '{"nodetype":[{"arch":"ppc64"}]}' -O == +end + +start:table_get2 +description: table_get2 +cmd:restapitest -m GET -r /tables/nodetype,noderes/nodes/tnode1,tnode2 +check:rc==200 +cmdcheck:restapitest -o '{"nodetype":[{"arch":"ppc64"}]}' -O == +end + +start:table_put +description: table_put +cmd:restapitest -m PUT -r /tables/nodetype,noderes/nodes/tnode1,tnode2 -d '{"nodetype":{"arch":"x86_64"},"noderes":{"netboot":"xnba"}}' +check:rc==200 +end + +start:table_get3 +description: table_get3 +cmd:restapitest -m GET -r /tables/nodetype,noderes/nodes/tnode1,tnode2 +check:rc==200 +cmdcheck:restapitest -o '{"nodetype":[{"arch":"x86_64"}]}' -O == +end + +start:table_get_attr +description: table_get_attr +cmd:restapitest -m GET -r /tables/nodetype,noderes/nodes/tnode1,tnode2 +check:rc==200 +cmdcheck:restapitest -o '{"nodetype":[{"arch":"x86_64"}]}' -O == +end + +start:table_get_row +description: table_get_row +cmd:restapitest -m GET -r /tables/networks/rows +check:rc==200 +cmdcheck:restapitest -o '{"networks":[{"netname":"ANY"}]}' -O == +end + +start:table_get_row_key +description: table_get_row_key +cmd:restapitest -m GET -r /tables/networks/rows/net=9.114.154.64,mask=255.255.255.192 +check:rc==200 +cmdcheck:restapitest -o '{"networks":[{"mask":"255.255.255.192"}]}' -O == +end + +start:table_put +description: table_put +cmd:restapitest -m PUT -r /tables/routes/rows/routename=privnet -d '{"net":"10.0.1.0","mask":"255.255.255.0","gateway":"10.0.1.254","ifname":"eth1"}' +check:rc==200 +end + +start:table_get_row1 +description: table_get_row1 +cmd:restapitest -m GET -r /tables/routes/privnet +check:rc==200 +cmdcheck:restapitest -o '{"routes":[{"gateway":"10.0.1.254"}]}' -O == +end + +start:table_get_row_key1 +description: table_get_row_key1 +cmd:restapitest -m GET -r /tables/routes/rows/routename=privnet +check:rc==200 +cmdcheck:restapitest -o '{"networks":[{"ifname":"eth1"}]}' -O == +end + +start:table_delete_row +description: table_delete_row +cmd:restapitest -m DELETE -r /tables/routes/rows/routename=privnet +check:rc==200 +cmdcheck:restapitest -o '{"networks":[{"ifname":"eth1"}]}' -O == +end + +start:table_get_row_for_delete +description: table_get_row_for_delete +cmd:restapitest -m GET -r /tables/routes/privnet +check:rc==200 +cmdcheck:restapitest -o '{"routes":[{"gateway":"10.0.1.254"}]}' -O !== +end + +start:table_get_special_key +description: table_get_special_key +cmd:restapitest -m GET -r /tables/networks/rows/net=192.168.1.0,mask=255.255.255.0/mgtifname,tftpserver +check:rc==200 +cmdcheck:restapitest -o '{"networks":[{"mgtifname":"eth0"}]}' -O !== +end + diff --git a/xCAT-test/restapitest b/xCAT-test/restapitest index 1e0682fc2..c37c2995b 100755 --- a/xCAT-test/restapitest +++ b/xCAT-test/restapitest @@ -144,6 +144,11 @@ for my $u (@users) { $i++; for my $t (@tokens) { for my $c (@certs){ + if ($method eq "POST" and ($resource =~ /^\/nodes\/(\w+)$/)) { + `/opt/xcat/bin/rmdef $1`; + print_debug("restapi test rmdef $1\n"); + } + my $res = run_restapi($method, $resource, $data, $c, $port, $host, $u, $p, $t); if($res){ my $reshash = parse_json($res); @@ -276,6 +281,49 @@ sub parse_json print "[:] content is $content \n" if($debug); parse_json($content); } + # for those who look like: + # {"Vc68m4hsp01":{"parent":"Server-9119-590-SN02C5F9E","pprofile":"Vc68m4hsp01"},"p5ih_c75vios":{"parent":"P5IH-SN02012EB-A","mgt":"hmc","id":"2"},"p5ih_lpar04":{"parent":"P5IH-SN02013EB-A","pprofile":"p5ih_lpar04"}} + elsif($input =~ /^"(\S+?)\":{\S+},/){ + $input =~ s/},/}%/; + my @contents = split /%/, $input; + my @reval; + # record result + foreach my $t (@contents) { + print ":{}, content is $t \n" if($debug); + my $re = parse_json($t); + push @reval, $re; + } + # merge hash + foreach my $t (@reval) { + if(ref($t) =~ "HASH") { + foreach my $k (keys %$t){ + $hash{$k} = $$t{$k}; + } + } + } + return \%hash; + } + elsif( $input =~ /^{\S+},{\S+}/ and !($input =~ /]/)){ + $input =~ s/},{/}%{/; + my @contents = split /%/, $input; + my @reval; + # record result + foreach my $t (@contents) { + print "{},{}, content is $t \n" if($debug); + my $re = parse_json($t); + push @reval, $re; + } + # merge hash + foreach my $t (@reval) { + if(ref($t) =~ "HASH") { + foreach my $k (keys %$t){ + $hash{$k} = $$t{$k}; + } + } + } + return \%hash; + } + # for those who look like # {"clustersite":{"domain":"cluster.com","master":"192.168.1.15"}} elsif ($input =~ /^\s*{(.*)}\s*$/s) { @@ -283,6 +331,26 @@ sub parse_json print "{} content is $content \n" if($debug); parse_json($content); } + elsif( $input =~ /],\"\S+\":/)){ + $input =~ s/],\"\S+\":/]%\"\S+\":/; + my @contents = split /%/, $input; + my @reval; + # record result + foreach my $t (@contents) { + print "],:, content is $t \n" if($debug); + my $re = parse_json($t); + push @reval, $re; + } + # merge hash + foreach my $t (@reval) { + if(ref($t) =~ "HASH") { + foreach my $k (keys %$t){ + $hash{$k} = $$t{$k}; + } + } + } + return \%hash; + } # for those who look like # "domain":"cluster.com","master":"192.168.1.15" elsif ($input =~ /,/ and !($input =~ /}/)) { @@ -505,3 +573,5 @@ sub transf_hash + + diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 5bc33da04..195fab5a6 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -393,11 +393,15 @@ elif [ "$1" = "-s" ];then fi fi hostname $NODE - grep -i "HOSTNAME" /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then + echo $NODE > /etc/hostname else - echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + grep -i "HOSTNAME" /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + else + echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + fi fi fi exit 0 diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index b29e2953c..f3f8b2236 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -63,7 +63,11 @@ then else #RedHat uses /etc/sysconfig/network-scripts/ifcfg-eth NICFILEPRE="/etc/sysconfig/network-scripts/ifcfg-" - sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then # for rh7 + echo `hostname` >/etc/hostname + else + sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + fi if [ ! -z "$defgw" ]; then echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index d1bcd6a4c..8da573914 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -16,11 +16,15 @@ device_names=`ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://` str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat - grep -i HOSTNAME /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then #RH7 + echo $HOSTNAME > /etc/hostname else - echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + grep -i HOSTNAME /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + else + echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + fi fi for i in $device_names;do str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i" diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 11a2c55ae..3838d7268 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -171,7 +171,7 @@ then cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] then - rm -rf /etc/httpd/conf.d/xcat.conf + rm -rf /etc/apache2/conf.d/xcat.conf cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf else rm -rf /etc/httpd/conf.d/xcat.conf