2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

Merge pull request #301 from zet809/bmcdiscovery_add_flag_t

add flag -t for bmcdiscovery to generate a temp bmc node
This commit is contained in:
Xiaopeng Wang 2015-11-05 16:11:02 +08:00
commit 83e4df505e
6 changed files with 31 additions and 14 deletions

View File

@ -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`;
}

View File

@ -6,7 +6,7 @@ B<bmcdiscover> - Discover bmc using scan method, now scan_method can be nmap.
B<bmcdiscover> [B<-h>|B<--help>] [B<-v>|B<--version>]
B<bmcdiscover> [B<-s> I<scan_method>] B<--range> I<ip_ranges> [B<-z>] [B<-w>]
B<bmcdiscover> [B<-s> I<scan_method>] B<--range> I<ip_ranges> [B<-z>] [B<-w>] [B<-t>]
B<bmcdiscover> B<-i>|B<--bmcip> I<bmc_ip> [B<-u>|B<--bmcuser> I<bmcusername>] B<-p>|B<--bmcpwd> I<bmcpassword> 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.

View File

@ -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;
}

View File

@ -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";

View File

@ -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) {

View File

@ -2354,7 +2354,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};
}
}