Skip navigation
1046 Views 1 Reply Latest reply: Jun 11, 2012 4:24 AM by amitk RSS
amitk Rank: White Belt 26 posts since
Apr 13, 2009
Currently Being Moderated

May 25, 2012 5:40 AM

can not change ProdState using script

After I upgraded zenoss from 2.5.2 to 3.2.1, my script (which was working fine) suddently stopped working.

 

---------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env /usr/local/zenoss/zenoss/bin/python

 

import Globals

import re

 

from Products.ZenUtils.ZenScriptBase import ZenScriptBase

from transaction import commit

 

dmd = ZenScriptBase(connect=True).dmd

 

for line in file ('/usr/local/zenoss/scripts/.cr_maint_node_list'):

         fl = line.strip().split(',')[0]

         if dmd.Devices.findDevice(fl):

             d = dmd.Devices.findDevice(fl)

             d.setProdState(300)

             commit()

---------------------------------------------------------------------------------------------------------------------

 

its giving following error now:

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Traceback (most recent call last):

  File "./mark_maint_node.py", line 15, in <module>

    d.setProdState(300)

  File "/state/partition1/zenoss/zenoss/Products/ZenModel/Device.py", line 1346, in setProdState

    self.primaryAq().index_object()

  File "/state/partition1/zenoss/zenoss/Products/ZenModel/Device.py", line 1967, in index_object

    super(Device, self).index_object(idxs)

  File "/state/partition1/zenoss/zenoss/Products/ZenModel/ZenModelRM.py", line 353, in index_object

    cat.catalog_object(self, self.getPrimaryId(), idxs=idxs)

  File "/usr/local/zenoss/python/lib/python2.6/site-packages/Zope2-2.12.1-py2.6-linux-x86_64.egg/Products/ZCatalog/ZCatalog.py", line 529, in catalog_object

    update_metadata=update_metadata)

  File "/usr/local/zenoss/python/lib/python2.6/site-packages/Zope2-2.12.1-py2.6-linux-x86_64.egg/Products/ZCatalog/Catalog.py", line 348, in catalogObject

    self.updateMetadata(object, uid)

  File "/usr/local/zenoss/python/lib/python2.6/site-packages/Zope2-2.12.1-py2.6-linux-x86_64.egg/Products/ZCatalog/Catalog.py", line 278, in updateMetadata

    newDataRecord = self.recordify(object)

  File "/usr/local/zenoss/python/lib/python2.6/site-packages/Zope2-2.12.1-py2.6-linux-x86_64.egg/Products/ZCatalog/Catalog.py", line 417, in recordify

    if(attr is not MV and safe_callable(attr)): attr=attr()

  File "/state/partition1/zenoss/zenoss/Products/ZenModel/Device.py", line 2303, in details

    dinfo = IInfo(self)

TypeError: ('Could not adapt', <Device at /zport/dmd/Devices/Server/Linux/drdblogin/devices/drdlogin0010.en.desres.deshaw.com>, <InterfaceClass Products.Zuul.interfaces.info.IInfo>)

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

But using zendmd, it works fine:

 

---------------------------------------------------------------------------------------------------------------------

 

>>> for line in file ('/usr/local/zenoss/scripts/.cr_maint_node_list'):

...           fl = line.strip().split(',')[0]

...           if dmd.Devices.findDevice(fl):

...                d = dmd.Devices.findDevice(fl)

...                d.setProdState(300)

...

>>> commit()

 

---------------------------------------------------------------------------------------------------------------------

 

PS: The same script is working fine on another instance of zenoss which was also upgraded same way.

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points