<p>I'm working on a tool that needs to be able to detect if a host running RHEL 5 or 6 has a bad yum repository (host is unreachable, directory does not exist, etc.) and report exactly which repository or repositories are bad. Originally (and before I discovered that yum has a Python API), I would do the following:</p>
<p>1. Run a Python script that parses all of the files under /etc/yum.repos.d and prints out the names of all enabled repositories.<br>
2. For each reported host, run: yum --disablerepo='*' --enablerepo=<repo> repolist<br>
3. If any of those commands return a non-zero exit code, report them as bad.</p>
<p>This worked perfectly on RHEL 5 as recently as 5.7 (running yum 3.2.22), although I haven't tested on RHEL 5.8. However, it looks like something changed in the version of yum that ship with later RHEL versions. In RHEL 6.2 (yum 3.2.29), "yum repolist" now appears to skip bad repositories, so I can't tell by the exit code if the repository is bad ("yum check-update still returns the expected exit code). And on RHEL 6.3 (a newer build of yum 3.2.29), I have one machine that doesn't seem to consider bad repositories worthy of reporting via exit code at all (even "yum check-update" returns 0 if a repository is bad), and I have another machine (running CentOS, but still yum 3.2.29) that returned with exit code 1 if a repository is bad, just as I would expect.</p>
<p>Anyone know what's behind this change in behavior? The yum changelog offers no clues.</p>
<p>Bonus question: for my purposes, would it be easier to write a Python script that uses yum's sparsely-documented API than to execute it from the command line and rely on exit codes? (I do know Python pretty well, but the documentation for the yum API is pretty rudimentary.)<br>
</p>
<p>Thanks in advance.</p>
<p>-- <br>
Lincoln Peters<br>
<<a href="mailto:anfrind@gmail.com">anfrind@gmail.com</a>></p>