aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Jaggars <jjaggars@redhat.com>2012-02-14 09:27:36 -0600
committerJesse Jaggars <jjaggars@redhat.com>2012-02-14 09:27:36 -0600
commit80e99a2d290b10ed908320c97ca11874aac422b0 (patch)
tree80775693e8ff4eb89a9fb37c174f6ea339cda01e
parent1132b767fb4d83bb07925641c78223a7388ff3c2 (diff)
downloadsos-80e99a2d290b10ed908320c97ca11874aac422b0.tar.gz
adding root_symlink support under tarfiles and fixing getOption behavior
-rw-r--r--sos/plugins/__init__.py6
-rw-r--r--sos/utilities.py10
-rw-r--r--tests/option_tests.py10
3 files changed, 25 insertions, 1 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 68c5b477..576196de 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -311,7 +311,9 @@ class Plugin(object):
for name, parms in izip(self.optNames, self.optParms):
if _check(name):
- return parms['enabled']
+ val = parms['enabled']
+ if val != None:
+ return val
for key, value in self.cInfo.get('global_plugin_options', {}).iteritems():
if _check(key):
@@ -442,6 +444,8 @@ class Plugin(object):
if not (status == 127 or status == 32512): # if not command_not_found
outfn_strip = outfn[len(self.cInfo['cmddir'])+1:]
self.archive.add_string(shout, outfn)
+ if root_symlink:
+ self.archive.add_link(outfn, root_symlink)
else:
self.soslog.debug("could not run command: %s" % exe)
outfn = None
diff --git a/sos/utilities.py b/sos/utilities.py
index e91586de..015c6c8e 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -296,6 +296,9 @@ class Archive(object):
name = os.path.split(self._name)[-1]
return os.path.join(name, src.lstrip(os.sep))
+ def add_link(self, dest, link_name):
+ pass
+
class TarFileArchive(Archive):
@@ -329,6 +332,13 @@ class TarFileArchive(Archive):
tar_info.mtime = time.time()
self.tarfile.addfile(tar_info, StringIO(content))
+ def add_link(self, dest, link_name):
+ tar_info = tarfile.TarInfo(name=self.prepend(link_name))
+ tar_info.type = tarfile.SYMTYPE
+ tar_info.linkname = dest
+ tar_info.mtime = time.time()
+ self.tarfile.addfile(tar_info, None)
+
def open_file(self, name):
try:
self.tarfile.close()
diff --git a/tests/option_tests.py b/tests/option_tests.py
index 06f048a4..03804dec 100644
--- a/tests/option_tests.py
+++ b/tests/option_tests.py
@@ -10,9 +10,13 @@ class GlobalOptionTest(unittest.TestCase):
self.commons = {
'global_plugin_options': {
'test_option': 'foobar',
+ 'baz': None,
+ 'empty_global': True,
},
}
self.plugin = Plugin(self.commons)
+ self.plugin.optNames = ['baz', 'empty']
+ self.plugin.optParms = [{'enabled': False}, {'enabled': None}]
def test_simple_lookup(self):
self.assertEquals(self.plugin.getOption('test_option'), 'foobar')
@@ -20,5 +24,11 @@ class GlobalOptionTest(unittest.TestCase):
def test_multi_lookup(self):
self.assertEquals(self.plugin.getOption(('not_there', 'test_option')), 'foobar')
+ def test_cascade(self):
+ self.assertEquals(self.plugin.getOption(('baz')), False)
+
+ def test_none_should_cascade(self):
+ self.assertEquals(self.plugin.getOption(('empty', 'empty_global')), True)
+
if __name__ == "__main__":
unittest.main()