From 2b259c24e809445ec1d0e01fd91a8e0a3fd93f92 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 19 Dec 2017 20:36:39 -0500 Subject: [PATCH 1/2] rspconfig reset_gard for OpenBMC --- xCAT-server/lib/xcat/plugins/openbmc.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index af4b76991..6b2ce9c9e 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -449,6 +449,14 @@ my %status_info = ( RSPCONFIG_SSHCFG_RESPONSE => { process => \&rspconfig_sshcfg_response, }, + RSPCONFIG_RESET_GARD_REQUEST => { + method => "POST", + init_url => "/org/open_power/control/gard/action/Reset", + data => "[]", + }, + RSPCONFIG_RESET_GARD_RESPONSE => { + process => \&rspconfig_response, + }, RSPCONFIG_DUMP_LIST_REQUEST => { method => "GET", init_url => "$openbmc_project_url/dump/enumerate", @@ -1096,6 +1104,9 @@ sub parse_args { } elsif ($subcommand =~ /^sshcfg$/) { return ([ 1, "Configure sshcfg must be issued without other options." ]) if ($num_subcommand > 1); $setorget = ""; # SSH Keys are copied using a RShellAPI, not REST API + } elsif ($subcommand =~ /^reset_gard$/) { + return ([ 1, "Reset GARD must be issued without other options."]) if ($num_subcommand > 1); + $setorget = ""; } elsif ($subcommand eq "dump") { my $option = ""; $option = $ARGV[1] if (defined $ARGV[1]); @@ -1512,6 +1523,11 @@ sub parse_command_status { $status_info{RSPCONFIG_SET_NTPSERVERS_REQUEST}{data} = "[\"$1\"]"; return 0; } + if ($subcommand eq "reset_gard") { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_RESET_GARD_REQUEST"; + $next_status{RSPCONFIG_RESET_GARD_REQUEST} = "RSPCONFIG_RESET_GARD_RESPONSE"; + return 0; + } } $subcommand = $$subcommands[0]; @@ -3226,6 +3242,12 @@ sub rspconfig_response { return; } + if ($node_info{$node}{cur_status} eq "RSPCONFIG_RESET_GARD_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + xCAT::SvrUtils::sendmsg("GARD reset", $callback, $node); + } + } + if ($next_status{ $node_info{$node}{cur_status} }) { if ($node_info{$node}{cur_status} eq "RSPCONFIG_CHECK_RESPONSE") { $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }{$origin_type}; From 19c13987a1a63af2857977d9b822719505bbd5b5 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 20 Dec 2017 03:31:44 -0500 Subject: [PATCH 2/2] modify command to rspconfig gard -c --- xCAT-server/lib/xcat/plugins/openbmc.pm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 6b2ce9c9e..8f11939ab 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -449,12 +449,12 @@ my %status_info = ( RSPCONFIG_SSHCFG_RESPONSE => { process => \&rspconfig_sshcfg_response, }, - RSPCONFIG_RESET_GARD_REQUEST => { + RSPCONFIG_CLEAR_GARD_REQUEST => { method => "POST", init_url => "/org/open_power/control/gard/action/Reset", data => "[]", }, - RSPCONFIG_RESET_GARD_RESPONSE => { + RSPCONFIG_CLEAR_GARD_RESPONSE => { process => \&rspconfig_response, }, RSPCONFIG_DUMP_LIST_REQUEST => { @@ -1104,9 +1104,13 @@ sub parse_args { } elsif ($subcommand =~ /^sshcfg$/) { return ([ 1, "Configure sshcfg must be issued without other options." ]) if ($num_subcommand > 1); $setorget = ""; # SSH Keys are copied using a RShellAPI, not REST API - } elsif ($subcommand =~ /^reset_gard$/) { - return ([ 1, "Reset GARD must be issued without other options."]) if ($num_subcommand > 1); + } elsif ($subcommand eq "gard") { + my $option = ""; + $option = $ARGV[1] if (defined $ARGV[1]); + return ([ 1, "Clear GARD cannot be issued with other options." ]) if ($num_subcommand > 2); + return ([ 1, "Invalid parameter for $command $subcommand $option" ]) if ($option !~ /^-c$|^--clear$/); $setorget = ""; + return; } elsif ($subcommand eq "dump") { my $option = ""; $option = $ARGV[1] if (defined $ARGV[1]); @@ -1523,11 +1527,6 @@ sub parse_command_status { $status_info{RSPCONFIG_SET_NTPSERVERS_REQUEST}{data} = "[\"$1\"]"; return 0; } - if ($subcommand eq "reset_gard") { - $next_status{LOGIN_RESPONSE} = "RSPCONFIG_RESET_GARD_REQUEST"; - $next_status{RSPCONFIG_RESET_GARD_REQUEST} = "RSPCONFIG_RESET_GARD_RESPONSE"; - return 0; - } } $subcommand = $$subcommands[0]; @@ -1579,6 +1578,10 @@ sub parse_command_status { $next_status{RSPCONFIG_DUMP_DOWNLOAD_REQUEST} = "RSPCONFIG_DUMP_DOWNLOAD_RESPONSE"; } return 0; + } elsif ($subcommand eq "gard") { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_CLEAR_GARD_REQUEST"; + $next_status{RSPCONFIG_CLEAR_GARD_REQUEST} = "RSPCONFIG_CLEAR_GARD_RESPONSE"; + return 0; } if ($subcommand =~ /^admin_passwd=(.+),(.+)/) { @@ -3242,9 +3245,9 @@ sub rspconfig_response { return; } - if ($node_info{$node}{cur_status} eq "RSPCONFIG_RESET_GARD_RESPONSE") { + if ($node_info{$node}{cur_status} eq "RSPCONFIG_CLEAR_GARD_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("GARD reset", $callback, $node); + xCAT::SvrUtils::sendmsg("GARD cleared", $callback, $node); } }