ZTPServer VM on EOS in a L3WOM ============================== .. The line below adds a local TOC .. contents:::local: :depth: 1 Files Needed ------------ * ``ztps.vmdk`` : the VM disk image for the ZTPServer VM * ``startup-config``: a text file (with no extension) * ``ztps.sh`` : a bash shell script * ``ztps.xml`` : an xml file * ``dhcpd.conf`` : a text file for Linux dhcpd configuration * ``dhcpd.rpm`` : a DHCP server RPM to be installed on EOS * ``ztps_daemon`` : a python script * ``fullrecover`` : an empty text file (with no extension) * ``boot-config`` : a text file (with no extension); contains a single line: ``SWI=flash:EOS.swi`` * ``boot-extention``: a text file (with no extention); contains a single like: ``dhcpd.rpm`` * ``EOS.swi`` : download an EOS image and rename it to ``EOS.swi`` .. End of Files Needed ztps.vmdk --------- Objective ^^^^^^^^^ I want to create a ZTPServer vmdk file to use on EOS. Solution ^^^^^^^^ The ZTPServer vmdk file can be created using either methods below: 1) Automatically Create a Full-Featured ZTPServer: https://github.com/arista-eosplus/packer-ZTPServer 2) Create your own VM and install ZTPServer as intructed in the "Installation" section Explanation ^^^^^^^^^^^ The turnkey solution detailed on the github will create a full featured ztps.vmdk by executing a single command. The vmdk created using this method comes with certain parameters pre-defined (i.e. domain-name, root user credential, IP address, etc). If desired, you can change these parameters by logging into the VM after it's created. The second method requires more manual work compare to the first method, but may be more suitable if you already have a VM build to your needs and simply want to add ZTPServer to it. .. End of ztps.vmdk startup-config -------------- Objective ^^^^^^^^^ I need to prepare a startup-config for the first SPINE switch to enable ZTPServer. Solution ^^^^^^^^ Essential parts of the configuration: * ``interface Loopback2`` : need a loopback interface on the same subnet as the VM * ``daemon ztps`` : used to run the ``ztps.daemon`` python script in the background * ``event-handler ztps`` : used to start the shell script ``ztps.sh`` * ``virtual-machine ztps`` : used to start the ZTPServer VM on EOS * ``management api http-commands``: need to enable eAPI for ``daemon ztps`` to function .. code-block:: console interface Loopback2 ip address 172.16.130.253/24 daemon ztps command /mnt/flash/ztps_daemon & event-handler ztps trigger on-boot action bash /mnt/flash/ztps.sh & delay 300 virtual-machine ztps config-file flash:/ztps.xml enable management api http-commands protocol http localhost no shutdown Explanation ^^^^^^^^^^^ The ``event-handler ztps`` is triggered on-boot to kickstart the shell script ``ztps.sh``. There is a delay of 300 seconds before the script will be executed, to make sure all the necessary systems are in place before we run the script. For details of the script please see the ``ztps.sh`` section. The ``management api http-commands`` section enables Arista eAPI on the host swithc; eAPI is leveraged by the ``ztps_daemon``. eAPI can be accessed remotely via http or https, or it can be accessed locally via http, or by binding to a UNIX socket (only available on 4.14.5F onward). Since the daemon is a script that runs locally, we can either enalbe eAPI on the localhost via http (if you are running 4.14.5F or later), or we can just enable eAPI over https (this will require authentication). The ``daemon ztps`` section runs a python script in the back ground as a daemon to restart DHCPD whenever an interface comes up. For details of the shell script ``ztps.sh`` and the python script ``ztps_daemon`` please refer to the corresponding sectio below. .. note:: The loopback interface is only needed if you plan to bootstrap a L3 ECMP fabric without a management network. In this scenario, the loopback address needs to be advertised in the ECMP routing protocol to enable connectivity for the downstream deviecs in the fabric. .. End of startup-config ztps.sh ------- Objective ^^^^^^^^^ I want to create a shell script to set up all the necessary environment for ZTPServer when the switch boots up. Solution ^^^^^^^^ .. code-block:: console #!/bin/bash # This script is used with the event-handler so that on-boot, we will create linux bridge, #enable ip.forwarding, restart the ZTPS VM, and start DHCPD logger -t "ZTPS" -p local0.info "Starting the process for ZTPS VM deployment" # Create Linux Bridge sudo brctl addbr br0 sudo ifconfig br0 up sudo ifconfig br0 172.16.130.254/24 logger -t "ZTPS" -p local0.info "Linux Bridge created" # Enable ip.forwarding sudo sysctl net.ipv4.conf.all.forwarding=1 sudo sysctl net.ipv4.ip_forward=1 logger -t "ZTPS" -p local0.info "ip.forwarding enabled" # Move the DHCP server RPM to the appropriate folder on EOS for installation # Move the dhcpd.conf file to the appropriate folder sudo cp /mnt/flash/dhcp-4.2.0-23.P2.fc14.i686.rpm /mnt/flash/.extensions/dhcpd.rpm sudo cp /mnt/flash/dhcpd.conf /etc/dhcp/ sudo /usr/sbin/dhcpd sleep 5 #make sure dhcpd is running before we continue ps aux | grep "dhcpd" | grep -v grep if [ $? -eq 0 ] then { logger -t "ZTPS" -p local0.info "DHCPD is running. Restart ZTPS VM." #Now lets restart the ZTPS VM sudo echo -e "enable\nconfigure terminal\nvirtual-machine ztps restart\n" | FastCli -M -e -p 15 logger -t "ZTPS" -p local0.info "ZTPS VM restarted" exit 0 } else logger -t "ZTPS" -p local0.info "Looks like DHCPD didn't start. Lets sleep for a few seconds and try again" sleep 10 fi Explanation ^^^^^^^^^^^ In order to enable connectivity to the VM from both remotely and locally (from the host switch), a Linux bridge interface needs to be created and assigned an IP in the same subnet as the VM; Linux ``ip.forwarding`` also needs to be enabled in the kernel for the packets to be routed to the VM. EOS does not come with dhcpd preinstalled, there a DHCP-Server RPM needs to be downloaded, installed and started. Dowdload the RPM from `here `_ and rename it to ``dhcpd.rpm``. The RPM needs to be moved to the ``/mnt/flash/.extension`` location, and a ``boot-extension`` file, with the RPM specified, needs to be present in ``/mnt/flash`` in order for the RPM to be installed persistently after a reboot. The ZTPServer VM needs to be restarted after the switch boots up. .. note:: The ZTPServer VM needs to have its default gateway pointed to the br0 interface IP address. .. End of ztps.sh ztps.xml -------- Objective ^^^^^^^^^ I want to prepare a KVM custom xml file to enable a VM on EOS. Solution ^^^^^^^^ Key parts of the xml file to pay attention to: * ```` : in case multiple VMs are running on the system, make sure the configured ID is unique * ```` : make sure the type is ``vmdk`` * ````: make sure the path is correct * ```` : make sure this MAC matches the MAC address of the interface on the ZTPServer VM that you intend to use for connectivity * ```` : make sure the target device type is ``vnet0`` .. code-block :: console ztps 1048576 1048576 1 hvm destroy restart restart /usr/bin/qemu-system-x86_64