2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 09:50:19 +00:00

Merge pull request #4121 from zet809/rspconfig_ipsrc_ip_for_openbmc

Add ipsrc for rspconfig, fix rspconfig vlan reading
This commit is contained in:
Victor Hu
2017-10-20 14:07:54 -04:00
committed by GitHub
4 changed files with 51 additions and 27 deletions

View File

@ -47,7 +47,7 @@ OpenBMC specific:
=================
\ **rspconfig**\ \ *noderange*\ {\ **ip | netmask | gateway | hostname | vlan | sshcfg**\ }
\ **rspconfig**\ \ *noderange*\ {\ **ipsrc | ip | netmask | gateway | hostname | vlan | sshcfg**\ }
MPA specific:
@ -406,9 +406,15 @@ OPTIONS
\ **ipsrc**\
Get the IP source for OpenBMC.
\ **ip**\
The ip address.
The IP address.

View File

@ -145,7 +145,7 @@ my %usage = (
rspconfig <noderange> [garp=<number of 1/2 second>]
rspconfig <noderange> [userid=<userid> username=<username> password=<password>]
OpenBMC specific:
rspconfig <noderange> [ip|netmask|gateway|hostname|vlan]
rspconfig <noderange> [ipsrc|ip|netmask|gateway|hostname|vlan]
iDataplex specific:
rspconfig <noderange> [thermprofile]
rspconfig <noderange> [thermprofile=<two digit number from chassis>]

View File

@ -24,7 +24,7 @@ B<rspconfig> I<noderange> B<garp>=I<time>
=head2 OpenBMC specific:
B<rspconfig> I<noderange> {B<ip>|B<netmask>|B<gateway>|B<hostname>|B<vlan>|B<sshcfg>}
B<rspconfig> I<noderange> {B<ipsrc>|B<ip>|B<netmask>|B<gateway>|B<hostname>|B<vlan>|B<sshcfg>}
=head2 MPA specific:
@ -308,9 +308,13 @@ Get or set hostname on the service processor.
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].
=item B<ipsrc>
Get the IP source for OpenBMC.
=item B<ip>
The ip address.
The IP address.
=item B<memdecfg>={B<configure | deconfigure>:I<processingunit>:I<unit|bank>:I<id,...>}

View File

@ -681,6 +681,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, "Changing ipsrc value is currently not supported." ]) if ($key eq "ipsrc");
return ([ 1, "Unsupported command: $command $key" ]) unless ($key =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/);
my $nodes_num = @$noderange;
@ -699,7 +700,7 @@ sub parse_args {
unless (($key eq "ip" and $value eq "dhcp") or $key eq "hostname") {
$check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; }
}
} elsif ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/) {
} elsif ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$|^ipsrc$/) {
return ([ 1, "Can not configure and display nodes' value at the same time" ]) if ($setorget and $setorget eq "set");
$setorget = "get";
} elsif ($subcommand =~ /^sshcfg$/) {
@ -928,7 +929,7 @@ sub parse_command_status {
if ($command eq "rspconfig") {
my @options = ();
foreach $subcommand (@$subcommands) {
if ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$/) {
if ($subcommand =~ /^ip$|^netmask$|^gateway$|^hostname$|^vlan$|^ipsrc$/) {
$next_status{LOGIN_RESPONSE} = "RSPCONFIG_GET_REQUEST";
$next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE";
push @options, $subcommand;
@ -1905,10 +1906,11 @@ sub rspconfig_response {
my $address = "n/a";
my $gateway = "n/a";
my $prefix = "n/a";
my $vlan = "n/a";
my $vlan = 0;
my $hostname = "";
my $default_gateway = "n/a";
my $adapter_id = "n/a";
my $ipsrc = "n/a";
my $error;
my $path;
my @output;
@ -1926,8 +1928,8 @@ sub rspconfig_response {
}
($path, $adapter_id) = (split(/ipv4\//, $key_url));
($path, $adapter_id) = (split(/\/ipv4\//, $key_url));
if ($adapter_id) {
if (defined($content{Address}) and $content{Address}) {
unless ($address =~ /n\/a/) {
@ -1945,6 +1947,14 @@ sub rspconfig_response {
if (defined($content{PrefixLength}) and $content{PrefixLength}) {
$prefix = $content{PrefixLength};
}
if (defined($content{Origin})) {
$ipsrc = $content{Origin};
$ipsrc =~ s/^.*\.(\w+)/$1/;
}
if (defined($response_info->{data}->{$path}->{Id})) {
$vlan = $response_info->{data}->{$path}->{Id};
}
}
}
if ($error) {
@ -1952,24 +1962,28 @@ sub rspconfig_response {
push @output, $error;
}
else {
if ($grep_string =~ "ip") {
push @output, "BMC IP: $address";
}
if ($grep_string =~ "netmask") {
if ($address) {
my $decimal_mask = (2 ** $prefix - 1) << (32 - $prefix);
my $netmask = join('.', unpack("C4", pack("N", $decimal_mask)));
push @output, "BMC Netmask: " . $netmask;
foreach my $opt (split /,/,$grep_string) {
if ($opt eq "ip") {
push @output, "BMC IP: $address";
} elsif ($opt eq "ipsrc") {
push @output, "BMC IP Source: $ipsrc";
} elsif ($opt eq "netmask") {
if ($address) {
my $decimal_mask = (2 ** $prefix - 1) << (32 - $prefix);
my $netmask = join('.', unpack("C4", pack("N", $decimal_mask)));
push @output, "BMC Netmask: " . $netmask;
}
} elsif ($opt eq "gateway") {
push @output, "BMC Gateway: $gateway (default: $default_gateway)";
} elsif ($opt eq "vlan") {
if ($vlan) {
push @output, "BMC VLAN ID: $vlan";
} else {
push @output, "BMC VLAN ID: Disabled";
}
} elsif ($opt eq "hostname") {
push @output, "BMC Hostname: $hostname";
}
}
if ($grep_string =~ "gateway") {
push @output, "BMC Gateway: $gateway (default: $default_gateway)";
}
if ($grep_string =~ "vlan") {
push @output, "BMC VLAN ID enabled: $vlan";
}
if ($grep_string =~ "hostname") {
push @output, "BMC Hostname: $hostname";
}
}