schema-recipe: fix python tasks

The schema didn't accept python tasks. This commit fixes that, python
tasks can now be defined by an element:
<task python="path_to_python_task"/>

task element with the python attribute defined doesn't have any content
allowed.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestController: skip resource sync for config_only

This commit makes it so that config_only runs don't synchronize
resources (test modules and test tools). The code will later be extended
so that when synchronizing resources only the ones needed by the recipe
are sent to machines.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestController: sync only required resources

From now the controller will only synchronize resources required by the
slave machine for recipe execution. This is done by traversing the
commands that will be executed and searching for those that require any
kind of resource.

This commit also removes a piece of code from the function
_prepare_command that handled raising exceptions when a tool was not
found, this is now handled in the code that traverses the recipe
commands.

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

When the resource_table is initialized or cleared it should have at
least empty 'module' and 'tools' subdictionaries created. This is so
that proper exceptions are raised in case nothing was synchronized to
the slave - before this commit an exception KeyError 'module not
defined' would be raised, instead an exception "module/tool xyz not
found" is more appropriate.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Task: add HostAPI method sync_resources

This method provides new functionality to the python tasks. With this
the user can specify exactly which resources should be synchronized to
a single slave machine.

Since in case of python tasks all resources are automatically
synchronized this method doesn't have any practical meaning yet. This
will be changed in the following commits.

Example of use:

m1 = ctl.get_host("1")
m1.sync_resources(modules=["IcmpPing"], tools=["multicast"])

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
lnst-ctl: add -r, --reduce-sync option

This option disables the full resource synchronization for python tasks.
Instead it relies on the user to use the sync_resources HostAPI method
to manually synchronize required modules and tools.

The option doesn't have any effect on recipes that use xml tasks, these
will always be automatically synchronized in reduced mode when only
required resources are copied to slaves.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
XmlParser: save full filename in element objects

I'm not exactly sure why we would only store the full path in the root
element and the following elements would only use the basename of the
file. This comit changes that so that the absolute path is stored in all
element objects.

This will be usefull when figuring out the point of reference for
non xinclude attributes that refer to files.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
recipe xml format: add module_dir and tools_dir attributes

These attributes can be used in <task> elements to specify additional
directory paths that should be searched for module and tool resources.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
NetTestController: add support for {module,tools}_dir

This commit adds support for searching additional resource directories
specified by the module_dir and tools_dir attributes.

We create a deep copy of the original resource table and then update it
with the newly found modules or tools. After the task is processed we
restore the original resource table.

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