Combine debian and ubuntu basic log gathering classes

The plugin list shows logs twice for Ubuntu and Debian systems. Since the
variations between the 2 are minimal we are combining those classes.

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
Fix file and command collection regressions

The automation used to convert to add_copy_specs() and
add_cmd_outputs() left a few missing and stray commas in file
and command lists, for e.g. causing two lsusb commands to be
concatenated:

  Running 71/74: usb...
[plugin:usb] collecting path '/sys/bus/usb'
[plugin:usb] collecting output of 'lsusblsusb -v'
[plugin:usb] collecting output of 'lsusb -t'

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Really fix file and command collection regressions

Previous patch was missing the hunks for plugins other than
usb:

       modified:   sos/plugins/general.py
       modified:   sos/plugins/logs.py
       modified:   sos/plugins/networking.py
       modified:   sos/plugins/qpid.py
       modified:   sos/plugins/s390.py

The automation used to convert to add_copy_specs() and
add_cmd_outputs() left a few missing and stray commas in file
and command lists, for e.g. causing two lsusb commands to be
concatenated:

  Running 71/74: usb...
[plugin:usb] collecting path '/sys/bus/usb'
[plugin:usb] collecting output of 'lsusblsusb -v'
[plugin:usb] collecting output of 'lsusb -t'

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Add default Plugin.setup() method

Adding a default setup() method to the base Plugin class allows
useful plugins to be written declaratively by setting the 'files'
and 'packages' members of the subclass, e.g.:

    class FooPlugin(Plugin):
	plugin_name = 'foo'
        packages = ('foo',)
        files = ('/etc/foo.conf',)

Creates a plugin class named 'foo' that will run whenever the
'foo' package is installed or the '/etc/foo.conf' file exists.

The method calls self.add_copy_specs() with the plugin's files
list.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Remove shell redirects from OpenStack Nova plugin

Shell redirect syntax is no longer supported and will fail. Remove
its use from the OpenStack Nova plugin.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Remove shell pipeline from OpenStack Nova plugin

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Document dmraid options

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix dmraid metadata collection and make it optional

The dmraid command writes metadata dumps into the current working
directory. This is normally /tmp meaning that the files are
created outside the archive.

Use runat to change directory to the appropriate path in the
archive before running the command and add an option to control
metadata collection.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix debugfs_path usage in kvm plugin

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Dont double import logging module

Probably doesnt matter but for cleanliness sake.

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
Add OPAL log to collected file list

The OPAL console log used to live under /sys/kernel/debug/powerpc so it
was collected as part of that glob. This patch adds the new location at
/sys/firmware/opal/msglog to the list of collected files.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
[plugins/maas] added `maas commissioning list` output to the command output list
Foward maas patch code to latest trunk and update authors

Closes #272

Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
Remove deb tasks in Makefile

Isn't really necessary anymore since we have an automated build kick
off everytime a commit is made.

https://code.launchpad.net/~sosreport/+archive/ppa

Closes #234

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
Format the add_copy_specs method in juju plugin

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
Fix style and formatting in Plugin class

Make code formatting more consistent and readable by removing very
long lines and using consistent style for multi-line function
prototypes and calls. Also fix a couple of comment typos.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Use uft-8 encoding for archive IO

When reading and writing files within the archive class use the
codecs module and set the 'utf-8' encoding. This prevents encoding
exceptions if a plugin passes a unicode string to add_string() or
if a plugin attempts to read unicode encoded data from an archive
file via the open_file() method.

Fixes Issue #275.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Fix command parameter aliasing and exception handling

The addition of 'runat' exposed a bug in the parameter passing for
commands. We pack a tuple into a list in add_cmd_output() and then
unpack it in collect_cmd_output(). These functions need to be
careful in the use of positional vs. keyword arguments; passing
keywords as though they were positional can lead to e.g. an
integer timeout value appearing in the tuple member for
'suggest_filename' causing an exception when we attempt to pass
the value to get_cmd_output_now().

Fix this by ensuring that all keyword args are passed explicitly
through these functions and improve the debug logging by printing
the tuple we are packing/unpacking.

This also removes the exception handling block from the function
collect_cmd_output() - this routine should allow exceptions to
propagate up so that they can be handled by the --debug logic.

The 'command not found' case is already logged in the generic
get_command_output() wrapper.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Remove useless else on loop statement in TarFileArchive

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Log an error and exit with non-zero status if archive setup fails

Currently unexpected exceptions during archive setup log a python
backtrace and exit with success. Exit with failure (1) when this
happens and log a message indicating the exception is unhandled
before printing the backtrace.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>