aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2018-11-15 13:51:37 -0500
committerBryn M. Reeves <bmr@redhat.com>2019-03-19 11:43:53 +0000
commitd65099fde910102a8ef47e86a32418797a55345e (patch)
tree2e65c426ea9944549e6820374c8904670bc90885
parent3fa5e6ca47e1ca496b9691671cc4728ff0017aed (diff)
downloadsos-d65099fde910102a8ef47e86a32418797a55345e.tar.gz
[presets] Create preset directory if it does not exist
When attempting to add a preset when /var/lib/sos/presets does not exist, the attempt will fail. Now, if the directory does not exist, sos will attempt to create it. Resolves: #1480 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 8d74caaf..ae85991c 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -385,6 +385,9 @@ class PresetDefaults(object):
odict = self.opts.dict()
pdict = {self.name: {DESC: self.desc, NOTE: self.note, OPTS: odict}}
+ if not os.path.exists(presets_path):
+ os.makedirs(presets_path, mode=0o755)
+
with open(os.path.join(presets_path, self.name), "w") as pfile:
json.dump(pdict, pfile)