Package Products :: Package ZenHub :: Module invalidationoid |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenHub.invalidationoid

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2011, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  import logging
    12  from zope.interface import implements
    13  from zope.component import adapts
    14  from Products.ZenModel.DeviceComponent import DeviceComponent
    15  from Products.ZenModel.DeviceHW import DeviceHW
    16  from Products.ZenRelations.PrimaryPathObjectManager import PrimaryPathObjectManager
    17  from Products.ZenHub.interfaces import IInvalidationOid
    18
    19  log = logging.getLogger('zen.InvalidationOid')
    20
    21
    22 -class DefaultOidTransform(object):
    23      implements(IInvalidationOid)
    24      adapts(PrimaryPathObjectManager)
    25
    26 -    def __init__(self, obj):
    27          self._obj = obj
    28
    29 -    def transformOid(self, oid):
    30          return oid
    31
    32 -class DeviceOidTransform(object):
    33      implements(IInvalidationOid)
    34
    35 -    def __init__(self, obj):
    36          self._obj = obj
    37
    38 -    def transformOid(self, oid):
    39          #get device oid
    40          result = oid
    41          device = getattr(self._obj, 'device', lambda : None)()
    42          if device:
    43              result = device._p_oid
    44              log.debug("oid for %s changed to device oid for %s", self._obj, device )
    45          return result
    46