Remove NetConfigDeviceAllCleanup from machine cleanup

NetConfigDeviceAllCleanup would clean the system from netdevice modules
even if they had not been configured at all. This can break a setup with
virt guest running on a host system both acting as lnst slaves and using
bridge netdevice driver.

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

The patch fixes crash of lnst-slave when options are specified for an
enslaved device.

Signed-off-by: Jan Tluka <jtluka@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestSlave: listen for netlink notifications

The slave server now listens to NETLINK_ROUTE notifications. At the
moment only RTM_NEWLINK messages are interesting to us, so we construct
update messages from these and send them to the controller.

The update messages contain the name of the interface, it's hw address,
and the index under which it is recognized in the kernel. The index is
useless right now but it will be useful later when we will have an
internal interface database.

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

This commit adds the ability to recieve data from NetlinkSockets. The
data is also parsed and decoded by a NETLINK_ROUTE marshaller, since
that is the only type of netlink socket we will be using at the moment.

The order of the if/elif statements is important and the NetlinkSocket
must come before the socket.SocketType check.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Controller: add handling of update messages

This commit extends the message handling on the controller, to recieve
update messages from slave machines.

A new method was added to the Machine objects- interface_update that
will be called when an update message is recieved. At the moment it only
looks up the corresponding interface (by devname) and updates its hw
address. In the future this could be used to update ip addresses, and
devnames them selves (when the kernel indices are stored).

This change also required the addition of a dictionary to the message
dispatcher object that maps machine id to the machine object.

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

This commit fixes several Exception messages that were formatted with
variables, but there were no formatting escape sequences in them which
caused crashes.

Also the initialize method of class Interface uses the result of the
get_devices_by_hwaddr slave method to properly set the interface
devname.

Finally I had to add a sleep call after the interface deconfiguration
call because sometimes dynamically added devices (through libvirt) would
change their MAC address based on their master bond device, and wouldn't
have enough time to change back before deleting them.

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

The scan_netdev function was starting to be a bit unreliable sometimes
causing crashes. It also wasn't a very pretty solution of the
problem.

The new scan_netdev function connects to a netlink socket and requests a
dump of all interfaces on the system, and parses the result to return a
similar data structure to the previous implementation of the function.
Again it contains the addditional kernel index of the interface that
will be used in the future.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NmConfigDevice: fix vlan is_nm_managed method

When accessing the vlan slave interface I used the index 1 instead of 0.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
smoke tests: fix expect values

Values of the expect attribute are generated based on values stored in
the variables.conf file.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
variables.conf: value change from true/false to pass/fail

The recent change of the xml format changed the accepted values of the
expect attribute from true/false to pass/fail.

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