From ff7e52b304aa1276e401b823b5e61fcc83be1ffa Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 17 Aug 2017 22:03:57 -0400 Subject: [PATCH 1/3] rspconfig ip to dhcp for openbmc --- xCAT-server/lib/xcat/plugins/openbmc.pm | 45 +++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 00ffa21dc..6aade674d 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -277,6 +277,14 @@ my %status_info = ( RSPCONFIG_SET_RESPONSE => { process => \&rspconfig_response, }, + RSPCONFIG_DHCP_REQUEST => { + method => "POST", + init_url => "$openbmc_project_url/network/action/Reset", + data => "[]", + }, + RSPCONFIG_DHCP_RESPONSE => { + process => \&rspconfig_response, + }, RSPCONFIG_SSHCFG_REQUEST => { method => "GET", init_url => "", @@ -553,7 +561,6 @@ sub parse_args { # # disable function until fully tested # - $check = unsupported($callback); # Check later for each subcommand: if (ref($check) eq "ARRAY") { return $check; } my $setorget; foreach $subcommand (@ARGV) { if ($subcommand =~ /^(\w+)=(.*)/) { @@ -564,9 +571,12 @@ sub parse_args { my $nodes_num = @$noderange; return ([ 1, "Invalid parameter for option $key" ]) unless ($value); - return ([ 1, "Invalid parameter for option $key: $value" ]) unless (xCAT::NetworkUtils->isIpaddr($value)); + return ([ 1, "Invalid parameter for option $key: $value" ]) if ($key != "ip" and !xCAT::NetworkUtils->isIpaddr($value)); if ($key eq "ip") { return ([ 1, "Can not configure more than 1 nodes' ip at the same time" ]) if ($nodes_num >= 2); + if ($value != "dhcp" and !xCAT::NetworkUtils->isIpaddr($value)) { + return ([ 1, "Invalid parameter for option $key: $value" ]); + } } $setorget = "set"; if (ref($check) eq "ARRAY") { return $check; } @@ -791,15 +801,23 @@ sub parse_command_status { } elsif ($subcommand =~ /^(\w+)=(.+)/) { my $key = $1; my $value = $2; - $next_status{LOGIN_RESPONSE} = "RSPCONFIG_SET_REQUEST"; - $next_status{RSPCONFIG_SET_REQUEST} = "RSPCONFIG_SET_RESPONSE"; - $next_status{RSPCONFIG_SET_RESPONSE} = "RSPCONFIG_GET_REQUEST"; - $next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE"; - if ($key eq "ip") { - $status_info{RSPCONFIG_SET_RESPONSE}{ip} = $value; + if ($key eq "ip" and $value eq "dhcp") { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_DHCP_REQUEST"; + $next_status{RSPCONFIG_DHCP_REQUEST} = "RSPCONFIG_DHCP_RESPONSE"; + $next_status{RSPCONFIG_DHCP_RESPONSE} = "RPOWER_BMCREBOOT_REQUEST"; + $next_status{RPOWER_BMCREBOOT_REQUEST} = "RPOWER_RESET_RESPONSE"; + $status_info{RPOWER_RESET_RESPONSE}{argv} = "bmcreboot"; + } else { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_SET_REQUEST"; + $next_status{RSPCONFIG_SET_REQUEST} = "RSPCONFIG_SET_RESPONSE"; + $next_status{RSPCONFIG_SET_RESPONSE} = "RSPCONFIG_GET_REQUEST"; + $next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE"; + if ($key eq "ip") { + $status_info{RSPCONFIG_SET_RESPONSE}{ip} = $value; + } + $status_info{RSPCONFIG_SET_REQUEST}{data} = ""; # wait for interface, ip/netmask/gateway is $value + push @options, $key; } - $status_info{RSPCONFIG_SET_REQUEST}{data} = ""; # wait for interface, ip/netmask/gateway is $value - push @options, $key; } } $status_info{RSPCONFIG_GET_RESPONSE}{argv} = join(",", @options); @@ -1649,6 +1667,13 @@ sub rspconfig_response { xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@output); } + if ($node_info{$node}{cur_status} eq "RSPCONFIG_DHCP_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + xCAT::SvrUtils::sendmsg("DHCP", $callback, $node); + xCAT::SvrUtils::sendmsg("Will reset BMC...", $callback, $node); + } + } + if ($next_status{ $node_info{$node}{cur_status} }) { $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }; gen_send_request($node); From 0dbfef1e017ec5e101c7d244d0fa5860e09ddae0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Sun, 20 Aug 2017 22:33:36 -0400 Subject: [PATCH 2/3] modified depending on comments --- xCAT-server/lib/xcat/plugins/openbmc.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 6aade674d..d6835ab7a 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1669,8 +1669,8 @@ sub rspconfig_response { if ($node_info{$node}{cur_status} eq "RSPCONFIG_DHCP_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("DHCP", $callback, $node); - xCAT::SvrUtils::sendmsg("Will reset BMC...", $callback, $node); + my $bmc_node = "$node BMC"; + xCAT::SvrUtils::sendmsg("Setting IP to DHCP...", $callback, $bmc_node); } } From 337501871f4b4fbeb6dc40c7dcc051c04a0bbfd0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Sun, 20 Aug 2017 22:35:31 -0400 Subject: [PATCH 3/3] modified depending on comments --- xCAT-server/lib/xcat/plugins/openbmc.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index d6835ab7a..e3b70a444 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -561,6 +561,7 @@ sub parse_args { # # disable function until fully tested # + $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } my $setorget; foreach $subcommand (@ARGV) { if ($subcommand =~ /^(\w+)=(.*)/) {