Пример #1
0
        def my_sieve(raw_data):
            return_list = []

            log.debug('SIEVE: pattern=%r, raw_data_len=%d', matcher.pattern, len(raw_data))
            # do not descend into this loop unless we are at log level trace...
            if log.isEnabledFor('trace'):
                temp = raw_data[:]
                while temp:
                    log.trace('SIEVE: raw_data: %s', temp[:32].encode('hex'))
                    if len(temp) > 32:
                        temp = temp[32:]
                    else:
                        temp = ''

            for match in matcher.finditer(raw_data):
                # if sentinel value present in this slice it is invalid
                if not SCAN_START_SENTINEL in raw_data[match.start():match.end()]:
                    return_list.append((match.start(), match.end()))

            return return_list
Пример #2
0
    def _check_sync(self):
        """
        This will be the main operation related with checking that the
        information on this platform agent (and sub-platforms) is consistent
        with the information in the external network rooted at the
        corresponding platform, then publishing relevant notification events.

        For the moment, it only reports the value of the external checksum
        and the value of the local checksum.

        @todo complete implementation

        @return {'external_checksum': string, 'local_checksum': string}
        """
        log.debug("%r: _check_sync: getting external checksum...",
                  self._platform_id)

        external_checksum = self.get_external_checksum()
        local_checksum = self._pnode.compute_checksum()

        if log.isEnabledFor(logging.DEBUG):  # pragma: no cover
            filename = "logs/checksum_check_from_driver.yml"
            try:
                from mi.platform.util.network_util import NetworkUtil
                open(filename,
                     "w").write(NetworkUtil.serialize_pnode(self._pnode))
            except Exception as e:
                log.debug("%r: cannot write %s: %s", self._platform_id,
                          filename, e)

        result = {
            'external_checksum': external_checksum,
            'local_checksum': local_checksum
        }

        log.debug("%r: _check_sync: result: %s", self._platform_id, result)

        # TODO - if checksums are different, determine what sub-components are
        # in disagreement; publish relevant event(s), etc.

        return result
Пример #3
0
    def _check_sync(self):
        """
        This will be the main operation related with checking that the
        information on this platform agent (and sub-platforms) is consistent
        with the information in the external network rooted at the
        corresponding platform, then publishing relevant notification events.

        For the moment, it only reports the value of the external checksum
        and the value of the local checksum.

        @todo complete implementation

        @return {'external_checksum': string, 'local_checksum': string}
        """
        log.debug("%r: _check_sync: getting external checksum...", self._platform_id)

        external_checksum = self.get_external_checksum()
        local_checksum = self._pnode.compute_checksum()

        if log.isEnabledFor(logging.DEBUG):  # pragma: no cover
            filename = "logs/checksum_check_from_driver.yml"
            try:
                from mi.platform.util.network_util import NetworkUtil
                open(filename, "w").write(NetworkUtil.serialize_pnode(self._pnode))
            except Exception as e:
                log.debug("%r: cannot write %s: %s", self._platform_id, filename, e)

        result = {'external_checksum': external_checksum,
                  'local_checksum': local_checksum}

        log.debug("%r: _check_sync: result: %s", self._platform_id, result)

        # TODO - if checksums are different, determine what sub-components are
        # in disagreement; publish relevant event(s), etc.

        return result