NetTestSlave: Removing double exception handling

Due to several changes in the communication channel between controller
and the slaves, the NetTestSlave class was handling (and logging)
exceptions twice.

This patch removes the first unnecessary processing, so only a single
traceback is logged.

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Common: Adding Colours module

This patch adds a new module with helper functions for colouring
terminal output of LNST to the lnst.Common package.

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Logs: Adding support for terminal output colouring

In this patch, the MultilineFormatter was reimplemented to support
output colouring using the lnst.Common.Colours module.

In case output to terminal is detected, it will add the colouring escape
sequences to the string, so different parts of the logs are printed in
different colours.

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Colouring: Make the colour presets configurable

This patch adds support for a new set of configuration options to allow
the user to change the colour presets. The predefined colour presets are
the following:

    faded       for debugging output
    alert       for important messages
    highlight   highlighted text

    pass        PASS colour
    fail        FAIL colour

    info        the INFO label
    debug       the DEBUG label
    warning     the WARNING label
    error       the ERROR label
    log_header  the date and ip address in each log message

You can override these values on both the controller and the slave by
addint a [colours] section to your conf file and setting different
values for these presets. For example:

[colours]
faded = yellow default false
alert = red default true

Each colour preset comprises of three values:

    (foreground colour, background colour, bold flag)

You can use one of the 16 standard colours or (if your terminal supports
it) use the extended palette. The standard colours are:

    black, red, green, yellow, blue, magenta, cyan,
    light-gray, dark-gray, light-red, light-green,
    light-yellow, light-blue, light-magenta, light-cyan,
    white

The colours from the extended palette can be accessed by their index
as follows (256 colours are available):

    extended(0)
    extended(5)
    ...
    extended(255)

The complete palette can be found here:

    http://misc.flogisoft.com/bash/tip_colors_and_formatting

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestResultSerializer: Coloured summary

This patch contains several modifications of the summary. It is now
coloured in case it is printed to a terminal.

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
lnst-ctl, lnst-slave: Disabling colours

This patch adds a possibility to lnst-ctl and lnst-slave to disable the
output colouring by a CLI options. Either -m or --no-colour can be used.

Signed-off-by: Radek Pazdera <rpazdera@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Fix config_only action

The config_only action did not work correctly since deconfigure
parameter of NetTestController::_cleanup_slaves() has not been used
for bypassing deconfiguration of configured interfaces at all. This
patch fixes this behavior.

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Slave: add NmConfigDevice

This file contains a class hierarchy identical to the NetConfigDevice
class hierarchy. The difference is that NetworkManager is used for
device configuration.

This implementation is still very experimental so it is highly possible
that crashes will occur.

Currently macvlan and team are not supported by NM so these classes are
just placeholders for future implementation.

This class hierarchy will be used when NM is detected to be running on
the slave machine. The reason is that the normal tools won't work anyway
so we might as well try using NM.

Using a combination of NM and ip tools might be possible in future but
for now that would just complicate things.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Slave: use NmConfigDevice when NM is running

This patch adds detection of NM to the NetConfigDevice helper functions.
So when NM is running the classes in NmConfigDevice are used, instead of
those in NetConfigDevice.

I also changed the logged messages in NetTestSlave from error to warning
level, and reworded it so that it is obvious that the implementation is
highly experimental.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Slave Config: add option use_nm

The added configuration option is under section 'environment', it's of
type boolean, so it accepts True/False values. The default value is True.

This option can disable the use of NetworkManager when it is detected
and running.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Use team device instead of pidfile argument

Without this fix LNST will fail if used with teamd-1.3 on team device
deconfiguration. This is a bug both in libteam and LNST. Based on
Jiri Pirko's recommendation I'm removing pidfile generation from LNST code
and using device argument instead for team device removal.

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>