diff --git a/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst b/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst index 92c8ddda1..25cb6d2fe 100644 --- a/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst +++ b/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst @@ -23,11 +23,11 @@ SYNOPSIS \ **bmcdiscover**\ [\ **-v | -**\ **-version**\ ] -\ **bmcdiscover**\ [\ **-s**\ \ *scan_method*\ ] \ **-**\ **-range**\ \ *ip_ranges*\ [\ **-z**\ ] [\ **-w**\ ] [\ **-t**\ ] +\ **bmcdiscover**\ [\ **-s**\ \ *scan_method*\ ] [\ **-u**\ \ *bmc_user*\ ] [\ **-p**\ \ *bmc_passwd*\ ] [\ **-z**\ ] [\ **-w**\ ] [\ **-t**\ ] \ **-**\ **-range**\ \ *ip_ranges*\ -\ **bmcdiscover**\ {\ **-i | -**\ **-bmcip**\ } \ *bmc_ip*\ {\ **-u | -**\ **-bmcuser**\ } \ *bmc_username*\ {\ **-p | -**\ **-bmcpasswd**\ } \ *bmc_password*\ \ **-**\ **-check**\ +\ **bmcdiscover**\ \ **-u**\ \ *bmc_user*\ \ **-p**\ \ *bmc_passwd*\ \ **-i**\ \ *bmc_ip*\ \ **-**\ **-check**\ -\ **bmcdiscover**\ {\ **-i | -**\ **-bmcip**\ } \ *bmc_ip*\ {\ **-u | -**\ **-bmcuser**\ } \ *bmc_username*\ {\ **-p | -**\ **-bmcpasswd**\ } \ *bmc_password*\ \ **-**\ **-ipsource**\ +\ **bmcdiscover**\ [\ **-u**\ \ *bmc_user*\ ] [\ **-p**\ \ *bmc_passwd*\ ] \ **-i**\ \ *bmc_ip*\ \ **-**\ **-ipsource**\ *********** @@ -100,13 +100,13 @@ OPTIONS \ **-c|-**\ **-check**\ - Check + Check BMC administrator User/Password. \ **-**\ **-ipsource**\ - BMC IP source + Display the BMC IP configuration. diff --git a/xCAT-client/pods/man1/bmcdiscover.1.pod b/xCAT-client/pods/man1/bmcdiscover.1.pod index f63a9edb2..ad0f3ed55 100644 --- a/xCAT-client/pods/man1/bmcdiscover.1.pod +++ b/xCAT-client/pods/man1/bmcdiscover.1.pod @@ -8,11 +8,11 @@ B [B<-?>|B<-h>|B<--help>] B [B<-v>|B<--version>] -B [B<-s> I] B<--range> I [B<-z>] [B<-w>] [B<-t>] +B [B<-s> I] [B<-u> I] [B<-p> I] [B<-z>] [B<-w>] [B<-t>] B<--range> I -B {B<-i>|B<--bmcip>} I {B<-u>|B<--bmcuser>} I {B<-p>|B<--bmcpasswd>} I B<--check> +B B<-u> I B<-p> I B<-i> I B<--check> -B {B<-i>|B<--bmcip>} I {B<-u>|B<--bmcuser>} I {B<-p>|B<--bmcpasswd>} I B<--ipsource> +B [B<-u> I] [B<-p> I] B<-i> I B<--ipsource> =head1 DESCRIPTION @@ -63,11 +63,11 @@ BMC user password. =item B<-c|--check> -Check +Check BMC administrator User/Password. =item B<--ipsource> -BMC IP source +Display the BMC IP configuration. =item B<-h|--help> diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index c76f9347c..5b96a7a10 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -113,9 +113,13 @@ sub bmcdiscovery_usage { push @{ $rsp->{data} }, "Usage:"; push @{ $rsp->{data} }, "\tbmcdiscover [-?|-h|--help]"; push @{ $rsp->{data} }, "\tbmcdiscover [-v|--version]"; - push @{ $rsp->{data} }, "\tbmcdiscover [-s scan_method] --range ip_range [-z] [-w] [-t]"; - push @{ $rsp->{data} }, "\tbmcdiscover {-i|--bmcip} bmc_ip {-u|--bmcuser} bmc_user {-p|--bmcpasswd} bmc_password --check"; - push @{ $rsp->{data} }, "\tbmcdiscover {-i|--bmcip} bmc_ip {-u|--bmcuser} bmc_user {-p|--bmcpasswd} bmc_password --ipsource"; + push @{ $rsp->{data} }, "\tbmcdiscover [-s scan_method] [-u bmc_user] [-p bmc_passwd] [-z] [-w] [-t] --range ip_range\n"; + + push @{ $rsp->{data} }, "\tCheck BMC administrator User/Password:\n"; + push @{ $rsp->{data} }, "\t\tbmcdiscover -u bmc_user -p bmc_password -i bmc_ip --check\n"; + + push @{ $rsp->{data} }, "\tDisplay the BMC IP configuration:\n"; + push @{ $rsp->{data} }, "\t\tbmcdiscover [-u bmc_user] [-p bmc_passwd] -i bmc_ip --ipsource"; xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK ); return 0; @@ -197,43 +201,43 @@ sub bmcdiscovery_processargs { return 1; } + # + # Get the default bmc account from passwd table + # + ($bmc_user, $bmc_pass) = bmcaccount_from_passwd(); + # overwrite the default user/pass with what is passed in + if ($::opt_P) { + $bmc_pass = $::opt_P; + if ($::opt_U) { + $bmc_user = $::opt_U; + } + } + ######################################### # Option -s -r should be together ###################################### if ( defined($::opt_R) ) { - - ###################################### - # check if there is nmap or not - ###################################### - if ( -x '/usr/bin/nmap' ) - { - $nmap_path="/usr/bin/nmap"; - } - elsif ( -x '/usr/local/bin/nmap' ) - { - $nmap_path="/usr/local/bin/nmap"; - } - else - { - my $rsp; - push @{ $rsp->{data} }, "\tThere is no nmap in /usr/bin/ or /usr/local/bin/. \n "; - xCAT::MsgUtils->message( "E", $rsp, $::CALLBACK ); - return 1; - - } - ($bmc_user, $bmc_pass) = bmcaccount_from_passwd(); - if ($::opt_P) { - $bmc_pass = $::opt_P; - if (!$::opt_U) { - $bmc_user = ''; - } else { - $bmc_user = $::opt_U; - } - } - scan_process($::opt_M,$::opt_R,$::opt_Z,$::opt_W,$request_command); - - return 0; + ###################################### + # check if there is nmap or not + ###################################### + if ( -x '/usr/bin/nmap' ) + { + $nmap_path="/usr/bin/nmap"; + } + elsif ( -x '/usr/local/bin/nmap' ) + { + $nmap_path="/usr/local/bin/nmap"; + } + else + { + my $rsp; + push @{ $rsp->{data} }, "\tThere is no nmap in /usr/bin/ or /usr/local/bin/. \n "; + xCAT::MsgUtils->message( "E", $rsp, $::CALLBACK ); + return 1; + } + scan_process($::opt_M,$::opt_R,$::opt_Z,$::opt_W,$request_command); + return 0; } if ( defined($::opt_C) && defined($::opt_S) ) { @@ -244,19 +248,20 @@ sub bmcdiscovery_processargs { return 2; } - #################################################### - # --check option, requires -i and -p to be specified - #################################################### + ######################################################### + # --check option, requires -i, -u, and -p to be specified + ######################################################### if ( defined($::opt_C) ) { - if ( defined($::opt_P) && defined($::opt_I) ) { - my $option_u = defined $::opt_U ? $::opt_U : "none"; - my $res=check_auth_process($::opt_I,$option_u,$::opt_P); + if ( defined($::opt_P) && defined($::opt_U) && defined($::opt_I) ) { + my $res=check_auth_process($::opt_I,$::opt_U,$::opt_P); return $res; } else { my $msg = ""; if (!defined($::opt_I)) { $msg = "The check option requires a BMC IP. Specify the IP using the -i|--bmcip option."; + } elsif (!defined($::opt_U)) { + $msg = "The check option requires a user. Specify the user with the -u|--bmcuser option."; } elsif (!defined($::opt_P)) { $msg = "The check option requires a password. Specify the password with the -p|--bmcpasswd option."; } @@ -271,9 +276,8 @@ sub bmcdiscovery_processargs { # --ipsource option, requires -i, -p to be specified #################################################### if ( defined($::opt_S) ) { - if ( defined($::opt_P) && defined($::opt_I) ) { - my $option_u = defined $::opt_U ? $::opt_U : "none"; - my $res=get_bmc_ip_source($::opt_I,$option_u,$::opt_P); + if ( defined($bmc_user) && defined($bmc_pass) && defined($::opt_I) ) { + my $res=get_bmc_ip_source($::opt_I,$bmc_user,$bmc_pass); return $res; } else { @@ -884,23 +888,25 @@ sub bmcdiscovery_ipmi { $node =~ s/(.*)/\L$1/g; } } elsif ($output =~ /error : unauthorized name/){ - xCAT::MsgUtils->message("I", {data=>["Warning: bmc username is incorrect for $node"]}, $::CALLBACK); + xCAT::MsgUtils->message("E", {data=>["BMC username is incorrect for $node"]}, $::CALLBACK); + return 1; } elsif ($output =~ /RAKP \S* \S* is invalid/) { - xCAT::MsgUtils->message("I", {data=>["Warning: bmc password is incorrect for $node"]}, $::CALLBACK); + xCAT::MsgUtils->message("E", {data=>["BMC password is incorrect for $node"]}, $::CALLBACK); + return 1; } - if ( defined($opz) || defined($opw) ) - { - format_stanza($node, $ip); - if (defined($opw)) - { - write_to_xcatdb($node, $ip,$request_command); - } - } - else{ - my $rsp = {}; - push @{ $rsp->{data} }, "$ip"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + if ( defined($opz) || defined($opw) ) + { + format_stanza($node, $ip); + if (defined($opw)) + { + write_to_xcatdb($node, $ip,$request_command); + } + } + else{ + my $rsp = {}; + push @{ $rsp->{data} }, "$ip"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } } }