From 861164068bb35007fdc1437eda7e6ddaed4b8118 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Fri, 23 Oct 2015 04:16:56 -0400 Subject: [PATCH] add flag -t for bmcdiscovery to generate a temp bmc node --- perl-xCAT/xCAT/Utils.pm | 9 ++++++++- xCAT-client/pods/man1/bmcdiscover.1.pod | 6 +++++- xCAT-server/lib/perl/xCAT/PPC.pm | 5 +---- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 18 ++++++++++++++---- xCAT-server/lib/xcat/plugins/nodediscover.pm | 5 ++--- xCAT-server/sbin/xcatd | 2 +- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 2f5327080..fefc18faa 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4432,7 +4432,14 @@ sub cleanup_for_powerLE_hardware_discovery { } xCAT::MsgUtils->message("S", "Discovery info: configure password for pbmc_node:$pbmc_node."); if (defined($new_bmc_username) and $new_bmc_username ne '') { - `rspconfig $pbmc_node username=$new_bmc_username password=$new_bmc_password`; + if ($new_bmc_username eq "ADMIN" or $new_bmc_username eq 'USERID') { + # ADMIN is username for OpenPOWER server, it is not allowed to modify at present + # USERID is username for IBM system x server, just modify password + `rspconfig $pbmc_node userid=2 password=$new_bmc_password`; + } else { + # For other username, we'd better create new user for them + `rspconfig $pbmc_node userid=3 username=$new_bmc_username password=$new_bmc_password`; + } } else { `rspconfig $pbmc_node password=$new_bmc_password`; } diff --git a/xCAT-client/pods/man1/bmcdiscover.1.pod b/xCAT-client/pods/man1/bmcdiscover.1.pod index c53398774..cc9b36907 100644 --- a/xCAT-client/pods/man1/bmcdiscover.1.pod +++ b/xCAT-client/pods/man1/bmcdiscover.1.pod @@ -6,7 +6,7 @@ B - Discover bmc using scan method, now scan_method can be nmap. B [B<-h>|B<--help>] [B<-v>|B<--version>] -B [B<-s> I] B<--range> I [B<-z>] [B<-w>] +B [B<-s> I] B<--range> I [B<-z>] [B<-w>] [B<-t>] B B<-i>|B<--bmcip> I [B<-u>|B<--bmcuser> I] B<-p>|B<--bmcpwd> I B<-c>|B<--check> @@ -42,6 +42,10 @@ List the stanza formate data. Write to the database. +=item B<-t> + +Genereate a BMC type node object. + =item B<-i|--bmcip> BMC ip. diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index ecea1ddda..9c7c3ba52 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -2193,10 +2193,7 @@ sub process_request { # Deal with findme request #################################### if ($req->{command}->[0] eq 'findme') { - # The arch of the node shall be check first to makesure it is a power machine - if (!defined $req->{'arch'} or $req->{'arch'}->[0] ne 'ppc64') { - return; - } + # Need to support both ppc64 and ppc64le, maybe also x86_64. Will be move out later. &findme($req, $callback, $subreq); return; } diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index b7a88804e..412acee53 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -117,7 +117,7 @@ sub bmcdiscovery_usage { "\n - get BMC IP Address source, DHCP Address or static Address .\n"; push @{ $rsp->{data} }, "\tbmcdiscover [-h|--help|-?]\n"; push @{ $rsp->{data} }, "\tbmcdiscover [-v|--version]\n "; - push @{ $rsp->{data} }, "\tbmcdiscover [-s] scan_method [--range] ip_range [-z] [-w] \n "; + push @{ $rsp->{data} }, "\tbmcdiscover [-s] scan_method [--range] ip_range [-z] [-w] [-t]\n "; push @{ $rsp->{data} }, "\tbmcdiscover [-i|--bmcip] bmc_ip [-u|--bmcuser] bmcusername [-p|--bmcpwd] bmcpassword [-c|--check]\n "; push @{ $rsp->{data} }, "\tbmcdiscover [-i|--bmcip] bmc_ip [-u|--bmcuser] bmcusername [-p|--bmcpwd] bmcpassword [--ipsource]\n "; push @{ $rsp->{data} }, "\tFor example: \n "; @@ -176,6 +176,7 @@ sub bmcdiscovery_processargs { 'bmcpwd|p=s' => \$::opt_P, 'ipsource' => \$::opt_S, 'version|v' => \$::opt_v, + 't' => \$::opt_T, ); if (!$getopt_success) { @@ -593,7 +594,7 @@ sub scan_process{ sub format_stanza { my $node = shift; my $data = shift; - my ($bmcip,$bmcmtm,$bmcserial,$bmcuser,$bmcpass) = split(/,/,$data); + my ($bmcip,$bmcmtm,$bmcserial,$bmcuser,$bmcpass,$nodetype,$hwtype) = split(/,/,$data); my $result; if (defined($bmcip)){ $result .= "$node:\n\tobjtype=node\n"; @@ -613,6 +614,10 @@ sub format_stanza { if ($bmcpass) { $result .= "\tbmcpassword=$bmcpass\n"; } + if ($nodetype && $hwtype) { + $result .= "\tnodetype=$nodetype\n"; + $result .= "\thwtype=$hwtype\n"; + } my $rsp = {}; push @{ $rsp->{data} }, "$result"; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); @@ -631,11 +636,11 @@ sub format_stanza { sub write_to_xcatdb { my $node = shift; my $data = shift; - my ($bmcip,$bmcmtm,$bmcserial,$bmcuser,$bmcpass) = split(/,/,$data); + my ($bmcip,$bmcmtm,$bmcserial,$bmcuser,$bmcpass,$nodetype,$hwtype) = split(/,/,$data); my $request_command = shift; my $ret; - $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$node,"bmc=$bmcip","cons=ipmi","mgt=ipmi","mtm=$bmcmtm","serial=$bmcserial","bmcusername=$bmcuser","bmcpassword=$bmcpass","groups=all"] }, $request_command, 0, 1); + $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$node,"bmc=$bmcip","cons=ipmi","mgt=ipmi","mtm=$bmcmtm","serial=$bmcserial","bmcusername=$bmcuser","bmcpassword=$bmcpass","nodetype=$nodetype","hwtype=$hwtype","groups=all"] }, $request_command, 0, 1); if ($::RUNCMD_RC != 0) { my $rsp = {}; push @{ $rsp->{data} }, "create or modify node is failed.\n"; @@ -886,6 +891,11 @@ sub bmcdiscovery_ipmi { } else { $ip .= ",,$::opt_P"; } + } else { + $ip .= ",,"; + } + if ($::opt_T) { + $ip .= ",mp,bmc"; } if ($mtm and $serial) { $node = "node-$mtm-$serial"; diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 86f582b51..48e8c1e0e 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -358,9 +358,8 @@ sub process_request { $callback->({error=> ["The node [$node] should have a correct IP address which belongs to the management network."], errorcode=>["1"]}); return; } - if ($request->{arch}->[0] =~ /ppc/ and $request->{platform}->[0] =~ /PowerNV/) { - xCAT::Utils->cleanup_for_powerLE_hardware_discovery($request, $doreq); - } + # Other arch such as IBM system x need also to go into this function. + xCAT::Utils->cleanup_for_powerLE_hardware_discovery($request, $doreq); my $restartstring = "restart"; if (scalar @forcenics > 0) { diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index a92c21963..7c972af5a 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -2358,7 +2358,7 @@ sub populate_mp_hash { unless ($mptab) {return;} my @entries = $mptab->getAllAttribs(qw/node nodetype/); foreach (@entries) { - if ($_->{nodetype} and $_->{nodetype} eq 'pbmc') { + if ($_->{nodetype} and $_->{nodetype} eq 'bmc') { $::XCATMPHASH{$_->{node}}=$_->{nodetype}; } }