NetTestController: fix typo in log message

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: fix ctl_clean_exit typos

The internal variable ctl_clean_exit in the SlaveMethods class was
incorrectly used a few types, python didn't pick this up because of it's
dynamic nature... This however caused that the cleanup didn't work
properly. This commit fixes that.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
ConnectionHandler: retrieve ALL messages from connections

The check_connections method only recieved one message per file
descriptor. This wasn't a problem because the other messages would be
retrieved in the next iteration. However this way we will be able to
order the recieved messages, so that messages from the controller can be
handled last, after all recieved updates (e.g. netlink).

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: handle ctl messages last

The get_messages method of the ServerHandler class will now return
messages sorted so that messages from the controller are last. This
presents a kind of optimization resulting in updates taking place before
the controller calls a method.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
InterfaceManager module created

The module contains two classes:
InterfaceManager
    - will represent the device database of the slave machine
    - handles creation of soft devices, name assignment included
    - handles netlink messages by updating the database
    - provides access to local devices by kernel ifindex of the device
      (used for unique identification on the machine)
    - contains controller id to slave device mapping - created on
      controller interface initialization by the HWADDR specified in the
      controllers pool files. The controller therefore only needs to
      know the id of the device and the slave will translate that to the
      specific device.
Device
    - will represent a device record in the InterfaceManager database
    - provides a configuration interface that will use the *ConfigDevice
      objects.
    - will provide an interface to accessing the most common device
      attributes (such as IP address)
    - supports updates based on netlink messages and will be able to
      send update messages to the controller if any attributes are
      changed

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetConfigDevice: InterfaceManager integration

The NetConfigDevice module now supports the new InterfaceManager module
instead of the old NetConfig way. I also refactored certain variable
names so that they make more sense and are consistent with the rest of
the code.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NmConfigDevice: InterfaceManager integration

The NmConfigDevice module now supports the new InterfaceManager module
instead of the old NetConfig way. I also refactored certain variable
names so that they make more sense and are consistent with the rest of
the code.

In addition to this the NetworkManager code needed reimplementing in
some places to work with the new program flow of device configuration
and to support more use cases. The most important part of this is that
configuration of master interfaces (e.g. bonding or team) doesn't also
configure the slave interfaces. Instead it changes finds their
ConfigDevice object and changes it's configuration so that the device
is enslaved on activation.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: InterfaceManager integration

This commit reimplements the NetTestSlave module to use the new
InterfaceManager module instead of the old NetConfig one.

This includes:
* Netlink handling is done in the InterfaceManager class where it makes
* sense

* Device configuration is delegated to the InterfaceManager, the
* SlaveMethods class reflects this by adding methods such as
* map_if_by_hwaddr that can be used by the controller to map interface
* ids to the specific slave interface.
* Or the new create_soft_interface method that will be used to
* initialize soft interfaces.

* Packet capture now uses the interface provided by the
* InterfaceManager, packet captures are run on every controller mapped
* device.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Machine: use the new slave interface

Interface initialization and configuration now reflects the recent
changes to the slave implementation. The important points are:

* Static and Virtual interfaces are initialized by creating an id to
* device mapping on the slave

* Soft devices are initialized by calling the create_soft_interface
* slave method.

* Configuration no longer means setting the device up as well... this
* will be done separately in a different order due to how NetworkManager
* works.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Machine, NetTestController: ordered interface configuration

This commit completes the master/slave hierarchy of machine interfaces
and adds a new method get_ordered_interfaces to the Machine class that
returns the machines interfaces in order of slaves before masters. The
interfaces are then configured in this order and after all devices are
configured they are set UP in the same order. The reverse ordering is
used in the Machine class when deconfiguring devices.

Interface information sent to the slave will also contain the id of the
master interface or None. This will be used by the NmConfig classes to
activate master connections.

This is required for both NM and iproute2 to work properly.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>