Thanks Laurent! I will give that a shot.
Subject: |
RE: Automate Resetting of IP Address for Device |
Author: |
Morgan Timney |
Posted: |
2020-03-02 13:32 |
We have a few virtual devices that become invisible to the network when they are inactive. We have a global name that resolves to the IP of the currently up/active device. So perhaps similar needs to you.
I wrote this transform for in the /Status/Ping event class and has been working pretty well
# For hosts with 'powered off' vsphere redunancy, the below updates the IP immediatly following failovers.
# This transaction is blocking, so minimize additions to list.
if evt.device in ('globalname1','globalname2'):
evt.message = '%s %s' % (evt.message, evt.device)
import socket, sys
try:
DNSIP = socket.gethostbyname(evt.device) # get the IP address from DNS
if (device.manageIp != DNSIP): # if the devices IP doesnt match the DNSIP
from transaction import commit
device.setManageIp(DNSIP) # set the new IP on the device, push and commit.
commit()
device.pushConfig()
commit()
evt.message += "\nThe IP address was reset to match DNS." #downgrade the event to informational
evt.severity = 2
except Exception as e:
evt.message = "%s %s" % (evt.message, e)
------------------------------
Morgan Timney
The Southern Company
Birmingham AL
------------------------------