Client: Include ElementTree and wrapper module

In order to manipulate XML in virt tests, and
possibly other tests, include ElementTree. This
is for the sole purpose to minimize dependencies
in python 2.4 systems. If present, the system
ElementTree is used.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Block Stream testcase

This is a solution to issue #390. A test case that verifies
block streaming functionality in qemu.

Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
virt: image create command line options fix

The old command line generate method will cause error when some
options for -o is not set in configure files.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: add snapshot delete for QemuImg

Add snapshot delete function in QemuImg class for kvm_storage. And
the interface in libvirt_storage.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Client: Standardize on bundled ElementTree 2.6 module

Utility module standardized on ElementTree 2.6 to minimize dependencies
in python 2.4 systems.

Signed-off-by: Chris Evich <cevich@redhat.com>
boottool: update grub 2 configuration to use the "default saved" entry

On some systems, grub 2 is not set to boot by default from the saved
entry. This prevents boot once feature to work properly on those systems.

This patch edits the grub 2 configuration file setting the default to
whatever is set with the 'grub-reboot' utility, at the grub environment
file /boot/grub/grubenv. Also, it attempts to set the previous saved entry
to the default previously set on the configuration file.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
boottool: fix wording when trying to remove an non existing entry

This has been discussed on github issue #369, and the debug message
shortend accordinly to lmr's suggestions.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
virt.spice: Adding values for the default variants

Signed-off-by: Marian Krcmarik <mkrcmari@redhat.com>
client.kernel: Clean up add to bootloader logic

The old boottool implementation forced us to use the
following workaround:

 1) Add the kernel with a dummy argument
 2) Transform the args string in a list
 3) Append the arguments to the kernel entry one by one
 4) Remove the dummy argument

Besides being ugly as sin, I believe this is causing
problems in the bootloader code that are affecting
a bunch of distros, such as Ubuntu and RHEL5.

This change needs more testing, but it was a clear
thing that we were missing with the update to a
grubby backed boottool.

CC: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Close qemu-io shell session after it create

The shell session for qemu-io will not create in init step which
will cause the close session through out an error. So close it
after it created.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
boottool: updated minimum required grubby version to 8.15

Since it includes a fix relevant for RHEL 5 systems.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
client.kernel_config: Normalize the result of utils.running_config

All the config path manipulation in kernel_config relies
in comparisons like:

if orig_file == ''

running_config() may return None, that might in turn,
sneak into the lower level functions generating an
error. So let's play safe and pass '' in case the
result of running_config is None.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
kernel: Fix unittest broken by f8586dbb8f

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.job: Consolidate tests output options in one

Turn client/[tests|site-tests] into read only directories,
make all the output that required those dirs to be
read write to go to a configurable location. Consolidate
all previous options that dealt with test output:

* test_tmp_dir
* pkg_dir
* state_dir

Into a single one:

* test_output_dir

If that variable is not set, use the client temporary
directory to write those files into.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.test: Create test_dir config key

This is actually a rename from test_src_dir, as it's more
clear for the purpose. This is the place where we can
configure additional directories where we can look for
test modules

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.tests: Make test src dir configurable

test.srcdir was still writing into the test module directory,
breaking our assumptions of read only test modules. So
let's fix this by allowing the src dir to be in the
configurable test_output_dir, or default to the client
tmpdir if that is not set.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Replacing the obsolete env variable of bridge with the new one: netdst.

Signed-off-by: Vimal Patel <vipatel@redhat.com>
boottool: Don't fail if can't parse an index entry

Running autotest on a OpenSUSE client (12.1), that is
grub-based, I've found that boottool would fail with:

Traceback (most recent call last):
  File "/usr/local/autotest/tools/boottool", line 1994, in <module>
    app.run()
  File "/usr/local/autotest/tools/boottool", line 1804, in run
    result = action_method()
  File "/usr/local/autotest/tools/boottool", line 1885, in action_info
    entries = self.grubby.get_entries()
  File "/usr/local/autotest/tools/boottool", line 1010, in get_entries
    entries[entry["index"]] = entry
KeyError: 'index'

Turns out that the code is assuming that we can always
parse an index from the raw grubby output, leading to
the above error when the assumption does not hold true.

Fortunately, this is easy to fix, just handle KeyErrors
and continue on to parse the rest of the split parts
of the raw output.

CC: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
boottool: Search for installed grub in the system

Current boottool assumes a hardcoded path for grub,
/sbin/grub. Distros such as OpenSUSE install it on
/usr/sbin/grub, so this will cause a grub setup to
flat out fail on those distros.

So let's leverage find_executable, that is already
present, to take care of actually finding the
appropriate grub path.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
boottool: Find installed nvsetenv command rather than hardcode it

In the same vein of the grub path problem, nvsetenv's path
is hardcoded, while it doesn't need to. Fix that as well.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>