2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 09:50:19 +00:00

Merge pull request #1825 from cxhong/1732

Modify switchdiscover usage, man page and update readdoc.
Changes look good. Merging.
This commit is contained in:
Mark Gurevich
2016-09-19 13:12:00 -04:00
committed by GitHub
6 changed files with 203 additions and 8 deletions

View File

@ -4,7 +4,7 @@ Networks
.. toctree::
:maxdepth: 2
switchdiscover/index.rst
ethernet_switches/index.rst
switchdiscover/index.rst
infiniband/index.rst
ipv6/index.rst

View File

@ -5,3 +5,4 @@ Switch Discover
:maxdepth: 2
switches_discovery.rst
switch_based_switch_discovery.rst

View File

@ -0,0 +1,168 @@
Switch-based Switch Discovery
=============================
Currently, xCAT supports switch based hardware discovery, the servers are identified through the switches and switch ports they are directly connected to. A similar method can be used to discover switches using switch-based discovery within the user defined dynamic IP range.
Pre-requirement
~~~~~~~~~~~~~~~
In order to do switch-based switch discovery, the admin
1. Needs to manually setup and configure core-switch, SNMP v3 needs to be enabled in order for xCAT access to it. **username** and **userpassword** attributes are for the remote login. It can be for **ssh** or **telnet**. If it is for **telnet**, please set protocol to “telnet”. If the **username** is blank, the **username** and **password** will be retrieved from the passwd table with “switch” as the key. SNMP attributes will used for SNMPv3 communication. **nodetype** has to be set to "switch" to differentiate between switch-based node discovery or switch-based switch discovery. Refer to switches table attributes. Example of core-switch definition:
::
lsdef switch-10-5-23-1
Object name: switch-10-5-23-1
groups=switch
ip=10.5.23.1
mac=ab:cd:ef:gh:dc
mgt=switch
nodetype=switch
password=admin
postbootscripts=otherpkgs
postscripts=syslog,remoteshell,syncfiles
protocol=telnet
snmpauth=sha
snmppassword=userpassword
snmpusername=snmpadmin
snmpversion=3
switchtype=BNT
usercomment=IBM
username=root
2. Predefine all top-rack switches which connect to core-switch. The attribute **ip** is static ip address for the switch. When ``switchdiscover --setup`` command is issued, this ip address will replace dhcp IP address on the switch. **nodetype=switch** needs to be set to differentiate between switch-based node discovery or switch-based switch discovery during discovery process. the attribute **switch** is hostname of core-switch and **switchport** is the port number in the core-switch that top-rack switch is connected to.
::
lsdef switch-192-168-5-22
objtype=node
groups=switch
ip=192.168.5.22
mgt=switch
nodetype=switch
switch=switch-10-5-23-1
switchport=45
switchtype=BNT
3. Setup Dynamic IP range in network table for discovered switches to use. ::
# tabdump networks
#netname,net,mask,mgtifname,gateway,dhcpserver,tftpserver,nameservers,ntpservers,logservers,dynamicrange,staticrange,staticrangeincrement,nodehostname,ddnsdomain,vlanid,domain,comments,disable
"192_168_0_0-255_255_0_0","192.168.0.0","255.255.0.0","enP4p1s0f2","<xcatmaster>",,"192.168.3.29",,,,"192.168.5.150-192.168.5.170",,,,,,,,
dhcp should be restarted after seting up dynamic IP range.
Discover Switches
~~~~~~~~~~~~~~~~~
xCAT supports **switchdiscover** command to discover the switches that are attached to the subnets on xCAT management node. Refer to http://xcat-docs.readthedocs.io/en/latest/advanced/networks/switchdiscover/switches_discovery.html for more info.
For the switch-based switch discovery, we add **setup** flag: ::
switchdiscover [noderange|--range ip_ranges][-s scan_methods] [--setup]
if **--setup** flag is specified, the command will perform following steps:
1. Use snmp or nmap scan methods to find all switches in the dynamic IP ranges specified by --range, the available switches will be stored in switch hash table with hostname, switchtype, vendor info and mac address.
2. Based on mac address for each switch defined in the hash table, call **find_mac** subroutine. The **find_mac** subroutine will go thought the switch and switch ports and find matched mac address.
* If discovered switch didn't find any predefined switch matches, it will log the message ``NO predefined switch matched``.
* If discovered switch matched with one of pre-defined switch, it will update the predefined switch with ::
otherinterface=x.x.x.x (discovered ip)
state=matched
switchtype=type of switch
usercomment=vendor information
3. After switches are matched, the command will call config files to set up static IP address, hostname and enable the snmpv3. Currently, BNT and Mellanox switches are supported. The two config files are located in the **/opt/xcat/share/xcat/scripts/config.BNT** and **/opt/xcat/share/xcat/scripts/config.Mellanox**. the log message ``the switch type is not support for config`` is displayed if switchtype is something other than BNT or Mellanox.
4. After discovery process, the predefined node attribute in the xCATdb will be updated.
::
lsdef switch-192-168-5-22
groups=switch
ip=192.168.5.22
mac=a8:97:dc:02:92:00
mgt=switch
nodetype=switch
password=admin
postbootscripts=otherpkgs
postscripts=syslog,remoteshell,syncfiles
protocol=telnet
snmpauth=sha
snmppassword=xcatadminpassw0rd@snmp
snmpusername=xcatadmin
snmpversion=3
status=hostname_configed
statustime=08-31-2016 15:35:49
supportedarchs=ppc64
switch=switch-10-5-23-1
switchport=45
switchtype=BNT
usercomment=IBM Networking Operating System RackSwitch G8052
username=root
Configure switches
~~~~~~~~~~~~~~~~~~
The **switchdiscover** command with ``--setup`` flag will set up switches with static ip address, change the hostname from predefine switches and enable snmpv3 configuration. For other switches configuration, Refer to http://xcat-docs.readthedocs.io/en/latest/advanced/networks/ethernet_switches/ethernet_switches.html and http://xcat-docs.readthedocs.io/en/latest/advanced/networks/infiniband/switch_configuration.html
These two config files are located in the **/opt/xcat/share/xcat/scripts**. The **switchdiscover** process will call the config files with ``--all`` option. User can call these scripts to setup one of options manually.
1. **configBNT** is for configure BNT switches.
::
./configBNT --help
Usage:
configBNT [-?│-h│--help]
configBNT [--switches switchnames] [--all]
configBNT [--switches switchnames] [--ip]
configBNT [--switches switchnames] [--name ]
configBNT [--switches switchnames] [--snmp] [--user snmp_user] [--password snmp_password] [--group snmp_group]
configBNT [--switches switchnames] [--port port] [--vlan vlan]
2. **configMellanox** is for configuring Mellanox switch. The script will configure ntp service on the switch with xCAT MN and will use rspconfig command to
* enable ssh
* enable snmp function on the switch
* enable the snmp trap
* set logging destination to xCAT MN
::
./configMellanox --help
Usage:
configMellonax [-?│-h│--help]
configMellonax [--switches switchnames] [--all]
configMellonax [--switches switchnames] [--ip]
configMellonax [--switches switchnames] [--name]
configMellonax [--switches switchnames] [--config]
Switch Status
~~~~~~~~~~~~~
During the switch-based switch discovery process, there are four states displayed. User may only see **switch_configed** status on node definition if discovery process succefully finished.
**Matched** --- Discovered switch is matched to predefine switch, **otherinterfaces** attribute is updated to dhcp IP address, and mac address, **switch type** and **usercomment** also updated with vendor information for the predefined switch.
**ip_configed** --- switch is set up to static ip address based on predefine switch IP address. If failure to set up IP address, the status will stay as **Matched**.
**hostname_configed** -- switch host name is changed based on predefine switch hostname. If failure to change hostname on the switch, the status will stay as **ip_configed**.
**switch_configed** -- snmpv3 is setup for the switches. This should be finial status after running ``switchdiscover --setup`` command. If failure to setup snmpv3, the status will stay as **hostname_configed**.

View File

@ -15,7 +15,7 @@ SYNOPSIS
\ **switchdiscover [-v| -**\ **-version]**\
\ **switchdiscover**\ [\ *noderange*\ | \ **-**\ **-range**\ \ *ip_ranges*\ ] \ **[-V] [-w][-r|-x|-z][-s**\ \ *scan_methods*\ ]
\ **switchdiscover**\ [\ *noderange*\ | \ **-**\ **-range**\ \ *ip_ranges*\ ] \ **[-V] [-w][-r|-x|-z][-s**\ \ *scan_methods*\ \ **-**\ **-setup**\ ]
***********
@ -25,6 +25,8 @@ 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 as default to discover the switches. However, you can specify other discovery methods such as lldp or snmp with \ **-s**\ flag. You can write the discovered switches into xCAT database with \ **-w**\ flag. This command supports may output formats such as xml(\ **-x**\ ), raw(\ **-r**\ ) and stanza(\ **-z**\ ) in addition to the default format.
\ **-**\ **-setup**\ flag is for switch-based switch discovery. It will find all the discovered switches on the subnets, then match them with predefined switches in the xCATDB. Next, it will set discovered switches with static ip address and hostname based on the predefined switch. It will also enable snmpv3 configuration. The details of the process are defined in the http://xcat-docs.readthedocs.io/en/latest/advanced/networks/switchdiscover/switches_discovery.html.
To view all the switches defined in the xCAT databasee use \ **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.
@ -110,6 +112,12 @@ OPTIONS
\ **-**\ **-setup**\
Process switch-based switch discovery. Update discovered switch's ip address, hostname and enable snmpv3 configuration based on the predefined switch.
************
RETURN VALUE
@ -149,9 +157,7 @@ EXAMPLES
3.
To use lldp method to discover the switches:
3. To use lldp method to discover the switches:
.. code-block:: perl
@ -161,6 +167,16 @@ EXAMPLES
4. To process switch-based switch discovery, the core switch has to be configured and top-of-rack (edge) switch has to be predefine into xCAT databse with attribute \ **switch**\ and \ **switchport**\ to core switch:
.. code-block:: perl
switchdiscover --range 192.168.5.150-170 -s snmp --setup
*****
FILES

View File

@ -303,7 +303,7 @@ my %usage = (
[-u] [--range IPranges][-t tries][--vpdtable][-C counts][-T timeout]",
"switchdiscover" =>
"Usage: switchdiscover [-h|--help|-v|--version]
switchdiscover [<noderange>|--range ipranges] [-s scan_methods] [-r|-x|-z] [-w] [-V|--verbose]",
switchdiscover [<noderange>|--range ipranges] [-s scan_methods] [-r|-x|-z] [-w] [-V|--verbose] [--setup]",
"switchprobe" =>
"Usage: switchprobe [<noderange>] [-V|--verbose | -c|--check]",
"makentp" =>

View File

@ -10,7 +10,7 @@ B<switchdiscover [-h| --help]>
B<switchdiscover [-v| --version]>
B<switchdiscover> [I<noderange> | B<--range> I<ip_ranges>] B<[-V] [-w][-r|-x|-z][-s> I<scan_methods>]
B<switchdiscover> [I<noderange> | B<--range> I<ip_ranges>] B<[-V] [-w][-r|-x|-z][-s> I<scan_methods> B<--setup>]
@ -18,6 +18,8 @@ B<switchdiscover> [I<noderange> | B<--range> I<ip_ranges>] B<[-V] [-w][-r|-x|-z]
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 as default to discover the switches. However, you can specify other discovery methods such as lldp or snmp 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.
B<--setup> flag is for switch-based switch discovery. It will find all the discovered switches on the subnets, then match them with predefined switches in the xCATDB. Next, it will set discovered switches with static ip address and hostname based on the predefined switch. It will also enable snmpv3 configuration. The details of the process are defined in the http://xcat-docs.readthedocs.io/en/latest/advanced/networks/switchdiscover/switches_discovery.html.
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.
@ -81,6 +83,10 @@ XML formated output.
Stanza formated output.
=item B<--setup>
Process switch-based switch discovery. Update discovered switch's ip address, hostname and enable snmpv3 configuration based on the predefined switch.
=back
=head1 RETURN VALUE
@ -106,11 +112,15 @@ To do the switch discovery and save them to the xCAT database:
It is recommended to run B<makehosts> after the switches are saved in the DB.
=item 3.
To use lldp method to discover the switches:
switchdiscover -s lldp
=item 4.
To process switch-based switch discovery, the core switch has to be configured and top-of-rack (edge) switch has to be predefine into xCAT databse with attribute B<switch> and B<switchport> to core switch:
switchdiscover --range 192.168.5.150-170 -s snmp --setup
=back