KVM Test: Update nfs_corrupt test

The virt_env_process.preprocess_image() function parameters was updated
by f37c7f736a867bc649fc4319e8a8f9ccf1f049d6 to accept an image_name parameter.
This patch fixes the nfs_corrupt test module to use the new signature.

Signed-off-by: Feng Yang <fyang@redhat.com>
create image directory if needed

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
qtree: avoid class name clash

Rename 'class' to 'class_name' in the qtree parser, to fix a name clash
(followed by a parser error) with the 'class' property in upstream qemu.

Device in question is virtio-blk-pci:

      dev: virtio-blk-pci, id "virtio-disk0"
        class = 0x100
        [ ... snip ... ]
        class SCSI controller, addr 00:05.0, pci id 1af4:1001 (sub 1af4:0002)
        [ ... snip ... ]
qtree: id name clash workaround

qtree parser stubles over a duplicate id here:

  dev: kvm-apic, id ""
    id = 1
    vapic = on
    irq 0
    mmio ffffffffffffffff/0000000000100000

Bad idea on qemu side to do that in the first place, should
better be named 'apic-id' (simliar to scsi-id).

This patch adds a workaround for it: ignore empty id strings.
Looked like the least hacky way to fix the issue at hand.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
qtree: {bus, dev}-prop: prefix is gone, adapt

upstream qemu has no 'bus-prop:' and 'dev-prop:' prefixes any more,
they are gone with the move to QOM.  Adapt the qtree parser, by
stripping off the prefixes for older qemu versions, then use the
short, un-prefixed version to query the values.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Fix repair of systems with install_server

When we are running repair on a system, we aren't passed a profile like
we are with autoserv jobs normally in the machine name. So self.profile
for the Host object comes back as ''. With the code as-is, that will
result in install_machine() returning immediately back to the repair
code and verify complaining with:

07/08 06:45:32 INFO |base_class:0407| Trying to reinstall the machine
07/08 06:45:32 WARNI|base_class:0360| Already done this (<bound method [machine name redacted].machine_install of <remote host: [machine name redacted], profile: >>) repair procedure, re-raising the original exception.

I think a simpler choice is that if we still don't have a profile after
self.profile is assigned, let's assume that the install system can
figure it out? And if it is unable to (usually do to a misconfiguration
of Cobbler backend), thrown an exception.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
KVM Test: Always run vm.resume() after image_func()

in virt/virt_env_process.py,
 def _call_image_func():
should use try...finally to make sure the vm is alway resumed back.

Signed-off-by: Feng Yang <fyang@redhat.com>
client.base_sysinfo: Do not pickle SoftwareManager

The sleeptest on remote CentOS machine resulted in following traceback

15:45:31 ERROR| JOB ERROR: Unhandled TypeError: can't pickle file objects
Traceback (most recent call last):
  File "/tmp/sysinfo/autoserv-KCmM2V/job.py", line 1165, in step_engine
    execfile(self.control, global_control_vars, global_control_vars)
  File "/tmp/sysinfo/autoserv-KCmM2V/control.autoserv", line 13, in <module>
    pickle.dump(job.sysinfo, open(sysinfo_pickle, 'w'))
  File "/usr/lib64/python2.6/pickle.py", line 1362, in dump
    Pickler(file, protocol).dump(obj)
  File "/usr/lib64/python2.6/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib64/python2.6/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib64/python2.6/pickle.py", line 419, in save_reduce
  ...
  ...
  ...
  ...
  File "/usr/lib64/python2.6/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/usr/lib64/python2.6/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
  TypeError: can't pickle file objects

Marking SoftwareManager as not to pickle solve the problem.

Signed-off-by: Abhay Chavan <chavan.abhay@gmail.com>
Signed-off-by: Rajshree Thorat <rajashree.thorat16@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
client.shared.base_packages: Add new fetcher GitFetcher

This adds git as a new fetcher.  Git is great for
fetching tarballs directly from its source tree
using git-archive. This method allows us to skip
packaging tests into tar.bz2 and instead grab
them directly from a branch or commit or tag.

Underneath the command looks like:

git archive --remote=git://<git-site>/users/dzickus/autotest-tests -o don.tar master testsuite

This would download everything under the directory
testsuite into don.tar and autotest would install
it locally for use. All the local control file would
need to do is add a git repo using

job.add_repository(git://<git-location>:[<branch>])

where <branch> is assumed to be master if not specified.

Also, make it possible to add directories to organize
tests better instead of the current behavior which is
a flat directory level.

Tested by creating a git tree with all the autotest
tests in there and using a local control file to fetch
them.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.cmdparser: add fetch command

When playing with my changes for the Git Fetcher,
I thought it would be nice if we could just 'fetch'
the control file remotely.

This would make it easier for folks to create
random tests and host them, while letting others
just grab them with a url pointer (either git: or
http:).

It creates a new area to store the fetched tests
(based on the 'test_out_dir' variable) and hooks
this area into the 'list' and 'run' commands.

Tested by running:

autotest-local fetch git://<internal-git-site> testsuite/control.simple

and then run it with

autotest-local run testsuite/control.simple

(the control file adds the remote repo to fetch the tests from)

In order to completely abstract the use of the
job.add_repo to control files, just set fetch_location
in global_config.ini.

Signed-off-by: Don Zickus <dzickus@redhat.com>
base_utils: is_url - Include git in group of valid URL schemas

Include git in the list of valid schemas to determine
whether a string is a url, then remove all custom is_url
implementations.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
job: Move the site_tests area to the job tmp dir

In order to allow the package manager to install
test modules from http or git, move site_tests dir
to the autotest test output area. This area is
guaranteed to be writable by autotest in all use
cases, since all test locations so far are read-only.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
global_config.ini: Add fetch_location for packaging

Add a commented out fetch_location key in global_config.ini,
which will help make this param more discoverable. From
this key autotest will pick up the repositories for
dependencies, tests, profilers and client.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.cmdparser: Use the logging system

When testing the new autotest-local fetch command, I've
noticed that a *lot* of debug output is thrown, which
might be confusing.

So, make the CmdParser code to use the logging code
used by other autotest entry points, making the INFO
level the default. This reduces the amount of
output of autotest-local using the fetch action
drastically.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client.shared.base_packages: documentation and style overhaul

To educate myself, and hopefuly other, about the inner workings and
interface of the package manager, repository fetchers and other
related classes and functions, improve the docstrings and general
code style of this module.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
client.shared.base_packages: move the RepositoryFetcher init code up

To the base class, making it share more code, and add the custom
code (branch handling) to GitFetcher.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
client.shared.base_packages: remove misleading comment

Signed-off-by: Cleber Rosa <crosa@redhat.com>
client.shared.base_packages: deal with different suffixes created by git-archive

It looks like some versions of git-archive may choose to add a suffix
according to the archive format, even when the filename is explictly
specified without it.

This makes the install package post code to deal with these different
suffix possibilities.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Adding a test for remote-viewer using a Windows guest

Signed-off-by: Marian Krcmarik <mkrcmari@redhat.com>
Modified getPID in rv_connect for it to work with Windows guest test

Signed-off-by: Vimal Patel <vipatel@redhat.com>