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>