예제 #1
0
    def remote_applyDataMaps(self, device, maps, devclass=None, setLastCollection=False):
        from Products.DataCollector.ApplyDataMap import ApplyDataMap
        device = self.getPerformanceMonitor().findDevice(device)
        adm = ApplyDataMap(self)
        adm.setDeviceClass(device, devclass)
        def inner(map):
            def action():
                start_time = time.time()
                completed= bool(adm._applyDataMap(device, map))
                end_time=time.time()-start_time
                if hasattr(map, "relname"):
                    log.debug("Time in _applyDataMap for Device %s with relmap %s objects: %.2f", device.getId(),map.relname,end_time)
                elif hasattr(map,"modname"):
                    log.debug("Time in _applyDataMap for Device %s with objectmap, size of %d attrs: %.2f",device.getId(),len(map.items()),end_time)
                else:
                    log.debug("Time in _applyDataMap for Device %s: %.2f . Could not find if relmap or objmap",device.getId(),end_time)
                return completed
            return self._do_with_retries(action)

        changed = False
        for map in maps:
            result = inner(map)
            changed = changed or result

        if setLastCollection:
            self._setSnmpLastCollection(device)

        return changed
예제 #2
0
    def remote_applyDataMaps(self,
                             device,
                             maps,
                             devclass=None,
                             setLastCollection=False):
        from Products.DataCollector.ApplyDataMap import ApplyDataMap
        device = self.getPerformanceMonitor().findDeviceByIdExact(device)
        adm = ApplyDataMap(self)
        adm.setDeviceClass(device, devclass)

        changed = False
        #with pausedAndOptimizedIndexing():
        for map in maps:
            # make a copy because ApplyDataMap will modify the data map.
            datamap = copy.deepcopy(map)

            preadmdata = self.pre_adm_check(datamap, device)

            start_time = time.time()
            if adm._applyDataMap(device, datamap, commit=False):
                changed = True

            end_time = time.time() - start_time
            changesubject = "device" if changed else "nothing"
            if hasattr(datamap, "relname"):
                log.debug(
                    "Time in _applyDataMap for Device %s with relmap %s objects: %.2f, %s changed.",
                    device.getId(), datamap.relname, end_time, changesubject)
            elif hasattr(datamap, "modname"):
                log.debug(
                    "Time in _applyDataMap for Device %s with objectmap, size of %d attrs: %.2f, %s changed.",
                    device.getId(), len(datamap.items()), end_time,
                    changesubject)
            else:
                log.debug(
                    "Time in _applyDataMap for Device %s: %.2f . Could not find if relmap or objmap, %s changed.",
                    device.getId(), end_time, changesubject)

            self.post_adm_process(datamap, device, preadmdata)

        if setLastCollection:
            device.setSnmpLastCollection()

        return changed
예제 #3
0
    def remote_applyDataMaps(self, device, maps, devclass=None, setLastCollection=False):
        from Products.DataCollector.ApplyDataMap import ApplyDataMap
        device = self.getPerformanceMonitor().findDeviceByIdExact(device)
        adm = ApplyDataMap(self)
        adm.setDeviceClass(device, devclass)

        changed = False
        #with pausedAndOptimizedIndexing():
        for map in maps:
            preadmdata = self.pre_adm_check(map, device)

            start_time = time.time()
            if adm._applyDataMap(device, map, commit=False):
                changed = True

            end_time = time.time() - start_time
            changesubject = "device" if changed else "nothing"
            if hasattr(map, "relname"):
                log.debug(
                    "Time in _applyDataMap for Device %s with relmap %s objects: %.2f, %s changed.",
                    device.getId(),
                    map.relname,
                    end_time,
                    changesubject)
            elif hasattr(map, "modname"):
                log.debug(
                    "Time in _applyDataMap for Device %s with objectmap, size of %d attrs: %.2f, %s changed.",
                    device.getId(),
                    len(map.items()),
                    end_time,
                    changesubject)
            else:
                log.debug(
                    "Time in _applyDataMap for Device %s: %.2f . Could not find if relmap or objmap, %s changed.",
                    device.getId(),
                    end_time,
                    changesubject)

            self.post_adm_process(map, device, preadmdata)

        if setLastCollection:
            device.setSnmpLastCollection()

        return changed
    def remote_applyDataMaps(self, device, maps, devclass=None, setLastCollection=False):
        from Products.DataCollector.ApplyDataMap import ApplyDataMap
        device = self.getPerformanceMonitor().findDevice(device)
        adm = ApplyDataMap(self)
        adm.setDeviceClass(device, devclass)
        def inner(map):
            def action():
                return bool(adm._applyDataMap(device, map))
            return self._do_with_retries(action)

        changed = False
        for map in maps:
            result = inner(map)
            changed = changed or result

        if setLastCollection:
            self._setSnmpLastCollection(device)

        return changed
예제 #5
0
    def remote_applyDataMaps(self,
                             device,
                             maps,
                             devclass=None,
                             setLastCollection=False):
        from Products.DataCollector.ApplyDataMap import ApplyDataMap
        device = self.getPerformanceMonitor().findDevice(device)
        adm = ApplyDataMap(self)
        adm.setDeviceClass(device, devclass)

        def inner(map):
            def action():
                start_time = time.time()
                completed = bool(adm._applyDataMap(device, map))
                end_time = time.time() - start_time
                if hasattr(map, "relname"):
                    log.debug(
                        "Time in _applyDataMap for Device %s with relmap %s objects: %.2f",
                        device.getId(), map.relname, end_time)
                elif hasattr(map, "modname"):
                    log.debug(
                        "Time in _applyDataMap for Device %s with objectmap, size of %d attrs: %.2f",
                        device.getId(), len(map.items()), end_time)
                else:
                    log.debug(
                        "Time in _applyDataMap for Device %s: %.2f . Could not find if relmap or objmap",
                        device.getId(), end_time)
                return completed

            return self._do_with_retries(action)

        changed = False
        for map in maps:
            result = inner(map)
            changed = changed or result

        if setLastCollection:
            self._setSnmpLastCollection(device)

        return changed