candlepin/python-rhsm — pull request #121 by dgoodwin (2014-06-09 12:54:22+00:00)
Title: Detect when operating in container mode and load host system's config.

With the end goal of being able to generate correct redhat.repo for a
container, we need a way to access the host's /etc/rhsm configuration in as
futureproof a way as possible. (as this may change) To accommodate this we
check for existence of a (presumably) symlink at /etc/rhsm-host, and if found,
we assume we're operating inside a container and load the host's config. The
symlink allows for possibility of the actual location of host's config
changing, and *not* re-using /etc/rhsm/ helps prevent any complications with
rpm's and file ownership. (as /etc/rhsm is owned by our packages)

However there is an additional problem with the contents of rhsm.conf, while it
may live at /etc/rhsm-host in container mode, it still contains two properties
referencing full paths under /etc/rhsm for ca certificates and the CDN cert. We
need the hosts values in a Satellite use-case, so these must be adjusted.

To accommodate this we check if we're in container mode, and if so load a
config sub-class which replaces /etc/rhsm with /etc/rhsm-host in these values,
if it looks like we should.

A similar replacement will be done for entitlement directory at
/etc/pki/entitlement-host for the same reasons.

![rdmjks0](https://cloud.githubusercontent.com/assets/51265/3216630/1c05d81a-efd5-11e3-8bb1-251d72bbbab8.gif)