From ef724b0e6fd7bdfea20f8746db33065f677aecf9 Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 14 Jun 2016 01:52:17 -0400 Subject: [PATCH] Improve the error message for getadapter command 1. Add allow policy for getadapter 2. enhance the error message for different mgt when running getadapter partial-issue: #1174 --- xCAT-server/lib/xcat/plugins/getadapter.pm | 28 +++++++++++++++++++--- xCAT-server/sbin/xcatconfig | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/getadapter.pm b/xCAT-server/lib/xcat/plugins/getadapter.pm index b977088c7..5e73b4107 100644 --- a/xCAT-server/lib/xcat/plugins/getadapter.pm +++ b/xCAT-server/lib/xcat/plugins/getadapter.pm @@ -310,9 +310,10 @@ sub deploy_genesis { }, $subreq, 0, 1); if ($::RUNCMD_RC != 0) { - $callback->({ error => "failed to run command: nodeset $node rumcmd=getadapter", errorcode => 1 }); + $callback->({ error => "failed to run command: nodeset $node runcmd=getadapter", errorcode => 1 }); return 1; } + # TODO: use rinstall to replace the following code when rinstall is ready. if ($node_desc_ptr->{mgt} eq "ipmi") { $outref = xCAT::Utils->runxcmd( { @@ -325,7 +326,6 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rsetboot $node net", errorcode => 1 }); return 1; } - $outref = xCAT::Utils->runxcmd( { command => ['rpower'], @@ -337,7 +337,19 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rpower $node reset", errorcode => 1 }); return 1; } - } else { + } elsif ($node_desc_ptr->{mgt} eq "kvm") { + $outref = xCAT::Utils->runxcmd( + { + command => ['rpower'], + node => ["$node"], + arg => ['reset'], + }, + $subreq, 0, 1); + if ($::RUNCMD_RC != 0) { + $callback->({ error => "failed to run command: rpower $node reset", errorcode => 1 }); + return 1; + } + } elsif ($node_desc_ptr->{mgt} eq "hmc") { $outref = xCAT::Utils->runxcmd( { command => ["rnetboot"], @@ -348,7 +360,12 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rnetboot $node", errorcode => 1 }); return 1; } + } else { + $callback->({ error => "$node: The mgt configuration is not supported by getadapter.", + errorcode => 1 }); + return 1; } + $callback->({data=>"$node: Booting into genesis, this could take several minutes..."}); return 0; }; # end of child_process_func @@ -476,6 +493,11 @@ sub update_adapter_result { $output .= "\n"; } $callback->({ data => "$output" }); + if (!$has_nic) { + $callback->({ data => "$node: Couldn't find interface name information detected by udevadm," + ." the nics table will not be updated." }); + return 0; + } my $nics_table = xCAT::Table->new('nics'); unless ($nics_table) { xCAT::MsgUtils->message("S", "Unable to open nics table, denying"); diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 099a3e06c..1dc1e8a45 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -1304,6 +1304,8 @@ sub initDB "$::XCATROOT/sbin/chtab priority=4.7 policy.commands=litefile policy.rule=allow;"; $chtabcmds .= "$::XCATROOT/sbin/chtab priority=4.8 policy.commands=litetree policy.rule=allow;"; + $chtabcmds .= + "$::XCATROOT/sbin/chtab priority=4.9 policy.commands=getadapter policy.rule=allow;"; } my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); if ($::RUNCMD_RC != 0)