autotest-firewalld-add-service: move argparse to runtime instead of init

Unit-testing was trying to isolate individual methods by instantiating
App(), however App.__init__() was creating an argparser which was in
turn running firewall-cmd.  Argparse setup should be delayed until
runtime so we can instantiate without side-effects.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest_firewalld_add_service_unittest: fix module name

python identifiers can't contain '-', so when using imp.load_module replace '-'
with "_".

This seems to have no effect in reality.  I'm not sure how
imp.load_module actually uses the first argument.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest_firewalld_add_service_unittest: mock out argparse

Since we aren't testing argparse mock it out during module load.  Use
a simple sys.modules hack.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest-firewalld-add-server: convert to Popen and add unit test

The docs say: subprocess.Popen is preferable to commands.  Also convert
_get_default_zone to static method so we can unit test it without
argparse.

v2: use standard autotest common import

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest-firewalld-add-service: improve handling of missing default zone

The print_help() message wasn't useful when this script is run without
firewall-cmd present.
Change the _get_default_zone to return None is firewall-cmd fails, then
add a specific error message indicating that we can't find the default
zone.

Also remove the 'not (zone and service)' check, since we check each
individually.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest-firewalld-add-service: exit with status 1 when missing args

Don't exit with success help missing an argument.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest-firewalld-add-service: convert methods to static

The new PyCharm 3.0 will now suggest conversion to staticmethod when
a method doesn't use self, so I decided to try it out.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest-firewalld-add-service: fix bug with newlines by adding rstrip

Popen.communicate() returns strings with newlines.  rstrip the newline
and update the unit test to catch this.  Caught by autotest_regression
virt test.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest_firewalld_add_service_unittest: fix #! to use /usr/bin/env

/usr/bin/env python is preferrable because it supports virtualenv.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
autotest_firewalld_add_service_unittest: resolve pylint by splitting unit test

Break test_get_default_zone into two separate unit tests and thus avoid pylint
complaints about '_' being defined twice.

Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Add README for deployment on Fedora

Signed-off-by: James Laska <jlaska@redhat.com>
global_config.ini: make it easier to be read by humans

Or at least humans like me. I have a hard time to visualy
separate the config keys from the comments, and the whitespace
helps me with that.

I hope this is not just a matter of personal taste and proves
helpful to others.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
scheduler: add a option for how drone machines are deployed

That is, if they're supposed to be already properly configured
or if the scheduler should try to setup their dependencies.

Since most deployment scenarios of Autotest server/scheduler
involves only a single server and a single drone (localhost),
let's make the default 'True', that is, the machine is already
setup.

In more complex deployment scenarios, with multiple drones,
it would simply be matter of flipping this switch right along
with adding the additional drone hostnames.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
global_config: add utility function/script to change global_config values

This keeps using the lowest-level (dumbest) approach of reading all
lines in the configuration file and changing the line that matches the
section and key provided.

The idea is to use this script during the build phase of packages
and avoid having a patch to change configuration files. This approach
is already partially used on the Fedora package but lacks consistency.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
conmux: try to use system conmux first

If conmux is available at a known location, let's use it instead.
If not, fallback to the one provided in the autotest tree.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
utils/autotest-rh.init: make the PID_PATH line simpler

And easier to substitute other values needed by when autotest
is packaged.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
README.fedora: add instructions for generating autotest packages

Signed-off-by: Cleber Rosa <crosa@redhat.com>
RPM packages: add SPEC file

The RPM spec file is the recipe for building RPMs. This one is
a "fork" of the Fedora RPM and tracks the state of the next
branch in autotest. That is, it's intended to be kept in sync
with the autotest code so that we can have quick and fresh
packages for each release.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
server/hosts/serial.py: replace literal ".." with os.pardir

Signed-off-by: Cleber Rosa <crosa@redhat.com>
autotest-framework.spec: added suggestions by Ross Brattain

Signed-off-by: Cleber Rosa <crosa@redhat.com>