Skip navigation
1402 Views 0 Replies Latest reply: Jun 6, 2012 10:24 PM by Andrey Telepin RSS
Andrey Telepin Rank: White Belt 70 posts since
May 13, 2010
Currently Being Moderated

Jun 6, 2012 10:24 PM

housekeeping before object and ZenPack deletetion

Which work i could do for keep db consistency. My module create object which have two relations:

 

to 'parent'  ("interface", ToOne(ToManyCont,"Products.ZenModel.IpInterface","cbServicePolicy")),

to child     ("classmap", ToManyCont(ToOne, "ZenPacks.atelepin.cbCiscoQOS.cbClassMap", "cbServicePolicy")),

 

When i delete one of the  cbServicePolicy should i implement __del__() or manage_deleteComponent() on cbServicePolicy or  classmap or  both

now my implementation look like:

 

cbServicePolicy:

def __del__(self):

        """

        Destructor for cbServicePolicy object

        """

        OSComponent.__del__()

 

 

    def manage_deleteComponent(self, REQUEST=None):

        """

        Delete cbServicePolicy and all douther cbClassMap

        """      

        for cp in self.classmap():

                 cp.manage_deleteComponent()

  self.getPrimaryParent()._delObject(self.id)

 

 

classmap:

def __del__(self):

        """

        Destructor for classmap object

        """

        OSComponent.__del__()

 

When Module remove:

 

 

def remove(self, app, leaveObjects=False):

        #Remove installed Plugin in time instalation

        dc = app.zport.dmd.Devices.getOrganizer('Network/Router/Cisco')

        cpl = list(getattr(dc, 'zCollectorPlugins'))

        for plugin in self.newplugins:

                 if plugin in cpl: cpl.remove(plugin)

        dc.zCollectorPlugins = list(cpl)

        ZenPackBase.remove(self, app, leaveObjects)

 

        IpInterface._relations = tuple([x for x in IpInterface._relations if x[0] not in ['cbServicePolicy']])

        for dev in self.dmd.Devices.getSubDevices():

                 for int in dev.os.interfaces():

                          int.buildRelations()

More Like This

  • Retrieving data ...

Legend

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