mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-23 20:22:05 +00:00
modify genesis test code
This commit is contained in:
parent
360a71c8c1
commit
bc48e85205
@ -1,48 +1,29 @@
|
||||
start:nodeset_shell
|
||||
description: verify could log in genesis shell
|
||||
cmd:nodeset $$CN shell
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g
|
||||
check:rc==0
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -s
|
||||
check:rc==0
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN
|
||||
cmd:xdsh $$CN cat /proc/cmdline
|
||||
check:rc==0
|
||||
check:output=~destiny=shell
|
||||
cmd:nodeset $$CN boot
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
start:nodeset_cmdline
|
||||
description:verify could run cmdline successfully
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -d -r __GETNODEATTR($$CN,arch)__
|
||||
cmd:nodeset $$CN runcmd="cmdtest,shell"
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g
|
||||
check:rc==0
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -d
|
||||
check:rc==0
|
||||
cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN
|
||||
cmd:xdsh $$CN "cat /tmp/testresult"
|
||||
check:rc==0
|
||||
check:output=~testcmd
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__
|
||||
check:rc==0
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
start:nodeset_runimg
|
||||
description:verify runimg could work
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -g -n $$CN -i $$imgip
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g
|
||||
check:rc==0
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -i
|
||||
check:rc==0
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN
|
||||
check:rc==0
|
||||
cmd:xdsh $$CN "cat /tmp/testresult"
|
||||
check:output=~testimg
|
||||
check:rc==0
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__
|
||||
check:rc==0
|
||||
cmd:rpower $$CN boot
|
||||
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c
|
||||
check:rc==0
|
||||
end
|
||||
|
@ -1,6 +1,11 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use xCAT::Utils;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
@ -10,182 +15,357 @@ use Time::Local;
|
||||
use File::Basename;
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
my $rungenesiscmd = 0;
|
||||
my $rungenesisimg = 0;
|
||||
my $shellmode = 0;
|
||||
my $cmdtest = "/tmp/cmdtest";
|
||||
my $timesleep = 0;
|
||||
use Sys::Hostname;
|
||||
my $program_name = basename("$0");
|
||||
my $genesis_runcmd_test = 0;
|
||||
my $genesis_runimg_test = 0;
|
||||
my $genesis_nodesetshell_test = 0;
|
||||
my $check_genesis_file;
|
||||
my $noderange;
|
||||
my $clearenv = 0;
|
||||
my $arch;
|
||||
my $imgip;
|
||||
my $runimgtest = "/tmp/imgtest";
|
||||
my $testresult = "/tmp/testresult";
|
||||
my $genesisdir = "/opt/xcat/share/xcat/netboot/genesis";
|
||||
my $genesisfiledir;
|
||||
|
||||
my $clear_env;
|
||||
my $help = 0;
|
||||
$::USAGE = "Usage:
|
||||
$program_name -h
|
||||
$program_name -n <node_range> -s
|
||||
$program_name -n <node_range> -d
|
||||
$program_name -n <node_range> -i
|
||||
$program_name -n <node_range> -c
|
||||
$program_name -n <node_range> -g
|
||||
Description:
|
||||
Run genesis testcase
|
||||
There will be default scripts for genesis's runcmd and runimg test if anyone want to use this function to test genesis please write scripts in /tmp/cmdtest for runcmd test and in /tmp/imgtest for runimg test
|
||||
Options:
|
||||
-n : The range of node
|
||||
-i : Run genesis runimage
|
||||
-d : Run genesis runcmd
|
||||
-s : Run genesis nodeshell mode
|
||||
-c : Clear genesis test environment
|
||||
-g : Check genesis file
|
||||
";
|
||||
##################################
|
||||
# main process
|
||||
##################################
|
||||
if (
|
||||
!GetOptions("h|?" => \$::HELP,
|
||||
"d" => \$rungenesiscmd,
|
||||
"g" => \$rungenesisimg,
|
||||
"t" => \$timesleep,
|
||||
"c" => \$clearenv,
|
||||
"n=s" => \$::NODE,
|
||||
"i=s" => \$::IMGIP,
|
||||
"r=s" => \$::ARCH)
|
||||
)
|
||||
!GetOptions("h|?" => \$help,
|
||||
"s" => \$genesis_nodesetshell_test,
|
||||
"d" => \$genesis_runcmd_test,
|
||||
"i" => \$genesis_runimg_test,
|
||||
"n=s" => \$noderange,
|
||||
"g" => \$check_genesis_file,
|
||||
"c" => \$clear_env
|
||||
))
|
||||
{
|
||||
&usage;
|
||||
send_msg(0, "$::USAGE");
|
||||
print "$::USAGE";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "Usage:run for genesis cases.\n";
|
||||
print " genesistest.pl [-?|-h]\n";
|
||||
print " genesistest.pl [-d] [-n node] [-r arch] Test runcmd for genesis \n";
|
||||
print " genesistest.pl [-g] [-n ndoe] [-i imgip] Test runimg for genesis\n";
|
||||
print " genesistest.pl [-t] [-n node] Sleep for genesis test\n";
|
||||
print " genesistest.pl [-c] [-n node][-r arch] Clear environment for genesis test\n";
|
||||
print "\n";
|
||||
return;
|
||||
if ($help) {
|
||||
print "$::USAGE";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
sub runcmd
|
||||
{
|
||||
my ($cmd) = @_;
|
||||
my $rc = 0;
|
||||
$::RUNCMD_RC = 0;
|
||||
my $outref = [];
|
||||
@$outref = `$cmd 2>&1`;
|
||||
if ($?)
|
||||
{
|
||||
$rc = $?;
|
||||
$rc = $rc >> 8;
|
||||
$::RUNCMD_RC = $rc;
|
||||
}
|
||||
chomp(@$outref);
|
||||
return @$outref;
|
||||
|
||||
###############################
|
||||
# init
|
||||
##############################
|
||||
if (!defined($noderange)) {
|
||||
send_msg(0, "Option -n is required");
|
||||
print "$::USAGE";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub rungenesiscmd
|
||||
{
|
||||
open(TESTCMD, ">$cmdtest")
|
||||
or die "Can't open testscripts for writing: $!";
|
||||
print TESTCMD join("\n", "#!/bin/bash"), "\n";
|
||||
print TESTCMD join("\n", "#This is test for genesis scripts"), "\n";
|
||||
print TESTCMD join("\n", "echo \"testcmd\" >> $testresult"), "\n";
|
||||
close(TESTCMD);
|
||||
if ($arch =~ /ppc64/)
|
||||
{
|
||||
$arch = "ppc64";
|
||||
my $os = xCAT::Utils->osver("all");
|
||||
if ($check_genesis_file) {
|
||||
send_msg(2, "[$$]:Check genesis file...............");
|
||||
&check_genesis_file(&get_arch);
|
||||
if ($?) {
|
||||
send_msg(0, "genesis file not available");
|
||||
} else {
|
||||
send_msg(2, "genesis file available");
|
||||
}
|
||||
$genesisfiledir = "$genesisdir/$arch/fs/bin";
|
||||
copy("$cmdtest", "$genesisfiledir");
|
||||
chmod 0755, "$genesisfiledir/cmdtest";
|
||||
}
|
||||
my $master=xCAT::TableUtils->get_site_Master();
|
||||
if (!$master) { $master=hostname(); }
|
||||
|
||||
####################################
|
||||
####nodesetshell test for genesis
|
||||
####################################
|
||||
if ($genesis_nodesetshell_test) {
|
||||
send_msg(2, "[$$]:Running nodesetshell test...............");
|
||||
`nodeset $noderange shell`;
|
||||
if ($?) {
|
||||
send_msg(0, "[$$]:nodeset shell failed...............");
|
||||
exit 1;
|
||||
}
|
||||
`rpower $noderange boot`;
|
||||
if ($?) {
|
||||
send_msg(0, "[$$]:rpower node failed...............");
|
||||
exit 1;
|
||||
}
|
||||
#run nodeshell test
|
||||
send_msg(2, "prepare for nodeshell script.");
|
||||
if ( &testxdsh(3)) {
|
||||
send_msg(0, "[$$]:Could not verify test results using xdsh...............");
|
||||
exit 1;
|
||||
}
|
||||
send_msg(2, "[$$]:Running nodesetshell test success...............");
|
||||
}
|
||||
####################################
|
||||
####runcmd test for genesis
|
||||
####################################
|
||||
if ($genesis_runcmd_test) {
|
||||
send_msg(2, "[$$]:Running runcmd test...............");
|
||||
if (&testxdsh(&rungenesiscmd(&get_arch))) {
|
||||
send_msg(0, "[$$]:Could not verify test results using xdsh...............");
|
||||
exit 1;
|
||||
}
|
||||
send_msg(2, "[$$]:Running runcmd test success...............");
|
||||
}
|
||||
##################################
|
||||
####runimg test for genesis
|
||||
##################################
|
||||
if ($genesis_runimg_test) {
|
||||
send_msg(2, "[$$]:Run runimg test...............");
|
||||
if (&testxdsh(&rungenesisimg)) {
|
||||
send_msg(0, "[$$]:Could not verify test results using xdsh ...............");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
send_msg(2, "[$$]:Running runimage test success...............");
|
||||
}
|
||||
###################################
|
||||
####clear test environment
|
||||
###################################
|
||||
if ($clear_env) {
|
||||
send_msg(2, "[$$]:clear genesis test enviroment...............");
|
||||
if (&clearenv(&get_arch)) {
|
||||
send_msg(0, "[$$]:clear environment failed...............");
|
||||
exit 1;
|
||||
}
|
||||
send_msg(2, "[$$]:clear genesis test enviroment success...............");
|
||||
}
|
||||
##################################
|
||||
#check_genesis_file
|
||||
#################################
|
||||
sub check_genesis_file {
|
||||
my $arch = shift;
|
||||
my $genesis_base;
|
||||
my $genesis_scripts;
|
||||
if ($os =~ "unknown") {
|
||||
send_msg(0, "The OS is not supported.");
|
||||
return 1;
|
||||
} elsif ($os =~ "ubuntu") {
|
||||
$genesis_base = `dpkg -l | grep -i "ii xcat-genesis-base" | grep -i "$arch"`;
|
||||
$genesis_scripts = `dpkg -l | grep -i "ii xcat-genesis-scripts" | grep -i "$arch"`;
|
||||
} else {
|
||||
$genesis_base = `rpm -qa | grep -i "xcat-genesis-base" | grep -i "$arch"`;
|
||||
$genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`;
|
||||
}
|
||||
unless ($genesis_base and $genesis_scripts) {
|
||||
send_msg(0, "xCAT-genesis for $arch did not be installed.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
###################################################
|
||||
###write runcmd script to verify runcmd could work
|
||||
##################################################
|
||||
sub rungenesiscmd {
|
||||
my $runcmd_script = "/tmp/cmdtest";
|
||||
my $result = "/tmp/testresult";
|
||||
my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis";
|
||||
my $genesis_bin_dir;
|
||||
my $value = 0;
|
||||
my $arch = shift;
|
||||
if (!(-e $runcmd_script)) {
|
||||
$value = 1;
|
||||
|
||||
#means runcmd test using test scripts genesistest.pl writes
|
||||
send_msg(2, "no runcmd scripts for test prepared.");
|
||||
open(TESTCMD, ">$runcmd_script")
|
||||
or die "Can't open testscripts for writing: $!";
|
||||
print TESTCMD join("\n", "#!/bin/bash"), "\n";
|
||||
print TESTCMD join("\n", "#This is test for genesis scripts"), "\n";
|
||||
print TESTCMD join("\n", "echo \"testcmd\" >> $result"), "\n";
|
||||
close(TESTCMD);
|
||||
} else {
|
||||
$value = 3;
|
||||
|
||||
#means runcmd test using test scripts user writes
|
||||
send_msg(2, "runcmd scripts for test ready.");
|
||||
}
|
||||
$genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin";
|
||||
copy("$runcmd_script", "$genesis_bin_dir");
|
||||
chmod 0755, "$genesis_bin_dir/cmdtest";
|
||||
`mknb $arch`;
|
||||
print "mknb $arch\n";
|
||||
if ($?) {
|
||||
send_msg(0, "mknb $arch failed for runcmd test.");
|
||||
}
|
||||
`nodeset $noderange "runcmd=cmdtest,shell"`;
|
||||
if ($?) {
|
||||
send_msg(0, "nodeset noderange shell failed for runcmd test");
|
||||
}
|
||||
`rpower $noderange boot`;
|
||||
if ($?) {
|
||||
send_msg(0, "rpower noderange boot failed for runcmd test");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub rungenesisimg
|
||||
{
|
||||
#######################################################################################################################
|
||||
####write runimage script to verify runimage could work eg.runimage=http://<IP of xCAT Management Node>/<dir>/image.tgz
|
||||
#######################################################################################################################
|
||||
sub rungenesisimg {
|
||||
my $runimg_script = "/tmp/imgtest";
|
||||
my $result = "/tmp/testresult";
|
||||
my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis";
|
||||
my $genesis_bin_dir;
|
||||
my $value = 0;
|
||||
mkdir("/install/my_image");
|
||||
open(TESTIMG, ">$runimgtest")
|
||||
or die "Can't open testscripts for writing: $!";
|
||||
print TESTIMG join("\n", "#!/bin/bash"), "\n";
|
||||
print TESTIMG join("\n", "#This is test for genesis scripts"), "\n";
|
||||
print TESTIMG join("\n", "echo \"testimg\" >> $testresult"), "\n";
|
||||
close(TESTIMG);
|
||||
copy("$runimgtest", "/install/my_image/runme.sh") or die "Copy failed: $!";
|
||||
if (!(-e $runimg_script)) {
|
||||
$value = 2;
|
||||
|
||||
#means runimg test using test scripts genesistest.pl writes
|
||||
send_msg(2, "no runimg scripts for test prepared.");
|
||||
open(TESTIMG, ">$runimg_script")
|
||||
or die "Can't open testscripts for writing: $!";
|
||||
print TESTIMG join("\n", "#!/bin/bash"), "\n";
|
||||
print TESTIMG join("\n", "#This is test for genesis scripts"), "\n";
|
||||
print TESTIMG join("\n", "echo \"testimg\" >> $result"), "\n";
|
||||
close(TESTIMG);
|
||||
print "value is $value \n";
|
||||
} else {
|
||||
$value = 3;
|
||||
|
||||
#means runimg test using test scripts user writes
|
||||
send_msg(2, "runimg scripts for test ready.");
|
||||
}
|
||||
copy("$runimg_script", "/install/my_image/runme.sh") or die "Copy failed: $!";
|
||||
chmod 0755, "/install/my_image/runme.sh";
|
||||
`cd /install/my_image ;tar -zcvf my_image.tgz .`;
|
||||
`nodeset $noderange "runimage=http://$imgip/install/my_image/my_image.tgz",shell`;
|
||||
`tar -zcvf /tmp/my_image.tgz -C /install/my_image .`;
|
||||
copy("/tmp/my_image.tgz", "/install/my_image") or die "Copy failed: $!";
|
||||
`nodeset $noderange "runimage=http://$master/install/my_image/my_image.tgz",shell`;
|
||||
if ($?) {
|
||||
send_msg(0, "nodeset noderange failed for runimg");
|
||||
}
|
||||
`rpower $noderange boot`;
|
||||
if ($?) {
|
||||
send_msg(0, "rpower boot failed for runimg test");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub timesleep
|
||||
{
|
||||
my @output = runcmd("ping $noderange -c 10");
|
||||
my $value = 0;
|
||||
print "output is $value ,@output\n";
|
||||
if ($::RUNCMD_RC) {
|
||||
foreach $value (1 .. 60) {
|
||||
@output = runcmd("ping $noderange -c 10");
|
||||
last if ($::RUNCMD_RC == 0);
|
||||
########################################
|
||||
####sleep while for xdsh $$CN could work
|
||||
#########################################
|
||||
sub testxdsh {
|
||||
my $value = shift;
|
||||
print "value is $value \n";
|
||||
my $checkstring;
|
||||
my $checkfile;
|
||||
if ($value == 1) {
|
||||
#mean runcmd test using test scripts genesistest.pl writes
|
||||
$checkstring = "testcmd";
|
||||
$checkfile = "/tmp/testresult";
|
||||
} elsif ($value == 2) {
|
||||
$checkstring = "testimg";
|
||||
$checkfile = "/tmp/testresult";
|
||||
} elsif ($value == 3) {
|
||||
$checkstring = "xcatd=$master:3001";
|
||||
$checkfile = "/proc/cmdline";
|
||||
}
|
||||
if (($value == 1) || ($value == 2) || ($value == 3)) {
|
||||
`xdsh $noderange -t 2 cat $checkfile |grep $checkstring`;
|
||||
if ($?) {
|
||||
foreach (1 .. 1500) {
|
||||
`xdsh $noderange -t 2 cat $checkfile | grep $checkstring`;
|
||||
last if ($? == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
my @output1 = runcmd("xdsh $noderange date");
|
||||
if ($::RUNCMD_RC) {
|
||||
foreach $value (1 .. 60) {
|
||||
@output1 = runcmd("xdsh $noderange -t 1 date");
|
||||
print "sleep $value\n";
|
||||
last if ($::RUNCMD_RC == 0);
|
||||
}
|
||||
}
|
||||
if ($::RUNCMD_RC == 0) {
|
||||
print "test ok\n";
|
||||
}
|
||||
return $?;
|
||||
}
|
||||
|
||||
sub clearenv
|
||||
{
|
||||
if (-f "/tmp/imgtest") {
|
||||
unlink("/install/my_image/runme.sh");
|
||||
unlink("/install/my_image/my_image.tgz");
|
||||
unlink("$runimgtest");
|
||||
rmdir("/install/my_image");
|
||||
print "img del ok\n";
|
||||
##########################
|
||||
####clear test environment
|
||||
##########################
|
||||
sub clearenv {
|
||||
my $arch = shift;
|
||||
my $runcmd_script = "/tmp/cmdtest";
|
||||
my $runimg_script = "/tmp/imgtest";
|
||||
my $runme = "/install/my_image/runme.sh";
|
||||
my $runmetar = "/install/my_image/my_image.tgz";
|
||||
my $runmetar_tmp = "/tmp/my_image.tgz";
|
||||
my $runmedir = "/install/my_image";
|
||||
my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis";
|
||||
if (-e "$runimg_script") {
|
||||
unlink("$runme");
|
||||
unlink("$runmetar_tmp");
|
||||
unlink("$runmetar");
|
||||
unlink("$runimg_script");
|
||||
rmdir("$runmedir");
|
||||
send_msg(2, "clear runimage test environment");
|
||||
}
|
||||
if (-f "/tmp/cmdtest") {
|
||||
if ($arch =~ /ppc64/)
|
||||
{
|
||||
$arch = "ppc64";
|
||||
}
|
||||
|
||||
$genesisfiledir = "$genesisdir/$arch/fs/bin";
|
||||
my $genesisfile = "$genesisfiledir/cmdtest";
|
||||
print "genesis file is $genesisfile\n";
|
||||
unlink("$genesisfile");
|
||||
unlink("$cmdtest");
|
||||
if (-e "$runcmd_script") {
|
||||
my $genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin";
|
||||
my $genesis_test_script = "$genesis_bin_dir/cmdtest";
|
||||
unlink("$genesis_test_script");
|
||||
unlink("$runcmd_script");
|
||||
`mknb $arch`;
|
||||
print "mknb $arch\n";
|
||||
if ($?) {
|
||||
send_msg(0, "mknb for runcmd test environment failed");
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
`nodeset $noderange boot`;
|
||||
if ($?) {
|
||||
send_msg(0, "nodeset node failed");
|
||||
exit 1;
|
||||
}
|
||||
`rpower $noderange boot`;
|
||||
if ($?) {
|
||||
send_msg(0, "rpower node failed");
|
||||
exit 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if ($::NODE)
|
||||
{
|
||||
$noderange = $::NODE;
|
||||
####################################
|
||||
#get arch
|
||||
###################################
|
||||
sub get_arch {
|
||||
use POSIX qw(uname);
|
||||
my @uname = uname();
|
||||
my $arch = $uname[4];
|
||||
if ($arch =~ /ppc64/i) {
|
||||
$arch = "ppc64";
|
||||
} elsif (($arch =~ /x86/i)&&($os =~ /ubuntu/i)) {
|
||||
if ($check_genesis_file) {
|
||||
$arch = "amd64";
|
||||
}
|
||||
}
|
||||
return $arch;
|
||||
}
|
||||
if ($::ARCH)
|
||||
{
|
||||
$arch = $::ARCH;
|
||||
}
|
||||
if ($::IMGIP)
|
||||
{
|
||||
$imgip = $::IMGIP;
|
||||
}
|
||||
if ($::HELP) {
|
||||
usage;
|
||||
}
|
||||
if ($rungenesiscmd)
|
||||
{
|
||||
&rungenesiscmd;
|
||||
}
|
||||
if ($timesleep)
|
||||
{
|
||||
×leep;
|
||||
}
|
||||
if ($rungenesisimg)
|
||||
{
|
||||
&rungenesisimg;
|
||||
}
|
||||
if ($clearenv)
|
||||
{
|
||||
&clearenv;
|
||||
#######################################
|
||||
## send messages
|
||||
########################################
|
||||
sub send_msg {
|
||||
my $log_level = shift;
|
||||
my $msg = shift;
|
||||
my $content;
|
||||
my $logfile = "";
|
||||
my $logfiledir = "/tmp/genesistestlog";
|
||||
my $date = `date +"%Y%m%d"`;
|
||||
chomp($date);
|
||||
if (!-e $logfiledir)
|
||||
{
|
||||
mkpath( $logfiledir );
|
||||
}
|
||||
$logfile = "genesis" . $date . ".log";
|
||||
if ($log_level == 0) {
|
||||
$content = "Fatal error:";
|
||||
} elsif ($log_level == 1) {
|
||||
$content = "Warning:";
|
||||
} elsif ($log_level == 2) {
|
||||
$content = "Notice:";
|
||||
}
|
||||
if (!open(LOGFILE, ">> $logfiledir/$logfile")) {
|
||||
return 1;
|
||||
}
|
||||
print LOGFILE "$date $$ $content $msg\n";
|
||||
close LOGFILE;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user