database: add database migration file that replaces Django fixtures

We used to rely on a Django fixtures to add a single record of initial
data to the afe_acl_groups table. We can simply move that data to the
schema, or, as done here, in a database version migration script.

This fixes issue #503.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
virt-libvirt: Fix base class name error in libvirt_xml

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
virt-libvirt: Move all virsh_() functions to virsh module

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Classify Virsh from module contents

* Moved libvirtd_*() back into libvirt_vm module until they have a
  better home
* Used properties and a closure around globals() to pass
  state into virsh functions as parameters
* Made all virsh function/method API extensible/flexible
* Converted all virsh functions/methods to take **dargs
* Added/updated documentation to all virsh functions/methods
* Subclassed ShellSession as VirshSession specialised for virsh
* Implimented Closure class to fix python inconsistency
* Provide Virsh class w/ persistant or non-persistant backend sessions
* Unified virsh.cmd behavior for use as module function or class method

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Update all virsh_*() -> virsh.*()

+ Added virsh help function

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Code cleanup & bugfix

+ Fixed uri handling and many libvirt test operation order
+ Fixed libvirt test module import problems
+ Add normalize_connect_uri()
+ Fixed many PEP8 style problems
* Fixed spelling problems

Signed-off-by: Chris Evich <cevich@redhat.com>
virt.libvirt: virsh_freecell - improve regexp search

Newer virsh will output KiB rather than kB, so let's
improve the regexp pattern to catch that up.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client: Add lvsetup module to test basic LVM functionality

It also can create a volume group on top of a ramdisk
for increased performance. Internally it creates a
volume group on top of a "sparse file", so it will
only allocate the memory it really needs.

Signed-off-by: Plamen Dimitrov <plamen.dimitrov@intra2net.com>
increse the floppy size from 1.44M to 2.88M

As the win guest driver is getting more huge, the virtio-win.vfd is now increased to 2.88M.
Let's increase vfd in autotest to 2.88M too.
Changelog From V1:
Now setting 1.44M for Linux guest, as the answer file is small and
legacy systems like RHEL.3 cant work with a 2.88M floppy.

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
client: xml_utils documentation update

I noticed some confusion on intended usage of some of the classes.
Added extensive documentation regarding design intent and references
to additional examples and docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Enhance libvirt_xml

* Improved LibvirtXMLError exception with optional string argument
* Added module docstring
* Added LibvirtXMLBase base-class for common methods/attributes
* Added simple LibvirtXML class

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: libvirt_vm bug fix

If the action is status, the funtion is supposed to return True when libvirtd
    service is running,otherwise return False if its stopped.
    However in this case since the function calls utilis.run without
    ignore_status=True, if the libvirtd service is stopped, then a CmdError
    is raised and the utils.run function fails to return after raising the
    error, in which case service_libvirtd_control(status) will never return false
    when libvirtd service is stopped.

    The fix will be to use ignore_status=True while calling utils.run,
    so that it can return if there is a CmdError, in case libvirtd is
    stopped.

Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com>
virt.storage: Backup both good and bad images upon disk corruption

It's useful to have both the good image created
at unattended install time and, when the image
gets corrupted, the bad image, both with the same
unique suffix. So expand the backup image method
to handle this behavior accordingly, and also
simplify the logic used on that method.

CC: Cleber Rosa <cleber@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm_vm: Skip adding interface to TAP if it's already present

This is a solution for issue #520 - when trying to create
a TAP device, the interface might be already a member of
the bridge, so the addition will fail with an IOError, with
errno == errno.EBUSY (device or resource busy). That IOError
will be wrapped in our TAPCreationError exception. So, when
performing the operation, catch the TAPCreationError and
verify errno of the detail attribute, if it's errno.EBUSY,
skip the addition operation and continue.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm_vm: Add prefix/disable_kvm/disable_shutdown support

This patch adds the following new config keys for
the virt tests (kvm variant):

 1) Add prefix to the qemu cmd (ex: valgrind)
 2) Explicitly add -no-kvm to the qemu cmd
 3) Explicitly add -no-shutdown to the qemu cmd

Document the additions on base.cfg.

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
virt.kvm_vm: Adding bios_path to pass custom bios path

Sometimes people need to use customized bios, eg: for debugging.

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
virt.kvm_vm: Don't regenerate spice cert when they already exist

Now autotest alway regenerates certs before run/boot
a guest, which is not needed, and sometimes could be
a disaster when one has a running VM, since re-generate
the certs would make your existing VM no longer accessible.

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
virt.utils_misc: Write keyvals of the kernel version used

We want to display kernel versions used for virt jobs, so
let's record the kernel used in each scenario right from
the install_host_kernel helper function.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Remove temporarily virsh_unittest

As it needs to be reworked post virt test refactoring.

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