diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-01-27 12:54:31 -0500 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-07-08 17:05:22 +0100 |
commit | 259897b60b0e4ee00585a8d73521fa4e291eb8da (patch) | |
tree | 4134fad943c53b05830bc964334f6dd5512c3cb6 | |
parent | 2ddc706c7219d0b891304fcb066dea865f8516b5 (diff) | |
download | sos-259897b60b0e4ee00585a8d73521fa4e291eb8da.tar.gz |
[policies/redhat] automatically set tmp_dir in containers
Now that policies have the infrastructure to detect that they
are running in a container and to use the HOST environment
variable if present enable automatic setting of self._tmp_dir in
appriate container environments.
This causes reports to be automatically written to $HOST/var/tmp
when $HOST is set while still allowing users to override the tmp
path manually by specificying --tmp-dir=PATH.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/policies/redhat.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py index f20359d7..3cf40b33 100644 --- a/sos/policies/redhat.py +++ b/sos/policies/redhat.py @@ -79,14 +79,17 @@ class RedHatPolicy(LinuxPolicy): return False def _container_init(self): - """Check if sos is running in a container and if a host sysroot - has been passed in the environment. + """Check if sos is running in a container and perform container + specific initialisation based on ENV_HOST_SYSROOT. """ if ENV_CONTAINER_UUID in os.environ: self._in_container = True if ENV_HOST_SYSROOT in os.environ: self._host_sysroot = os.environ[ENV_HOST_SYSROOT] use_sysroot = self._in_container and self._host_sysroot != '/' + if use_sysroot: + host_tmp_dir = os.path.abspath(self._host_sysroot + self._tmp_dir) + self._tmp_dir = host_tmp_dir return self._host_sysroot if use_sysroot else None def runlevel_by_service(self, name): |