From ae11f1f4fe548b152154806d9c7af7511bd1ff54 Mon Sep 17 00:00:00 2001 From: baiyuan Date: Thu, 23 Oct 2014 05:19:46 -0400 Subject: [PATCH] fix defect 4309 lskitdeployparam -k returns kit plugin bug --- xCAT-server/lib/xcat/plugins/kit.pm | 39 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 94c59d717..e4a94a721 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -4356,20 +4356,35 @@ sub lskitdeployparam { foreach my $kit (@$kits) { my $deployparam_file = $kit->{kitdir}."/other_files/".$kit->{kitdeployparams}; + my $tmpkitdeployparames = $kit->{kitdeployparams}; + if (defined($deployparam_file)) { - open(my $fh, "<", $deployparam_file) || die sprintf("Failed to open file %s because: %s", $deployparam_file, $!); + + # Check if there is kitdeployparam file or not + if (defined($tmpkitdeployparames)) + { + open(my $fh, "<", $deployparam_file) || die sprintf("Failed to open file %s because: %s", $deployparam_file, $!); - while (<$fh>) { - chomp $_; - if ($_ =~ /^#ENV:.+=.+#$/) { - my $tmp = $_; - $tmp =~ s/^#ENV://; - $tmp =~ s/#$//; - (my $name, my $value) = split(/=/, $tmp); - $deployparam_hash->{$name} = $value; - } - } - close($fh); + while (<$fh>) { + chomp $_; + if ($_ =~ /^#ENV:.+=.+#$/) { + my $tmp = $_; + $tmp =~ s/^#ENV://; + $tmp =~ s/#$//; + (my $name, my $value) = split(/=/, $tmp); + $deployparam_hash->{$name} = $value; + } + } + close($fh); + } + else { + my $rsp = {}; + push @{ $rsp->{data}}, "There is no kitdeployparams file in $deployparam_file.\n"; + xCAT::MsgUtils->message("W", $rsp, $::CALLBACK); + + return 1; + } + } }