@@ -233,7 +233,7 @@ my %status_info = (
233
233
234
234
RSPCONFIG_GET_REQUEST => {
235
235
method => " GET" ,
236
- init_url => " " ,
236
+ init_url => " $openbmc_project_url /network/enumerate " ,
237
237
},
238
238
RSPCONFIG_GET_RESPONSE => {
239
239
process => \&rspconfig_response,
@@ -468,7 +468,7 @@ sub parse_args {
468
468
my $noderange = shift ;
469
469
my $check = undef ;
470
470
471
- xCAT::SvrUtils::sendmsg(" [OpenBMC development support] Using this version of xCAT, ensure firware level is at v1.99.6-0-r1, or higher." , $callback );
471
+ xCAT::SvrUtils::sendmsg(" [OpenBMC development support] Using this version of xCAT, ensure firmware level is at v1.99.6-0-r1, or higher." , $callback );
472
472
473
473
my $subcommand = undef ;
474
474
my $verbose = undef ;
@@ -758,9 +758,7 @@ sub parse_command_status {
758
758
push @options , $key ;
759
759
}
760
760
}
761
- $next_status {RSPCONFIG_GET_RESPONSE }{argv } = join (" ," , @options );
762
- xCAT::SvrUtils::sendmsg(" Command $command is not available now!" , $callback );
763
- return 1;
761
+ $status_info {RSPCONFIG_GET_RESPONSE }{argv } = join (" ," , @options );
764
762
}
765
763
766
764
if ($command eq " rvitals" ) {
@@ -1497,24 +1495,68 @@ sub rspconfig_response {
1497
1495
my $response_info = decode_json $response -> content;
1498
1496
1499
1497
if ($node_info {$node }{cur_status } eq " RSPCONFIG_GET_RESPONSE" ) {
1500
- my $grep_string = $status_info {RSPCONFIG_GET_RESPONSE }{argv };
1501
- my $data ;
1498
+ my $address = " n/a" ;
1499
+ my $gateway = " n/a" ;
1500
+ my $prefix = " n/a" ;
1501
+ my $vlan = " n/a" ;
1502
+ my $default_gateway = " n/a" ;
1503
+ my $adapter_id = " n/a" ;
1504
+ my $error ;
1505
+ my $path ;
1502
1506
my @output ;
1503
- if ($grep_string =~ " ip" ) {
1504
- $data = " " ; # got data from response
1505
- push @output , " BMC IP: $data " ;
1506
- }
1507
- if ($grep_string =~ " netmask" ) {
1508
- $data = " " ; # got data from response
1509
- push @output , " BMC Netmask: $data " ;
1510
- }
1511
- if ($grep_string =~ " gateway" ) {
1512
- $data = " " ; # got data from response
1513
- push @output , " BMC Gateway: $data " ;
1507
+ my $grep_string = $status_info {RSPCONFIG_GET_RESPONSE }{argv };
1508
+ foreach my $key_url (keys %{$response_info -> {data }}) {
1509
+ my %content = %{ ${ $response_info -> {data } }{$key_url } };
1510
+
1511
+ if ($key_url =~ / network\/ config/ ) {
1512
+ if (defined ($content {DefaultGateway }) and $content {DefaultGateway }) {
1513
+ $default_gateway = $content {DefaultGateway };
1514
+ }
1515
+ }
1516
+
1517
+
1518
+ ($path , $adapter_id ) = (split (/ ipv4\/ / , $key_url ));
1519
+
1520
+ if ($adapter_id ) {
1521
+ if (defined ($content {Address }) and $content {Address }) {
1522
+ unless ($address =~ / n\/ a/ ) {
1523
+ # We have already processed an entry with adapter information.
1524
+ # This must be a second entry. Display an error. Currently only supporting
1525
+ # an adapter with a single IP address set.
1526
+ $error = " Interfaces with multiple IP addresses are not supported" ;
1527
+ last ;
1528
+ }
1529
+ $address = $content {Address };
1530
+ }
1531
+ if (defined ($content {Gateway }) and $content {Gateway }) {
1532
+ $gateway = $content {Gateway };
1533
+ }
1534
+ if (defined ($content {PrefixLength }) and $content {PrefixLength }) {
1535
+ $prefix = $content {PrefixLength };
1536
+ }
1537
+ }
1514
1538
}
1515
- if ($grep_string =~ " vlan" ) {
1516
- $data = " " ; # got data from response
1517
- push @output , " BMC VLAN ID enabled: $data " ;
1539
+ if ($error ) {
1540
+ # Display error message once, regardless of how many subcommands were specified
1541
+ push @output , $error ;
1542
+ }
1543
+ else {
1544
+ if ($grep_string =~ " ip" ) {
1545
+ push @output , " BMC IP: $address " ;
1546
+ }
1547
+ if ($grep_string =~ " netmask" ) {
1548
+ if ($address ) {
1549
+ my $decimal_mask = (2 ** $prefix - 1) << (32 - $prefix );
1550
+ my $netmask = join (' .' , unpack (" C4" , pack (" N" , $decimal_mask )));
1551
+ push @output , " BMC Netmask: " . $netmask ;
1552
+ }
1553
+ }
1554
+ if ($grep_string =~ " gateway" ) {
1555
+ push @output , " BMC Gateway: $gateway (default: $default_gateway )" ;
1556
+ }
1557
+ if ($grep_string =~ " vlan" ) {
1558
+ push @output , " BMC VLAN ID enabled: $vlan " ;
1559
+ }
1518
1560
}
1519
1561
1520
1562
xCAT::SvrUtils::sendmsg(" $_ " , $callback , $node ) foreach (@output );
0 commit comments