def _parse_tests(self, tag):

        parser = nagios_objects.ObjectParser(
                self._nagios_obj, ('host', 'service'))
        hosts = {}
        tests = []

        for host in parser['host']:
            # Make sure host address is valid
            addr = host.get('address', host['host_name'])
            try:
                addr = socket.gethostbyname(addr)
            except socket.gaierror, ex:
                raise errors.InitError(
                    "Failed to resolve '%s': %s" % (addr, ex))
            host.setdefault('address', addr)
            hosts[host['host_name']] = host

        for service in parser['service']:
            host = hosts[service['host_name']]
            if "_TEST" not in service:
                continue
            elif tag and service.get("_TAG", host.get('_TAG', None)) != tag:
                continue

            test_defaults = {
                    'host': service['host_name'],
                    'addr': host['address'],
                    'description': service['service_description']}

            test_overrides = {}

            for key in service:
                if len(key) < 2 or key[0] != "_":
                    continue

                # save all vars that start with '_'
                # coil is normally in lower case and Nagios is case insensitive
                test_overrides[key[1:].lower()] = service[key]

            log.debug("Found Nagios service: %s", test_defaults)
            log.debug("Service overrides: %s", test_overrides)
            tests.append((test_defaults, test_overrides))

        return tests
Store a cube in the annotation database
dataset/ETHPy150Open marineam/nagcat/python/nagcat/nagios.py/NagcatNagios._parse_tests--crossover with--dataset/ETHPy150Open neurodata/ndstore/ocpca/ocpcadb.py/OCPCADB.putCube