Archived community.zenoss.org | full text search
Skip navigation
5872 Views 1 Reply Latest reply: Apr 7, 2010 11:22 AM by mistich RSS
mistich Rank: White Belt 30 posts since
Sep 25, 2007
Currently Being Moderated

Apr 7, 2010 11:22 AM

adding a python script to a zenpack

I have a script /zport/dmd/findDeviceByIp I want to add it to the zenpack where would I add it in my init.py

 

so that when called you can call it under /zport/dmd not under /zport/dmd/devices

 

Thanks,

Pete

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    1. Apr 7, 2010 11:35 AM (in response to mistich)
    Re: adding a python script to a zenpack

    You'd want to monkeypatch it onto the DataRoot class.

     

    Versions 2.4 and later..

    from Products.ZenUtils.Utils import monkeypatch

    @monkeypatch('Products.ZenModel.DataRoot.DataRoot')

    def findDeviceByIp(self, ip=None):

        """

        I need to have a method comment to be usable via a REST or XML-RPC call.

        """

        pass

     

    Versions earlier than 2.4..

    from Products.ZenModel.DataRoot import DataRoot

    def DataRoot_findDeviceByIp(self, ip=None):

        """

        I need to have a method comment to be usable via a REST or XML-RPC call.

        """

        pass

     

    DataRoot.findDeviceByIp = DataRoot_findDeviceByIp

More Like This

  • Retrieving data ...

Legend

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