diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index d30b9edd2..2ef132eb3 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -289,7 +289,7 @@ my %usage = ( [-u] [--range IPranges][-t tries][--vpdtable][-C counts][-T timeout]", "switchdiscover" => "Usage: switchdiscover [-h|--help|-v|--version] - switchdiscover [|--range ipranges] [-s scan_methods] [-r|-x|-z][-n] [-w] [-V|--verbose]", + switchdiscover [|--range ipranges] [-s scan_methods] [-r|-x|-z] [-w] [-V|--verbose]", "rflash" => "Usage: rflash [ -h|--help|-v|--version] diff --git a/xCAT-client/pods/man1/switchdiscover.1.pod b/xCAT-client/pods/man1/switchdiscover.1.pod index af17fd3e1..301b049f4 100755 --- a/xCAT-client/pods/man1/switchdiscover.1.pod +++ b/xCAT-client/pods/man1/switchdiscover.1.pod @@ -11,7 +11,7 @@ I I -I +I @@ -32,8 +32,6 @@ B The switches which the user want to discover. B<-h> Display usage message. -B<-n> Only display and write the newly discovered switches. - B<--range> Specify one or more IP ranges. It accepts multiple formats. For example, 192.168.1.1/24, 40-41.1-2.3-4.1-100. If the range is huge, for example, 192.168.1.1/8, switchdiscover may take a very long @@ -42,7 +40,7 @@ B<--range> Specify one or more IP ranges. B<-r> Display Raw response. B<-s> It is a comma separated list of methods for switch discovery. - The possible switch scan methods are: llpd, nmap and snmp. The default is lldpd. + The possible switch scan methods are: lldpd, nmap and snmp. The default is lldpd. B<-v> Command Version. diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index a70b92061..ec6575145 100755 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -547,9 +547,9 @@ sub nmap_scan { # us the ip addresses of the nodes. If none is define, use the # subnets for all the interfaces. ################################################## - my $ranges = get_ip_ranges($request); + my $ranges = get_ip_ranges($request); - $ccmd = "/usr/bin/nmap -sn -oX - @$ranges"; + $ccmd = "/usr/bin/nmap -sn -oX - @$ranges"; print $ccmd; my $result = xCAT::Utils->runcmd($ccmd, 0); if ($::RUNCMD_RC != 0) @@ -633,8 +633,8 @@ sub snmp_scan { ip : IP address passed by the switch after scan Returns: hose: hostname of the switch - if host is empty, format hostname as switch and ip combination - ex: switch-9-114-5-6 + if host is empty, try to lookup use ip address, otherwise format hostname + as switch and ip combination. ex: switch-9-114-5-6 =cut #-------------------------------------------------------------------------------- sub get_hostname { @@ -642,9 +642,12 @@ sub get_hostname { my $ip = shift; if ( !$host ) { - my $ip_str = $ip; - $ip_str =~ s/\./\-/g; - $host = "switch-$ip_str"; + $host = gethostbyaddr( inet_aton($ip), AF_INET ); + if ( !$host ) { + my $ip_str = $ip; + $ip_str =~ s/\./\-/g; + $host = "switch-$ip_str"; + } } return $host; }