def parse_nm_config(cfg):
    try:
        return utils.parse_config(cfg)
    except (ParsingError, TypeError) as e:
        api.current_logger().warning(
            'Error parsing NetworkManager configuration: {}'.format(e))
        return None
Esempio n. 2
0
def test_empty_config():
    config = utils.parse_config()
    facts = SSSDFactsLibrary(config).process()

    assert not facts.enable_files_domain_set
    assert not facts.explicit_files_domain
    assert not facts.pam_cert_auth
Esempio n. 3
0
def parse_repofile(repofile):
    """
    Parse the given repo file.

    :param repofile: Path to the repo file
    :type repofile: str
    :rtype: RepositoryFile
    """
    data = []
    with open(repofile, mode='r') as fp:
        cp = utils.parse_config(fp, strict=False)
        for repoid in cp.sections():
            data.append(_parse_repository(repoid, dict(cp.items(repoid))))
    return RepositoryFile(file=repofile, data=data)
Esempio n. 4
0
def check_dlm_cfgfile():
    """Parse DLM config file"""
    fname = "/etc/dlm/dlm.conf"

    try:
        with open(fname, 'r') as fp:
            cfgs = '[dlm]\n' + fp.read()
    except (OSError, IOError):
        return False

    cfg = utils.parse_config(cfgs)

    if not cfg.has_option('dlm', 'protocol'):
        return False

    proto = cfg.get('dlm', 'protocol').lower()
    return proto in ['sctp', 'detect', '1', '2']
Esempio n. 5
0
    def _parse(r):
        with open(r, mode='r') as fp:
            cp = utils.parse_config(fp)

            for section in cp.sections():
                prepared = {'repoid': section, 'additional_fields': {}}
                data = dict(cp.items(section))
                for key in data.keys():
                    if key in RepositoryData.fields:
                        if isinstance(RepositoryData.fields[key],
                                      fields.Boolean):
                            data[key] = asbool(data[key])
                        prepared[key] = data[key]
                    else:
                        prepared['additional_fields'][key] = data[key]
                prepared['additional_fields'] = json.dumps(
                    prepared['additional_fields'])
                yield RepositoryData(**prepared)
Esempio n. 6
0
def check_dlm_cfgfile(_open=open):
    """Parse DLM config file.
    :param _open: object behind opening a file. Might be replaced
        by mocked one for the purpose of testing
    """
    fname = '/etc/dlm/dlm.conf'

    try:
        with _open(fname, 'r') as fp:
            cfgs = '[dlm]\n' + fp.read()
    except (OSError, IOError):
        return False

    cfg = utils.parse_config(cfgs)

    if not cfg.has_option('dlm', 'protocol'):
        return False

    proto = cfg.get('dlm', 'protocol').lower()
    return proto in ['sctp', 'detect', '1', '2']
 def __init__(self, content):
     parser = utils.parse_config(StringIO(textwrap.dedent(content)))
     self.config = parser
def get_config(content):
    parser = utils.parse_config(StringIO(textwrap.dedent(content)))
    return parser
def test_get_domain_section():
    config = utils.parse_config()
    library = SSSDFactsLibrary(config)

    assert library.get_domain_section("ldap") == "domain/ldap"
def test_empty_config():
    config = utils.parse_config()
    facts = SSSDFactsLibrary(config).process()

    assert not facts.domains