Witness-Script for Nutanix Metro Availability (python)

Last week I had some conversations around our Metro Availability and a so called “witness”, a third observation instance. I already build a short how to with the vRealize Orchestrator but sometimes there´s no VMware 🙂

I decided to use python to write a short “promotion” function that works as soon as the Metro site has the “Standby” state.

For automation purpose I wanted to have a SNMP receiver that tracks the site that goes down and sets the site to promote. Because pysnmp is much to heavy in this small case  i just used sockets to listen on a SNMP port.

Now there are 3 files:

  • config.py – holds the configuration parameter (user, pass, site DNS/IP, protection domain)
  • listen.py – has the sockets listener and sets the site parameter based on a string in the SNMP trap
  • witness. py – the promote function (REST call) based on the received site

You can find them here:  https://github.com/cjohannsen81/ntnx_witness

After starting the script with: sudo python witness.py (sudo in my case, cause of user restrictions) the socket listener will wait for a call on port 162. I used this one: snmptrap -v1 -c public 1 1 123 s siteB with the site as string. You can adjust the SNMP stuff by changing the listen.py file to your needs.

As soon as there is a “siteA” or “siteB” string in the trap the listen.py sets the site that goes down and the witness.py will promote the standby site.

Screen Shot 2015-05-20 at 10.26.39

If necessary it´s also possible to just add a “disable” function for testing purpose or validation:


This would disable the site that was reported and promotes the opposite site 😉


Beitrag erstellt 26

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Verwandte Beiträge

Beginne damit, deinen Suchbegriff oben einzugeben und drücke Enter für die Suche. Drücke ESC, um abzubrechen.

Zurück nach oben