Exemplo n.º 1
0
    def notifyAffectedDevices(self, object, event):
        # FIXME: This is horrible
        with gc_cache_every(1000, db=self.dmd._p_jar._db):
            if isinstance(object, self._getNotifiableClasses()):
                self._reconfigureIfNotify(object)
            else:
                if isinstance(object, Device):
                    return
                # something else... mark the devices as out-of-date
                while object:
                    # Don't bother with privately managed objects; the ZenPack
                    # will handle them on its own
                    if is_private(object):
                        return
                    # walk up until you hit an organizer or a device
                    if isinstance(object, DeviceClass):
                        uid = (self.__class__.__name__, self.instance)
                        self._notifier.notify_subdevices(object, uid, self._notifyAll)
                        break

                    if isinstance(object, Device):
                        self._notifyAll(object)
                        break

                    object = aq_parent(object)
Exemplo n.º 2
0
    def notifyAffectedDevices(self, object, event):
        # FIXME: This is horrible
        with gc_cache_every(1000, db=self.dmd._p_jar._db):
            if isinstance(object, self._getNotifiableClasses()):
                self._reconfigureIfNotify(object)
            else:
                if isinstance(object, Device):
                    return
                # something else... mark the devices as out-of-date
                while object:
                    # Don't bother with privately managed objects; the ZenPack
                    # will handle them on its own
                    if is_private(object):
                        return
                    # walk up until you hit an organizer or a device
                    if isinstance(object, DeviceClass):
                        uid = (self.__class__.__name__, self.instance)
                        self._notifier.notify_subdevices(object, uid, self._notifyAll)
                        break

                    if isinstance(object, Device):
                        self._notifyAll(object)
                        break

                    object = aq_parent(object)
Exemplo n.º 3
0
    def notifyAffectedDevices(self, object, event):
        # FIXME: This is horrible
        with gc_cache_every(1000, db=self.dmd._p_jar._db):
            if isinstance(object, self._getNotifiableClasses()):
                self._reconfigureIfNotify(object)
            else:
                if isinstance(object, Device):
                    return
                # something else... mark the devices as out-of-date
                template = None
                while object:
                    # Don't bother with privately managed objects; the ZenPack
                    # will handle them on its own
                    if is_private(object):
                        return
                    # walk up until you hit an organizer or a device
                    if isinstance(object, RRDTemplate):
                        template = object
                    if isinstance(object, DeviceClass):
                        uid = (self.__class__.__name__, self.instance)
                        devfilter = None
                        if template:
                            def hasTemplate(device):
                                if issubclass(template.getTargetPythonClass(), Device):
                                    result = template in device.getRRDTemplates()
                                    if result:
                                        self.log.debug("%s bound to template %s", device.getPrimaryId(), template.getPrimaryId())
                                    else:
                                        self.log.debug("%s not bound to template %s", device.getPrimaryId(), template.getPrimaryId())
                                    return result
                                else:
                                    # check components, Too expensive?
                                    for comp in device.getMonitoredComponents(type=template.getTargetPythonClass().meta_type):
                                        result = template in comp.getRRDTemplates()
                                        if result:
                                            self.log.debug("%s bound to template %s", comp.getPrimaryId(), template.getPrimaryId())
                                            return True
                                        else:
                                            self.log.debug("%s not bound to template %s", comp.getPrimaryId(), template.getPrimaryId())
                                    return False
                            devfilter = hasTemplate
                        self._notifier.notify_subdevices(object, uid, self._notifyAll, devfilter)
                        break

                    if isinstance(object, Device):
                        self._notifyAll(object)
                        break

                    object = aq_parent(object)
Exemplo n.º 4
0
    def notifyAffectedDevices(self, object, event):
        # FIXME: This is horrible
        with gc_cache_every(1000, db=self.dmd._p_jar._db):
            if isinstance(object, self._getNotifiableClasses()):
                self._reconfigureIfNotify(object)
            else:
                if isinstance(object, Device):
                    return
                # something else... mark the devices as out-of-date
                template = None
                while object:
                    # Don't bother with privately managed objects; the ZenPack
                    # will handle them on its own
                    if is_private(object):
                        return
                    # walk up until you hit an organizer or a device
                    if isinstance(object, RRDTemplate):
                        template = object
                    if isinstance(object, DeviceClass):
                        uid = (self.__class__.__name__, self.instance)
                        devfilter = None
                        if template:
                            def hasTemplate(device):
                                if issubclass(template.getTargetPythonClass(), Device):
                                    result = template in device.getRRDTemplates()
                                    if result:
                                        self.log.debug("%s bound to template %s", device.getPrimaryId(), template.getPrimaryId())
                                    else:
                                        self.log.debug("%s not bound to template %s", device.getPrimaryId(), template.getPrimaryId())
                                    return result
                                else:
                                    # check components, Too expensive?
                                    for comp in device.getMonitoredComponents(type=template.getTargetPythonClass().meta_type):
                                        result = template in comp.getRRDTemplates()
                                        if result:
                                            self.log.debug("%s bound to template %s", comp.getPrimaryId(), template.getPrimaryId())
                                            return True
                                        else:
                                            self.log.debug("%s not bound to template %s", comp.getPrimaryId(), template.getPrimaryId())
                                    return False
                            devfilter = hasTemplate
                        self._notifier.notify_subdevices(object, uid, self._notifyAll, devfilter)
                        break

                    if isinstance(object, Device):
                        self._notifyAll(object)
                        break

                    object = aq_parent(object)
Exemplo n.º 5
0
    def notifyAffectedDevices(self, object, event):
        if isinstance(object, Device):
            return

        # something else... mark the devices as out-of-date
        from Products.ZenModel.DeviceClass import DeviceClass

        while object:
            # Don't bother with privately managed objects; the ZenPack
            # will handle them on its own
            if is_private(object):
                return
            # walk up until you hit an organizer or a device
            if isinstance(object, DeviceClass):
                uid = (self.__class__.__name__, self.instance)
                self._notifier.notify_subdevices(object, uid, self.notifyAll)
                break

            if isinstance(object, Device):
                self.notifyAll(object)
                break

            object = aq_parent(object)
    def notifyAffectedDevices(self, object, event):
        if isinstance(object, Device):
            return

        # something else... mark the devices as out-of-date
        from Products.ZenModel.DeviceClass import DeviceClass

        while object:
            # Don't bother with privately managed objects; the ZenPack
            # will handle them on its own
            if is_private(object):
                return
            # walk up until you hit an organizer or a device
            if isinstance(object, DeviceClass):
                uid = (self.__class__.__name__, self.instance)
                self._notifier.notify_subdevices(object, uid, self.notifyAll)
                break

            if isinstance(object, Device):
                self.notifyAll(object)
                break

            object = aq_parent(object)