From 1afc1c29c55d85f7db096cac147af76b0dd0b5a2 Mon Sep 17 00:00:00 2001 From: ellen56 Date: Tue, 12 Oct 2010 09:41:43 +0000 Subject: [PATCH] 1. changed action of flag --restore to backup the xcat db before testing and restore xcat db after testing; 2. add inline function GETTABLEVALUE(keyname, key, colname, table) to get table attributes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7821 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-test/xcattest | 95 ++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 2d754cca5..7304f501e 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -269,8 +269,21 @@ sub getConfig sub init { + if($restore){ + log_this("******************************"); + log_this("Backup current xCAT database"); + log_this("******************************"); + &runcmd("mkdir -p /tmp/xCATdbbackup"); + &runcmd("dumpxCATdb -p /tmp/xCATdbbackup"); + if($::RUNCMD_RC != 0){ + &log_this("Fail to backup xCAT database"); + &runcmd("rm -rf /tmp/xCATdbbackup"); + $restore = 0; + return 1; + } + } log_this("******************************"); - log_this("initialize xCAT test evironment"); + log_this("Initialize xCAT test evironment"); log_this("******************************"); my $cmd = undef; foreach $cmd (@{$config{script_prev}}){ @@ -353,41 +366,43 @@ sub uninit log_this("******************************"); log_this("un-initialize xCAT test evironment"); log_this("******************************"); - my $cmd = undef;; - if(exists $config{object}){ - foreach my $type (keys %{$config{object}}){ - foreach my $name (keys %{$config{object}{$type}}){ - $cmd = "rmdef -t $type -o $name"; - log_this($cmd); - runcmd($cmd); - if($::RUNCMD_RC != 0){ - log_this("Fail to run $cmd"); - return 1; - } - } - } - } - if(exists $config{table}){ - foreach my $type (keys %{$config{table}}){ - foreach my $name (keys %{$config{table}{$type}}){ - $cmd = "chtab -d $config{table}{$type}{$name}{__KEY__}=$name $type"; - log_this($cmd); - runcmd($cmd); - if($::RUNCMD_RC != 0){ - log_this("Fail to run $cmd"); - return 1; - } - } - } - } - foreach $cmd (@{$config{script_post}}){ - log_this($cmd); - runcmd($cmd); - if($::RUNCMD_RC != 0){ - log_this("Fail to run $cmd"); - return 1; - } - } +# my $cmd = undef;; +# if(exists $config{object}){ +# foreach my $type (keys %{$config{object}}){ +# foreach my $name (keys %{$config{object}{$type}}){ +# $cmd = "rmdef -t $type -o $name"; +# log_this($cmd); +# runcmd($cmd); +# if($::RUNCMD_RC != 0){ +# log_this("Fail to run $cmd"); +# return 1; +# } +# } +# } +# } +# if(exists $config{table}){ +# foreach my $type (keys %{$config{table}}){ +# foreach my $name (keys %{$config{table}{$type}}){ +# $cmd = "chtab -d $config{table}{$type}{$name}{__KEY__}=$name $type"; +# log_this($cmd); +# runcmd($cmd); +# if($::RUNCMD_RC != 0){ +# log_this("Fail to run $cmd"); +# return 1; +# } +# } +# } +# } +# foreach $cmd (@{$config{script_post}}){ +# log_this($cmd); +# runcmd($cmd); +# if($::RUNCMD_RC != 0){ +# log_this("Fail to run $cmd"); +# return 1; +# } +# } + &runcmd("restorexCATdb -p /tmp/xCATdbbackup"); + &runcmd("rm -rf /tmp/xCATdbbackup"); return 0; } @@ -542,6 +557,12 @@ sub getnodeattr } return "Unknown"; } +sub gettablevalue +{ + my($keyname, $key, $colname, $table) = @_; + my @output = runcmd("gettab $keyname=$key $table\.$colname"); + return $output[0]; +} #to remove space and comment sub trim { @@ -584,6 +605,8 @@ sub getfunc } }elsif($func eq "INC"){ $value = $para[0] + 1; + }elsif($func eq "GETTABLEVALUE"){ + $value= gettablevalue(@para); } $str =~ s/__$func\($parameter\)__/$value/g; }