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>
client.kernel_config: Uncompress /proc/config.gz and use as cfg

For systems that support /proc/config.gz, we can use the
config only if it's properly uncompressed. So, uncompress
the config file, and then pass it to autotest.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
boottool: Analyze both stdout and stderr from grub's output

Turns out grub shipped by OpenSUSE 12.1 has the batch cmd
savedefault disabled:

linux-yk2o:~ # grub --batch

    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the
possible
   completions of a device/filename. ]
grub> savedefault --default=0 --once
savedefault --default=0 --once

Error 27: Unrecognized command

Horray for great engineering decisions! Kudos to the OpenSUSE team.

Also, since this wasn't captured by our code, it means
it went to stdout rather than stderr. So let's capture
both stdout and stderr to look for errors instead.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
boottool: Use 'grubonce' if available in grub legacy distros

The command 'grubonce' is a custom method to boot a bootloader
entry once, found in OpenSUSE 12.1. Let's try to use it if
found, then fall back to the more standard (and sane) method.

This fixes an issue booting new kernels on OpenSUSE 12.1.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
[RFC] global_config.ini: Enable SSH connection sharing by default

The autotest server needs to execute a bunch of a commands
on a test client for a typical job; each one of those
commands needs to wait on a costly authentication process.

Fortunately, SSH does have mechanisms to make subsequent
ssh sessions to use a master connection if available.
Search for ControlMaster in

http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1

What's even better, the support for Master SSH connection
already exists in autotest, only that it is turned off
by default. What I am proposing here is that we turn
this on so people can benefit from the speed boost on
jobs executed from an autotest server, without even
thinking about it.

We believe most of the scenarios involving installing an
autotest server use distros sufficiently recent to support
the MasterControl feature.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Adding site_tests to client directory

The directory site_tests was conceived long ago as a
place to store tests internal to organizations, that
could not become upstream. Now in Fedora installs,
the absence of this directory will make the code to
throw an exception due to its absence. So let's include
it in the source tree, and install it with setup.py.

CC: Martin Krizek <mkrizek@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.shared.base_job: Use autotest_top_path when no AUTODIR is set

During test of the next branch, I've realized the AUTODIR
environment variable is not set on autoserv jobs, hence,
failing any server job. So, when AUTODIR is not set
(server side job), use the global_config.ini value of
autotest_top_path.

This fixes a bug that was preventing server side jobs to
work on next.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
boottool: improve error detectiom when running grub --batch

As a matter of fact, grub outputs to stdout a lot of
stuff. As sometimes errors might be in both stdout
and stderr (talk about something annoying), it's
just not practical to stablish a whitelist of strings.
Let's then look for everything that has an 'error'
in the message.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
server.autotest_remote: Transfer and clean state files properly

The autotest_remote code assumes the state of remote
control files is simply path/to/control + ".state". This
causes problem with our patches moving state file creation
to the test output dir set on global_config.ini, with
fall back to the autotest tmpdir area.

Fix the code, creating new attributes for the _BaseRun
class, that will make it easier to control and keep
consistency of the state file locations.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client job: Adjust runjob method of loading a control file

We had to standardize that the state files will be
always on a temp area on the autotest client, so,
let's enforce this policy on runjob.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
server.autotest_remote_unittest: Fix unittest broken with 2648c15

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Improve virsh_cmd() to support logging output control.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>

This patch introduces a new parameter print_info with default
value False to support logging output control.
Add virsh_freecell function in libvirt_vm.py

Signed-off-by: Gu Yanhua <guyanhua-fnst@cn.fujitsu.com>
Add virsh_freecell.py to test virsh_freecell command

Signed-off-by: Gu Yanhua <guyanhua-fnst@cn.fujitsu.com>
Add configuration for "virsh freecell"

Signed-off-by: Chris Evich <cevich@redhat.com>
Signed-off-by: Gu Yanhua <guyanhua-fnst@cn.fujitsu.com>
.gitignore: add results/* dir

 $ git status

Will take a long time if the results directory actually holds lots
of results. Since it is not controlled by git, ignore it altogether.

Also, other paths suggested by Amos are added to the ignore list.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
cli: change the rpc client to return richer return status codes

Return a non-zero status if it is asked to display information about
a specific object and that object does not exist.

test.py:  modify to return:
    0:  on success
    1:  on failure
    2:  on partial success
  updated description to explain and give example.

topic_common:
    fixed a couple of typos in comments
    modified illegal_arg routine to save error in failuer rather than display the message.
    the message will be display later by "show_all_failures".

Changes from v1:
 * Add assignment line missing from previous commit.

Signed-off-by: Raymond Spear <ray.spear@hp.com>
cli: update unit tests to match new code behavior

Signed-off-by: Raymond Spear <ray.spear@hp.com>