.. include:: ../../common/discover/switch_discovery.rst

For switch based hardware discovery, the server are identified though the switches and switchposts they directly connect to. 

.. include:: schedule_environment.rst

Switch info::

    Switch name: switch1
    Switch username: xcat
    Switch password: passw0rd
    Switch IP Address: 10.0.201.1
    Switch port for Compute Node: port0

.. include:: config_environment.rst

Predefined Nodes
----------------

In order to differentiate one node from another, the admin needs to predefine node in xCAT database based on the switches information. This consists of two parts:

#. :ref:`predefined_switches_label`
#. :ref:`predefined_server_nodes_label`


.. _predefined_switches_label:

Predefine Switches

The predefined switches will represent devices that the physical servers are connected to. xCAT need to access those switches to get server related information through SNMP v3.

So the admin need to make sure those switches are configured correctly with SNMP v3 enabled. <TODO: The document that Configure Ethernet Switches>

Then, define switch info into xCAT::
    
    nodeadd switch1 groups=switch,all
    chdef switch1 ip=10.0.201.1
    tabch switch=switch1 switches.snmpversion=3 switches.username=xcat switches.password=passw0rd switches.auth=sha

Add switch into DNS using the following commands::

    makehosts switch1
    makedns -n

.. _predefined_server_nodes_label:

Predefine Server node

After switches are defined, the server node can be predefined with the following commands::

    nodeadd cn1 groups=powerLE,all
    chdef cn1 mgt=ipmi cons=ipmi ip=10.0.101.1 bmc=50.0.101.1 netboot=petitboot installnic=mac primarynic=mac
    chdef cn1 switch=switch1 switchport=0

Add cn1 into DNS::

    makehosts cn1
    maekdns -n

.. include:: pbmc_discovery_with_bmcdiscover.rst

Verify node definition
----------------------

The following is an example of the server node definition after hardware discovery::


  #lsdef cn1
  Object name: cn1
      arch=ppc64
      bmc=50.0.101.1
      cons=ipmi
      cpucount=192
      cputype=POWER8E (raw), altivec supported
      groups=powerLE,all
      installnic=mac
      ip=10.0.101.1
      mac=6c:ae:8b:02:12:50
      memory=65118MB
      mgt=ipmi
      mtm=8247-22L
      netboot=petitboot
      postbootscripts=otherpkgs
      postscripts=syslog,remoteshell,syncfiles
      primarynic=mac
      serial=10112CA
      supportedarchs=ppc64
      switch=switch1
      switchport=0
