From 067225cfce53f9381d42a1a2c941637a93502883 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 28 Aug 2017 15:45:50 -0400 Subject: [PATCH 1/7] Add code to support display of hostname using rspconfig --- xCAT-server/lib/xcat/plugins/openbmc.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index ad00bb276..865ab75e9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -583,7 +583,7 @@ sub parse_args { } $setorget = "set"; if (ref($check) eq "ARRAY") { return $check; } - } elsif ($subcommand =~ /^ip$|^netmask$|^gateway$|^vlan$/) { + } elsif ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/) { return ([ 1, "Can not configure and display nodes' value at the same time" ]) if ($setorget and $setorget eq "set"); $setorget = "get"; if (ref($check) eq "ARRAY") { return $check; } @@ -794,7 +794,7 @@ sub parse_command_status { if ($command eq "rspconfig") { my @options = (); foreach $subcommand (@$subcommands) { - if ($subcommand =~ /^ip$|^netmask$|^gateway$|^vlan$/) { + if ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/) { $next_status{LOGIN_RESPONSE} = "RSPCONFIG_GET_REQUEST"; $next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE"; push @options, $subcommand; @@ -1615,6 +1615,7 @@ sub rspconfig_response { my $gateway = "n/a"; my $prefix = "n/a"; my $vlan = "n/a"; + my $hostname = ""; my $default_gateway = "n/a"; my $adapter_id = "n/a"; my $error; @@ -1628,6 +1629,9 @@ sub rspconfig_response { if (defined($content{DefaultGateway}) and $content{DefaultGateway}) { $default_gateway = $content{DefaultGateway}; } + if (defined($content{HostName}) and $content{HostName}) { + $hostname = $content{HostName}; + } } @@ -1673,6 +1677,9 @@ sub rspconfig_response { if ($grep_string =~ "vlan") { push @output, "BMC VLAN ID enabled: $vlan"; } + if ($grep_string =~ "hostname") { + push @output, "BMC Hostname: $hostname"; + } } xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@output); From db08fe8fb2ad6f8c061e2b02fcef1765cb8a3214 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 28 Aug 2017 16:47:18 -0400 Subject: [PATCH 2/7] Add support for setting hostname for the BMC --- xCAT-server/lib/xcat/plugins/openbmc.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 865ab75e9..3468a34d5 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -271,9 +271,9 @@ my %status_info = ( process => \&rspconfig_response, }, RSPCONFIG_SET_REQUEST => { - method => "POST", - init_url => "", - data => "", + method => "PUT", + init_url => "$openbmc_project_url/network", + data => "[]", }, RSPCONFIG_SET_RESPONSE => { process => \&rspconfig_response, @@ -570,7 +570,7 @@ sub parse_args { return ([ 1, "Can not configure and display nodes' value at the same time" ]) if ($setorget and $setorget eq "get"); my $key = $1; my $value = $2; - return ([ 1, "Unsupported command: $command $key" ]) unless ($key =~ /^ip$|^netmask$|^gateway$|^vlan$/); + return ([ 1, "Unsupported command: $command $key" ]) unless ($key =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/); my $nodes_num = @$noderange; return ([ 1, "Invalid parameter for option $key" ]) unless ($value); @@ -814,6 +814,16 @@ sub parse_command_status { $next_status{RSPCONFIG_DHCP_RESPONSE} = "RPOWER_BMCREBOOT_REQUEST"; $next_status{RPOWER_BMCREBOOT_REQUEST} = "RPOWER_RESET_RESPONSE"; $status_info{RPOWER_RESET_RESPONSE}{argv} = "bmcreboot"; + } elsif ($key =~ /^hostname$/) { + $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"; + + $status_info{RSPCONFIG_SET_REQUEST}{data} = "$value"; + $status_info{RSPCONFIG_SET_REQUEST}{init_url} .= "/config/attr/HostName"; + push @options, $key; + } else { $next_status{LOGIN_RESPONSE} = "RSPCONFIG_SET_REQUEST"; $next_status{RSPCONFIG_SET_REQUEST} = "RSPCONFIG_SET_RESPONSE"; @@ -1685,6 +1695,11 @@ sub rspconfig_response { xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@output); } + if ($node_info{$node}{cur_status} eq "RSPCONFIG_SET_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + xCAT::SvrUtils::sendmsg("Setting BMC Hostname (requires bmcreboot to take effect)...", $callback, $node); + } + } if ($node_info{$node}{cur_status} eq "RSPCONFIG_DHCP_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { my $bmc_node = "$node BMC"; From 2a36f20fdd61304532049685f4e024a01bfbc075 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 29 Aug 2017 16:29:18 -0400 Subject: [PATCH 3/7] Adding changes to the man pages regarding hostname changing in rspconfig --- .../guides/admin-guides/references/man1/rspconfig.1.rst | 8 +++++++- xCAT-client/pods/man1/rspconfig.1.pod | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index c2a4d365c..038709fe0 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -47,7 +47,7 @@ OpenBMC specific: ================= -\ **rspconfig**\ \ *noderange*\ {\ **ip | netmask | gateway | vlan | sshcfg**\ } +\ **rspconfig**\ \ *noderange*\ {\ **ip | netmask | gateway | hostname | vlan | sshcfg**\ } MPA specific: @@ -394,6 +394,12 @@ OPTIONS +\ **hostname**\ + + Get or set hostname on the service processor. + + + \ **vlan**\ Get or set vlan ID. For get vlan ID, if vlan is not enabled, 'BMC VLAN disabled' will be outputed. For set vlan ID, the valid value are [1-4096]. diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 972aa649b..3f88d1152 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -24,7 +24,7 @@ B I B=I