PEP8 mass auto fix

Catching up with some problems found w.r.t. coding style

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Merge pull request #1208 from autotest/pep8-fix

PEP8 mass auto fix
virsh_start: Need to ensure stopped before run

When run after virsh.shutdown, the first virsh.start was failing with
because the domain was already started.  Adjusted the .cfg file to
ensure setting of the 'kill_vm_before_test' in the status_error_no
variant.

Also, changed the error returned from using 'stdout' to 'stderr' so that
"Domain is already active" would be displayed.
virttest.env_process: Remove restart_vm option

The restart_vm option, that will restart a vm at the beginning
of postprocessing, is unnecessary, given that you could
simply shut down all the VMs at the end of each test,
forcing new vms to be started.

So get rid of this option, and replace --restart-vm
in ./run to use kill_vm = yes instead.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Merge pull request #1214 from autotest/restart-vm

virttest.env_process: Remove restart_vm option
virttest: Fix network xml sync with state unchanged

When using original sync of NetworkXML class to restore a backup
network, it is redefined and started, leaving autostart disabled.
This is not the default setting (all true for active/persistent/
autostart) for the network.

In this modification, we set the default behavior of sync to
set all state to true. With the help of an optional "state" dict
parameter, we can restore the network to any state you like, or
in practical, to the state we backed up.

To facilitate this backup & restore process, I also added a helper
function state_dict() to retrieve a active/persistent/autostart
dict for backing up current vm state.

The unittest for these network manipulators is given in a new file
instead of libvirt_xml_unittest.py to separate manipulator tests
from XML base test.

Furthermore, The net_state_dict function use an outdated way to get
the persistent property for the network, which is already changed
by a patch (commit 895913d) in libvirt-0.10.2. The persistent status
can be retrieved from net_list directly. So I add a condition to
ensure it can be backported for older libvirt while avoiding
redundant call of net_autostart when testing on new libvirt.

This backport can be removed if old libvirt no longer maintained.

Signed-off-by: Hao Liu <hliu@redhat.com>
virt-libvirt: VirshPersistent Noise reduction

This class was logging a debug event every time it successfully
reused an aexpect session.  Since aexpect always loggs the command
being run anyway, this extra detail is mostly redundant.  If there's
a problem, an exception will be thrown anyway.

Signed-off-by: Chris Evich <cevich@redhat.com>
Revert virt.virtnet: update vm.virtnet when guest reboot

This reverts commit 33b69b8bb51b217a857028dc9ea7889eaef54531.

Conflicts:
	virttest/virt_vm.py
virt: Remove vm.driver_type

This parameter is only ever actually used for a handful of Xen tests and
checks.  Where referenced, it always came along with a test against the
'hvm_or_pv' parameter.  This patch removes vm.driver_type, removes
the params dict manipulation, and consolidates all use down to just a
new vm.is_xen() method call.  The handful of tests we have which use xen
VM's were also updated.

I also removed a docstring referencing xen for a non-existant function
parameter.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: VM House-keeping

*  Several callers to the VM class use 'basedir' and 'root_dir'
   interchangeably.  Rename these to just use root_dir since it
   appears more common.

*  VM instance attributes ``name``, ``params``, root_dir`` and
   ``address_cache`` are common to all subclasses, so it makes
   more sense to consolidate their assignment into the base-class.

*  Fix a name <-> self.name reference problem in a context label.

*  Implement proper line-wrapping for call to
   qemu_monitor.wait_for_create_monitor() in qemu_vm.py

*  Fix a possible bug where vm.migration_file is initialized
   to None, but only it's existance was checked, not it's possible
   None value.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Reduce virtnet and rewrite unittests

Component classes of virtnet had their behavior bound together,
making them less flexible and more difficult to use.  An auxiliary
class was then used to support customization but it was not at the
right level in the stack, nor did it help untangle any bound
behavior.

This update takes the intention of the auxiliary class
(VMNetStyle) and folds it into the virtnet component classes
in a more heirarchical manner.  Additionally, VirtNet itself
has been split up into an ABC, and multiple subclasses which
operate on different data sources, but through a common interface.

This places the burden/responsibility for managing data and it's source
on the virtnet consumer.  It allows for greater flexibility and eases
maintenance since class responsibility and interfaces are more clearly
defined and don't come with any cross-dependencies.

Finally, since a prior update made PropCan instances fully pickleable,
there is no need to perform string conversion/parsing for storage.
Further, since a proper ABC model was implemented, storage can
be performed agnostic to inner container-class type.  These changes
permit rich comparison between the various VirtNet classes, including
the ability to select specific properties to NOT be compared, at
runtime.

The unittests were nearly completely re-written to cover the most
critical points in the new structure.  Test coverage is a little
less robust than previous, however it also runs roughly 10x faster.
The cartesian-based testing was updated to reflect recent changes
to the vm classes, and cut back on a lot of redundant tests.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Share virtnet specialization and cleanup

Choosing which networking inner-storage class for virtnet
now happens at the VM level.  Also, the cache database
location can be made common, allowing for a shared
clean_tmp_files() implementation.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Let VM subclasses decide init virtnet

Rather than one-size-fits all, provide a common set of
network initialization, caching, storage, and syncing
functions, and allow higher-levels to decide when/how to
setup networking.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Simplify needs_restart

It's impossible to perfectly track vm state from test to test.
This area / behavior is currently being discussed for further
refinement, for now rather than try and be smart, just do a
very basic name/params/root_dr comparison and leave it at that.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Mac/IP loop readability

Clean up some variable names and virtnet calls to make it more
obvious what is being returned and operated on.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: BaseVM VirtNet updates

Simplify base-class networking code related to dynamic
addition/removal of networking devices.  Even though
all device info is cached in database, only pull
mac addresses from it for new devices.  Otherwise
always trust current params are ultimate authority
for setup info.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-qemu: Remove deprecated script support

While still supported in qemu, virt-test has long since
dropped support for networking up/down scripts.  However,
some remnents remained inside vm.make_create_command().

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-qemu: utils_net.QemuIface contains helpers

Rather than spread "helper" functions around haphazardly,
organize them together under the specialized networking-info.
container QemuIface for qemu_vm.  This prevents the need for
burried, private functions, and organizes them in a common
location where they can also be properly unittested.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: QemuIface auto-convert int() from str. params.

For parameters which expect integers, QemuIface will
attempt to parse them as integers, but provides for
disabling this conversion if necessary (i.e. unittesting).
Therefor, explicit calls to int on reference are no
longer necessary.

Signed-off-by: Chris Evich <cevich@redhat.com>
fiup! virt-qemu: Remove deprecated script support

Signed-off-by: Chris Evich <cevich@redhat.com>