Skip navigation
1672 Views 2 Replies Latest reply: Jun 27, 2012 7:25 AM by Andrey Telepin RSS
Michael Ducharme Rank: White Belt 24 posts since
Jul 20, 2010
Currently Being Moderated

Jun 25, 2012 9:45 PM

DMD data to modeler - making the mountain come to you

With some of our devices, some of the component data is unavailable if that component is offline. This is the case with our Trango Access Points, where we model the Trango Subscriber Units under the access point. If the Subscriber Unit is offline, the customer's name (suRemarks) no longer appears, neither does their IP Address or Distance. This leads to the customer's name, IP address and distance being blank if the modeling cycle happened to coincide with the subscriber being offline.

 

Although access to the DMD from the modeling script is theoretically available, it's recommended against. There is an official, but somewhat undocumented, back door way to get this component data into the modeler - and it turns out to be extremely simple:

 

Step 1) Add a method to your .py class file for the DEVICE (not the class file for the component!)

 

In my case, this was the TrangoAccessPointDevice.py:

 


def getSUVolatileData(self):

   """Return the volatile data on existing SUs for modeler use

   """

   myvolatiledata = {}

   for su in self.trangoSubscriberUnit():

       suinfo = { 'suRemarks' : su.suRemarks, 'suIPAddr' : su.suIPAddr, 'suDistance' : su.suDistance }

       myvolatiledata[su.suID] = suinfo

   return myvolatiledata

 

The method returns a dict of the "volatile data" - in my case, the Remarks, IP Address and Distance disappear when the subscriber is offline, so I want to pull those values from the DMD and pass them to the modeler.

 

Step 2) Add/alter the deviceProperties setting in your modeler script for the component to import this data:

 

In the class:

 


relname = "trangoSubscriberUnit"

modname = "ZenPacks.BCN.Trango.TrangoSubscriberUnit"

deviceProperties = SnmpPlugin.deviceProperties + ('getSUVolatileData',)

 

In my case, I had to add deviceProperties immediately below the existing "relname" and "modname". The trailing comma is only needed to clarify it is a tuple if there is only one item being added to the SnmpPlugin defaults.

 

Note that the getSUVolatileData is referring to the method from my class file - make certain you omit the parentheses.

 

In the process method:

 


getdata, tabledata = results

volatiledata = getattr(device,'getSUVolatileData', None)

 

The second statement above loads the dict into the volatiledata variable. The getdata, tabledata=results line was the pre-existing one from the modeler script.

 

Step 3) Alter the modeler routine so that the volatiledata is merged with the regular data if the subscriber is offline

 

If the subscriber is online, the newly modeled Remarks, IP address and Distance are the most recent values, so I want to keep those; if the subscriber is offline, however, I want to keep the old values for the subscriber, found in my volatiledata dict (unless they have never been modeled, in which case I want to substitute "Unavailable" messages):

 

for data in suInfoTable.values():

 


try:

     om = self.objectMap(data)

     om.id = self.prepId("suid%s" % str(om.suID))

     om.snmpindex = int(om.suID)

     *** SNIP ****

     if om.suAssociation != 1:

            # if we successfully modeled the SU before, use the

            # remarks, IP and Distance from the previous model

            if om.suID in volatiledata:

                om.suRemarks = volatiledata[om.suID]['suRemarks']

                om.suIPAddr = volatiledata[om.suID]['suIPAddr']

                om.suDistance = volatiledata[om.suID]['suDistance']

                log.debug( "Subscriber Unit %s offline during modeling, using old values" % om.suID)

            else:

                om.suRemarks = "Remarks Unavailable (SU was offline during remodel)"

                om.suIPAddr = "Unavailable"

                om.suDistance = -1

 

Step 4) Restart the stack and remodel

 

I hope this is helpful to those who want to access such DMD data from within the modeler plugin.

 

Message was edited by: Michael Ducharme

More Like This

  • Retrieving data ...