From 754b22c7106c593fcd49e2b61310927057e2a5af Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 2 Jul 2015 03:29:44 -0400 Subject: [PATCH] enhance mknb -c command --- xCAT-server/lib/xcat/plugins/mknb.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mknb.pm b/xCAT-server/lib/xcat/plugins/mknb.pm index 400b5943d..8f2a9be2d 100644 --- a/xCAT-server/lib/xcat/plugins/mknb.pm +++ b/xCAT-server/lib/xcat/plugins/mknb.pm @@ -19,6 +19,7 @@ sub process_request { my $serialport; my $serialspeed; my $serialflow; + my $initrd_file = undef; my $xcatdport = 3001; #if ($sitetab) { #my $portent = $sitetab->getAttribs({key=>'defserialport'},'value'); @@ -130,7 +131,6 @@ sub process_request { system("ssh-keygen -t rsa -f $tempdir/etc/ssh_host_rsa_key -C '' -N ''"); system("ssh-keygen -t dsa -f $tempdir/etc/ssh_host_dsa_key -C '' -N ''"); } - my $initrd_file = undef; my $lzma_exit_value=1; if ($invisibletouch) { my $done=0; @@ -164,6 +164,22 @@ sub process_request { } CREAT_CONF_FILE: + if ($configfileonly) { + unless (-e "$tftpdir/xcat/genesis.kernel.$arch") { + $callback->({error=>["No kernel file found in $tftpdir/xcat, pls run \"mknb $arch\" instead."],errorcode=>[1]}); + return; + } + if (-e "$tftpdir/xcat/genesis.fs.$arch.lzma") { + $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.lzma"; + } elsif (-e "$tftpdir/xcat/genesis.fs.$arch.gz") { + $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.gz"; + } elsif (-e "$tftpdir/xcat/nbfs.$arch.gz") { + $initrd_file = "$tftpdir/xcat/nbfs.$arch.gz"; + } else { + $callback->({error=>["No filesystem file found in $tftpdir/xcat, pls run \"mknb $arch\" instead."],errorcode=>[1]}); + return; + } + } my $hexnets = xCAT::NetworkUtils->my_hexnets(); my $normnets = xCAT::NetworkUtils->my_nets(); my $consolecmdline; @@ -305,7 +321,6 @@ CREAT_CONF_FILE: close($cfgfile); } } - if ($configfileonly) { $callback->({data=>["Write netboot config file done"]}); }