mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	Clean up the usage and manpage for bmcdiscover
Improve the output message for --ipsource and --check
This commit is contained in:
		| @@ -19,13 +19,13 @@ SYNOPSIS | ||||
| ******** | ||||
|  | ||||
|  | ||||
| \ **bmcdiscover**\  [\ **-h | -**\ **-help**\ ] [\ **-v | -**\ **-version**\ ] | ||||
| \ **bmcdiscover**\  [\ **-?**\ |\ **-h**\ |\ **--help**\ ] | ||||
|  | ||||
| \ **bmcdiscover**\  [\ **-s**\  \ *scan_method*\ ] \ **-**\ **-range**\  \ *ip_ranges*\  [\ **-z**\ ] [\ **-w**\ ] [\ **-t**\ ] | ||||
| \ **bmcdiscover**\  [\ **-v**\ |\ **--version**\ ] | ||||
|  | ||||
| \ **bmcdiscover**\  \ **-i | -**\ **-bmcip**\  \ *bmc_ip*\  [\ **-u | -**\ **-bmcuser**\  \ *bmcusername*\ ] \ **-p | -**\ **-bmcpwd**\  \ *bmcpassword*\  \ **-c | -**\ **-check**\  | ||||
| \ **bmcdiscover**\  [\ **-s**\  \ *scan_method*\ ] \ **--range**\  \ *ip_ranges*\  [\ **-z**\ ] [\ **-w**\ ] [\ **-t**\ ] | ||||
|  | ||||
| \ **bmcdiscover**\  \ **-i | -**\ **-bmcip**\  \ *bmc_ip*\  [\ **-u | -**\ **-bmcuser**\  \ *bmcusername*\ ] \ **-p | -**\ **-bmcpwd**\  \ *bmcpassword*\  \ **-**\ **-ipsource**\  | ||||
| \ **bmcdiscover**\  [\ **-i**\ |\ **--bmcip**\ ] \ *bmc_ip*\  [\ **-u**\ |\ **--bmcuser**\ ] \ *bmcusername*\  [\ **-p**\ |\ **--bmcpwd**\ ] \ *bmcpassword*\  (\ **-c**\ |\ **--check**\ |\ **--ipsource**\ ) | ||||
|  | ||||
|  | ||||
| *********** | ||||
| @@ -56,7 +56,7 @@ OPTIONS | ||||
|  | ||||
| \ **-s**\  | ||||
|   | ||||
|  Scan method  (The only supported scan method at this time is 'nmap') | ||||
|  Scan method  (The only supported scan method at this time is \ **nmap**\ ) | ||||
|   | ||||
|  | ||||
|  | ||||
| @@ -68,7 +68,7 @@ OPTIONS | ||||
|  | ||||
| \ **-w**\  | ||||
|   | ||||
|  Write to the xCAT database | ||||
|  Write to the xCAT database. | ||||
|   | ||||
|  | ||||
|  | ||||
| @@ -80,7 +80,7 @@ OPTIONS | ||||
|  | ||||
| \ **-i|-**\ **-bmcip**\  | ||||
|   | ||||
|  BMC IP | ||||
|  BMC IP address. | ||||
|   | ||||
|  | ||||
|  | ||||
| @@ -136,121 +136,38 @@ EXAMPLES | ||||
| ******** | ||||
|  | ||||
|  | ||||
| 1. To get all bmc from IP range | ||||
| 1. To get all responding BMCs from IP range "10.4.23.100-254" and 50.3.15.1-2": | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   bmcdiscover -s nmap --range "10.4.23.100-254 50.3.15.1-2" | ||||
|      bmcdiscover -s nmap --range "10.4.23.100-254 50.3.15.1-2" | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
| Note: Input for IP range can be in the form: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254. | ||||
|  | ||||
| 2. To get all BMSs in IP range "10.4.22-23.100-254", displayed in xCAT stanza format: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   10.4.23.254 | ||||
|   50.3.15.1 | ||||
|      bmcdiscover -s nmap --range "10.4.22-23.100-254" -z | ||||
|  | ||||
|  | ||||
| Note: input for IP range can also be like scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254. | ||||
|  | ||||
| 2. After discover bmc, list the stanza format data | ||||
|  | ||||
| bmcdiscover -s nmap --range "10.4.22-23.100-254" -z | ||||
|  | ||||
| Output is similar to: | ||||
| 3. Discover the BMCs and write the discovered-node definitions into the xCAT database and write out the stanza foramt to the console: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   node10422254: | ||||
|          objtype=node | ||||
|          groups=all | ||||
|          bmc=10.4.22.254 | ||||
|          cons=ipmi | ||||
|          mgt=ipmi | ||||
|   | ||||
|   node10423254: | ||||
|          objtype=node | ||||
|          groups=all | ||||
|          bmc=10.4.23.254 | ||||
|          cons=ipmi | ||||
|          mgt=ipmi | ||||
|      bmcdiscover -s nmap --range "10.4.22-23.100-254" -w -z | ||||
|  | ||||
|  | ||||
| 3. After discover bmc, write host node definition into the database, and the same time, give out stanza format data | ||||
| 4. To check if the username or password is correct against the BMC: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   bmcdiscover -s nmap --range "10.4.22-23.100-254" -w | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   node10422254: | ||||
|          objtype=node | ||||
|          groups=all | ||||
|          bmc=10.4.22.254 | ||||
|          cons=ipmi | ||||
|          mgt=ipmi | ||||
|   | ||||
|   node10423254: | ||||
|          objtype=node | ||||
|          groups=all | ||||
|          bmc=10.4.23.254 | ||||
|          cons=ipmi | ||||
|          mgt=ipmi | ||||
|  | ||||
|  | ||||
| 4. To check if user name or password is correct or not for bmc | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD -c | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   Correct ADMINISTRATOR | ||||
|   | ||||
|   bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD1 -c | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   Error: Wrong bmc password | ||||
|   | ||||
|   bmcdiscover -i 10.4.23.254 -u USERID1 -p PASSW0RD1 -c | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   Error: Wrong bmc user | ||||
|   | ||||
|   bmcdiscover -i 10.4.23.2541234 -u USERID -p PASSW0RD -c | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   Error: Not bmc | ||||
|      bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD -c | ||||
|  | ||||
|  | ||||
| 5. Get BMC IP Address source, DHCP Address or static Address | ||||
| @@ -258,15 +175,7 @@ Output is similar to: | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD --ipsource | ||||
|  | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  | ||||
| .. code-block:: perl | ||||
|  | ||||
|   Static Address | ||||
|      bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD --ipsource | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -4,13 +4,14 @@ B<bmcdiscover> - Discover Baseboard Management Controllers (BMCs) using a scan m | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|  | ||||
| B<bmcdiscover> [B<-h>|B<--help>] [B<-v>|B<--version>] | ||||
| B<bmcdiscover> [B<-?>|B<-h>|B<--help>] | ||||
|  | ||||
| B<bmcdiscover> [B<-v>|B<--version>] | ||||
|  | ||||
| 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> | ||||
| 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>|B<--ipsource>) | ||||
|  | ||||
| B<bmcdiscover> B<-i>|B<--bmcip> I<bmc_ip> [B<-u>|B<--bmcuser> I<bmcusername>] B<-p>|B<--bmcpwd> I<bmcpassword> B<--ipsource> | ||||
|  | ||||
| =head1 DESCRIPTION | ||||
|  | ||||
| @@ -32,7 +33,7 @@ Specify one or more IP ranges acceptable to nmap.  IP rance can be hostnames, IP | ||||
|  | ||||
| =item B<-s>             | ||||
|  | ||||
| Scan method  (The only supported scan method at this time is 'nmap') | ||||
| Scan method  (The only supported scan method at this time is B<nmap>) | ||||
|  | ||||
| =item B<-z>             | ||||
|  | ||||
| @@ -40,7 +41,7 @@ List the data returned in xCAT stanza format | ||||
|  | ||||
| =item B<-w>             | ||||
|  | ||||
| Write to the xCAT database | ||||
| Write to the xCAT database. | ||||
|  | ||||
| =item B<-t> | ||||
|  | ||||
| @@ -48,7 +49,7 @@ Generate a BMC type node object | ||||
|  | ||||
| =item B<-i|--bmcip>     | ||||
|  | ||||
| BMC IP | ||||
| BMC IP address. | ||||
|  | ||||
| =item B<-u|--bmcuser>   | ||||
|  | ||||
| @@ -84,90 +85,28 @@ Display version information | ||||
|  | ||||
| =head1 EXAMPLES | ||||
|  | ||||
| 1. To get all bmc from IP range | ||||
|  | ||||
|  bmcdiscover -s nmap --range "10.4.23.100-254 50.3.15.1-2" | ||||
| 1. To get all responding BMCs from IP range "10.4.23.100-254" and 50.3.15.1-2": | ||||
|  | ||||
| Output is similar to: | ||||
|     bmcdiscover -s nmap --range "10.4.23.100-254 50.3.15.1-2" | ||||
|  | ||||
|  10.4.23.254 | ||||
|  50.3.15.1 | ||||
| Note: Input for IP range can be in the form: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254. | ||||
|  | ||||
| Note: input for IP range can also be like scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254. | ||||
| 2. To get all BMSs in IP range "10.4.22-23.100-254", displayed in xCAT stanza format: | ||||
|  | ||||
| 2. After discover bmc, list the stanza format data | ||||
|     bmcdiscover -s nmap --range "10.4.22-23.100-254" -z | ||||
|  | ||||
| bmcdiscover -s nmap --range "10.4.22-23.100-254" -z | ||||
| 3. Discover the BMCs and write the discovered-node definitions into the xCAT database and write out the stanza foramt to the console: | ||||
|  | ||||
| Output is similar to: | ||||
|     bmcdiscover -s nmap --range "10.4.22-23.100-254" -w -z  | ||||
|  | ||||
|  node10422254: | ||||
|         objtype=node | ||||
|         groups=all | ||||
|         bmc=10.4.22.254 | ||||
|         cons=ipmi | ||||
|         mgt=ipmi | ||||
| 4. To check if the username or password is correct against the BMC: | ||||
|  | ||||
|  node10423254: | ||||
|         objtype=node | ||||
|         groups=all | ||||
|         bmc=10.4.23.254 | ||||
|         cons=ipmi | ||||
|         mgt=ipmi | ||||
|  | ||||
| 3. After discover bmc, write host node definition into the database, and the same time, give out stanza format data | ||||
|  | ||||
|  bmcdiscover -s nmap --range "10.4.22-23.100-254" -w | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  node10422254: | ||||
|         objtype=node | ||||
|         groups=all | ||||
|         bmc=10.4.22.254 | ||||
|         cons=ipmi | ||||
|         mgt=ipmi | ||||
|  | ||||
|  node10423254: | ||||
|         objtype=node | ||||
|         groups=all | ||||
|         bmc=10.4.23.254 | ||||
|         cons=ipmi | ||||
|         mgt=ipmi | ||||
|  | ||||
| 4. To check if user name or password is correct or not for bmc | ||||
|  | ||||
|  bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD -c | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  Correct ADMINISTRATOR | ||||
|  | ||||
|  bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD1 -c | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  Error: Wrong bmc password | ||||
|  | ||||
|  bmcdiscover -i 10.4.23.254 -u USERID1 -p PASSW0RD1 -c | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  Error: Wrong bmc user | ||||
|  | ||||
|  bmcdiscover -i 10.4.23.2541234 -u USERID -p PASSW0RD -c | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  Error: Not bmc | ||||
|     bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD -c | ||||
|  | ||||
| 5. Get BMC IP Address source, DHCP Address or static Address | ||||
|  | ||||
|  bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD --ipsource | ||||
|  | ||||
| Output is similar to: | ||||
|  | ||||
|  Static Address | ||||
|     bmcdiscover -i 10.4.23.254 -u USERID -p PASSW0RD --ipsource | ||||
|  | ||||
| =head1 SEE ALSO | ||||
|  | ||||
|   | ||||
| @@ -109,27 +109,12 @@ sub process_request | ||||
|  | ||||
| sub bmcdiscovery_usage { | ||||
|     my $rsp; | ||||
|     push @{ $rsp->{data} }, | ||||
|       "\nUsage: bmcdiscover - discover bmc using scan method,now scan_method can be nmap .\n"; | ||||
|     push @{ $rsp->{data} }, | ||||
|       "\n                   - check if BMC username or password is correct or not .\n"; | ||||
|     push @{ $rsp->{data} }, | ||||
|       "\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] [-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 "; | ||||
|     push @{ $rsp->{data} }, "\t1, bmcdiscover -s nmap --range \"10.4.23.100-254 50.3.15.1-2\" \n "; | ||||
|     push @{ $rsp->{data} }, "\t   Note : ip_range should be a string, can pass hostnames, IP addresses, networks, etc. \n "; | ||||
|     push @{ $rsp->{data} }, "\t   If there is bmc,bmcdiscover returns bmc ip, or else, it returns null. \n "; | ||||
|     push @{ $rsp->{data} }, "\t   Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 \n "; | ||||
|     push @{ $rsp->{data} }, "\t2, bmcdiscover -s nmap --range \"10.4.23.100-254 50.3.15.1-2\" -z \n "; | ||||
|     push @{ $rsp->{data} }, "\t3, bmcdiscover -s nmap --range \"10.4.23.100-254 50.3.15.1-2\" -w \n "; | ||||
|     push @{ $rsp->{data} }, "\t4, bmcdiscover -i <bmc_ip> -u <bmcusername> -p <bmcpassword> -c\n "; | ||||
|     push @{ $rsp->{data} }, "\t   Note : check if bmc username and password are correct or not. \n"; | ||||
|     push @{ $rsp->{data} }, "\t5, bmcdiscover -i <bmc_ip> -u <bmcusername> -p <bmcpassword> --ipsource\n "; | ||||
|     push @{ $rsp->{data} }, "\nbmcdiscover - Discover BMC (Baseboard Management Controller) using the specified scan method\n"; | ||||
|     push @{ $rsp->{data} }, "Usage:\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] bmcusername [-p|--bmcpwd] bmcpassword (-c | --check | --ipsource)"; | ||||
|     push @{ $rsp->{data} }, "\nFor more details see bmcdiscover(1)"; | ||||
|  | ||||
|     xCAT::MsgUtils->message( "I", $rsp, $::CALLBACK ); | ||||
|     return 0; | ||||
| @@ -250,63 +235,59 @@ sub bmcdiscovery_processargs { | ||||
|            return 0; | ||||
|     } | ||||
|  | ||||
|     ######################################### | ||||
|     # Option -i -u -p -c should be used together | ||||
|     ###################################### | ||||
|  | ||||
|     if ( defined($::opt_C) ) | ||||
|     { | ||||
|         if ( defined($::opt_P) && defined($::opt_I) ) | ||||
|         { | ||||
|              if ( defined($::opt_U) ) | ||||
|              { | ||||
|                  my $res=check_auth_process($::opt_I,$::opt_U,$::opt_P); | ||||
|                  return $res; | ||||
|              } | ||||
|              else | ||||
|              { | ||||
|                  my $res=check_auth_process($::opt_I,"none",$::opt_P); | ||||
|                  return $res; | ||||
|  | ||||
|              } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|              my $msg = "bmc_ip or bmcuser or bmcpw is empty."; | ||||
|              my $rsp = {}; | ||||
|              push @{ $rsp->{data} }, "$msg"; | ||||
|              xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|              return 2; | ||||
|         } | ||||
|     if ( defined($::opt_C) && defined($::opt_S) ) { | ||||
|         my $msg = "The 'check' and 'ipsource' option cannot be used together."; | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$msg"; | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|         ######################################### | ||||
|         # Option -i -u -p -s should be used together | ||||
|         ###################################### | ||||
|     if ( defined($::opt_S) ) | ||||
|     { | ||||
|         if ( defined($::opt_P) && defined($::opt_I) ) | ||||
|         { | ||||
|              if ( defined($::opt_U)) | ||||
|              { | ||||
|                 my $res=get_bmc_ip_source($::opt_I,$::opt_U,$::opt_P); | ||||
|                 return $res; | ||||
|              } | ||||
|              else | ||||
|              { | ||||
|                 my $res=get_bmc_ip_source($::opt_I,"none",$::opt_P); | ||||
|                 return $res; | ||||
|              } | ||||
|  | ||||
|     #################################################### | ||||
|     # --check option, requires -i 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); | ||||
|             return $res; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|              my $msg = "Can not get BMC IP Address source."; | ||||
|              my $rsp = {}; | ||||
|              push @{ $rsp->{data} }, "$msg"; | ||||
|              xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|              return 2; | ||||
|         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_P)) { | ||||
|                 $msg = "The check option requires a password.  Specify the password with the -p|--bmcpwd option."; | ||||
|             }  | ||||
|             my $rsp = {}; | ||||
|             push @{ $rsp->{data} }, "$msg"; | ||||
|             xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|             return 2; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     #################################################### | ||||
|     # --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); | ||||
|             return $res; | ||||
|         } | ||||
|         else { | ||||
|             my $msg = ""; | ||||
|             if (!defined($::opt_I)) { | ||||
|                 $msg = "The ipsource option requires a BMC IP.  Specify the IP using the -i|--bmcip option."; | ||||
|             } elsif (!defined($::opt_P)) { | ||||
|                 $msg = "The ipsource option requires a password.  Specify the password with the -p|--bmcpwd option."; | ||||
|             }  | ||||
|             my $rsp = {}; | ||||
|             push @{ $rsp->{data} }, "$msg"; | ||||
|             xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|             return 2; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     ######################################### | ||||
|     # Other attributes are not allowed | ||||
| @@ -315,6 +296,12 @@ sub bmcdiscovery_processargs { | ||||
|     return 4; | ||||
| } | ||||
|  | ||||
| my $bmc_str1 = "RAKP 2 message indicates an error : unauthorized name"; | ||||
| my $bmc_resp1 = "Wrong BMC username"; | ||||
|         | ||||
| my $bmc_str2 = "RAKP 2 HMAC is invalid"; | ||||
| my $bmc_resp2 = "Wrong BMC password"; | ||||
|  | ||||
| #---------------------------------------------------------------------------- | ||||
|  | ||||
| =head3   get_bmc_ip_source | ||||
| @@ -328,45 +315,44 @@ sub bmcdiscovery_processargs { | ||||
| #----------------------------------------------------------------------------- | ||||
|  | ||||
| sub get_bmc_ip_source{ | ||||
|  | ||||
|     my $bmcip = shift; | ||||
|     my $bmcuser = shift; | ||||
|     my $bmcpw = shift; | ||||
|     my $callback = $::CALLBACK; | ||||
|     my $bmcerror = "Can not find IP Address Source."; | ||||
|     my $ipsource_t = "IP Address Source"; | ||||
|     my $pcmd; | ||||
|  | ||||
|     if ( $bmcuser eq "none" ) | ||||
|     { | ||||
|        $pcmd = "/opt/xcat/bin/ipmitool-xcat -I lanplus -P $bmcpw -H $bmcip lan print "; | ||||
|     if ( $bmcuser eq "none" ) { | ||||
|        $pcmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -P $bmcpw -H $bmcip lan print "; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|        $pcmd = "/opt/xcat/bin/ipmitool-xcat -I lanplus -U $bmcuser -P $bmcpw -H $bmcip lan print "; | ||||
|  | ||||
|     else { | ||||
|        $pcmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -U $bmcuser -P $bmcpw -H $bmcip lan print "; | ||||
|     } | ||||
|     my $output = xCAT::Utils->runcmd("$pcmd", -1); | ||||
|     if ( $output !~ $ipsource_t ) | ||||
|     { | ||||
|  | ||||
|     if ( $output =~ "IP Address Source" ) { | ||||
|         # success case  | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$bmcerror"; | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         my $rsp = {}; | ||||
|         my $ipsource=`echo "$output"|grep "IP Address Source"|awk -F":" '{print \$2}'`; | ||||
|         my $ipsource=`echo "$output"|grep "IP Address Source"`; | ||||
|         chomp($ipsource);  | ||||
|         push @{ $rsp->{data} }, "$ipsource"; | ||||
|         xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); | ||||
|         return 0; | ||||
|      | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|     else { | ||||
|         my $rsp = {}; | ||||
|         if ( $output =~ $bmc_str1 ) { | ||||
|             # Error: RAKP 2 message indicates an error : unauthorized name <== incorrect username  | ||||
|             push @{ $rsp->{data} }, "$bmc_resp1"; | ||||
|         } elsif ( $output =~ $bmc_str2 ) {  | ||||
|             # Error: RAKP 2 HMAC is invalid <== incorrect password  | ||||
|             push @{ $rsp->{data} }, "$bmc_resp2"; | ||||
|         } else {  | ||||
|             # all other errors  | ||||
|             push @{ $rsp->{data} }, "Error: Can not find IP Address Source"; | ||||
|         } | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -386,60 +372,43 @@ sub check_auth_process{ | ||||
|     my $bmcip = shift; | ||||
|     my $bmcuser = shift; | ||||
|     my $bmcpw = shift; | ||||
|     my $bmstr1 = "RAKP 2 message indicates an error : unauthorized name"; | ||||
|     my $bmstr2 = "RAKP 2 HMAC is invalid"; | ||||
|     my $bmstr3 = "Set Session Privilege Level to ADMINISTRATOR"; | ||||
|     my $bmstr31 = "Correct ADMINISTRATOR"; | ||||
|     my $bmstr21 = "Wrong bmc password"; | ||||
|     my $bmstr11 = "Wrong bmc user"; | ||||
|     my $bmcerror = "Not bmc"; | ||||
|     my $othererror = "Check bmc first"; | ||||
|     my $bmstr4 = "BMC Session ID"; | ||||
|     my $bmc_str4 = "BMC Session ID"; | ||||
|       | ||||
|     my $callback = $::CALLBACK; | ||||
|     my $icmd; | ||||
|     if ( $bmcuser eq "none" ) | ||||
|     { | ||||
|     if ( $bmcuser eq "none" ) { | ||||
|        $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -P $bmcpw -H $bmcip chassis status "; | ||||
|     } | ||||
|     else | ||||
|     {  | ||||
|     else {  | ||||
|        $icmd = "/opt/xcat/bin/ipmitool-xcat -vv -I lanplus -U $bmcuser -P $bmcpw -H $bmcip chassis status "; | ||||
|     } | ||||
|     my $output = xCAT::Utils->runcmd("$icmd", -1); | ||||
|     if ( $output =~ $bmstr1 ) | ||||
|     { | ||||
|  | ||||
|     if ($output =~ "Set Session Privilege Level to ADMINISTRATOR" ) { | ||||
|         # Success case | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$bmstr11"; | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|     elsif ( $output =~ $bmstr2 ) | ||||
|     { | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$bmstr21"; | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|     elsif ( $output =~ $bmstr3 ) | ||||
|     { | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$bmstr31"; | ||||
|         push @{ $rsp->{data} }, "Correct ADMINISTRATOR"; | ||||
|         xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); | ||||
|         return 0; | ||||
|  | ||||
|     } | ||||
|     elsif ( $output !~ $bmstr4 ) | ||||
|     { | ||||
|     } else {  | ||||
|         # handle the various error scenarios  | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$bmcerror"; | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         my $rsp = {}; | ||||
|         push @{ $rsp->{data} }, "$othererror"; | ||||
|          | ||||
|         if ( $output =~ $bmc_str1 ) { | ||||
|             # Error: RAKP 2 message indicates an error : unauthorized name <== incorrect username  | ||||
|             push @{ $rsp->{data} }, "$bmc_resp1"; | ||||
|         } | ||||
|         elsif ( $output =~ $bmc_str2 ) { | ||||
|             # Error: RAKP 2 HMAC is invalid <== incorrect password  | ||||
|             push @{ $rsp->{data} }, "$bmc_resp2"; | ||||
|         } | ||||
|         elsif ( $output !~ $bmc_str4 ) { | ||||
|             # Did not find "BMC Session ID" in the response  | ||||
|             push @{ $rsp->{data} }, "Not a BMC, please verify the correct IP address"; | ||||
|         } | ||||
|         else { | ||||
|             push @{ $rsp->{data} }, "Unknown Error: $output"; | ||||
|         } | ||||
|         xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); | ||||
|         return 2; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user