
=head1 NAME

B<switchdiscover> - Discover all the switches on the subnets.


=head1 SYNOPSIS

I<switchdiscover [-h| --help]>

I<switchdiscover [-v| --version]>


I<switchdiscover [noderange|--range ip_ranges] [-V] [-w][-r|-x|-z][-s scan_methods]>



=head1 DESCRIPTION

The switchdiscover command scans the subnets and discovers all the swithches on the subnets. The command takes a list of subnets as input. The default subnets are the ones that the xCAT management node is on. It uses nmap command to discover the switches. However, you can specify other discovery methods such as lldp with B<-s> flag. You can write the discovered switches into xCAT database with B<-w> flag. This command supports may output formats such as xml(B<-x>), raw(B<-r>) and stanza(B<-z>) in addition to the default format.    

To view all the switches defined in the xCAT databasee use B<lsdef -w "nodetype=switch"> command.

For lldp method, please make sure that lldpd package is installed and lldpd is running on the xCAT management node. lldpd comes from xcat-dep packge or you can get it from http://vincentbernat.github.io/lldpd/installation.html. 


=head1 OPTIONS

=over 10

=item B<noderange>  

The switches which the user want to discover.
If the user specify the noderange, switchdiscover will just
return the switches in the node range. Which means it will 
help to add the new switches to the xCAT database without
modifying the existed definitions. But the switches' name 
specified in noderange should be defined in database in advance. 
The ips of the switches will be defined in /etc/hosts file. 
This command will fill the switch attributes for the switches defined. 

=item B<-h>          

Display usage message.

=item B<--range>  

Specify one or more IP ranges. Each can be an ip address (10.1.2.3) or an ip range (10.1.2.0/24). If the range is huge, for example, 192.168.1.1/8, the switch discover may take a very long time to scan. So the range should be exactly specified.

For nmap scan method, it accepts multiple formats. For example, 192.168.1.1/24, 40-41.1-2.3-4.1-100.

If the range is not specified, the command scans all the subnets that the active network interfaces (eth0, eth1) are on where this command is issued. 

=item B<-r>          

Display Raw responses.

=item B<-s>  

It is a comma separated list of methods for switch discovery. 
The possible switch scan methods are: lldp and nmap. The default is nmap.

=item B<-v>  

Command Version.

=item B<-V>    

Verbose output.

=item B<-w>     

Writes output to xCAT database.

=item B<-x>      

XML formated output.

=item B<-z>          

Stanza formated output.

=back

=head1 RETURN VALUE

0 The command completed successfully.

1 An error has occurred.

=head1 EXAMPLES

=over 3

=item *

To discover the switches on some subnets:

B<switchdiscover> I<--range 10.2.3.0/24,192.168.3.0/24,11.5.6.7>

=item *

To do the switch discovery and save them to the xCAT database:

B<switchdiscover> I<--range 10.2.3.4/24 -w>

It is recommended to run B<makehosts> after the switches are saved in the DB.

=item *

To use lldp mathod to discover the switches:

B<switchdiscover> -s lldp


=back

=head1 FILES

/opt/xcat/bin/switchdiscover


=head1 SEE ALSO






