server status RPC method: deal with servers without a install server

Autotest servers without a installation server are actually a valid
deployment scenario. So, in those cases, do not set the server's
"concern" status.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
autotest-scheduller: add the dependency on mysql to the systemd service file

After a fresh install of autotest from next, I tested a new feature of arc:

$ arcli server -s
Concerns: Yes
Scheduler Running: No
Scheduler Watcher Running: Yes
Install Server Running: No
Log Disk Space Usage: 18%

Running `systemctl status autotestd` would show:

_drone_manager.shutdown()
AttributeError: 'NoneType' object has no attribute 'shutdown'
Traceback (most recent call last):
File "/usr/local/autotest/scheduler/autotest-scheduler", line 13, in <module>
monitor_db.main()
File "/usr/local/autotest/scheduler/monitor_db.py", line 279, in main
main_without_exception_handling()
File "/usr/local/autotest/scheduler/monitor_db.py", line 272, in main_without_exce...andling
_drone_manager.shutdown()
AttributeError: 'NoneType' object has no attribute 'shutdown'

Turns out that the autotestd was trying to start before the MySQL
database, which is hard dependency.

After this patch, arcli is happy about the server state:

$ arcli server -s
Concerns: No
Scheduler Running: Yes
Scheduler Watcher Running: Yes
Install Server Running: No
Log Disk Space Usage: 18%

Signed-off-by: Cleber Rosa <crosa@redhat.com>
server.hosts.remote: When install server is not available, retry

Rather than giving up and throwing a hard to understand
exception to users when the install server code can't reach
the install server, retry every install_timeout / 100 seconds.

If after install_timeout / 10 we still could not reach
the server, then throw an easier to understand error
(Could not contact the install server).

CC: Rudá Moura <rmoura@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
server.hosts.remote: Introduce default install timeout

When selecting "Reinstall" on a given machine, we'll
fail because the server side test reinstall doesn't
set a proper timeout. So when no timeout specified,
read it from the global_config.ini file.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
server.hosts.remote: Set value type for install_timeout

By default, we read values from the config system as
strings, so we have to specify we want an integer instead.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
scheduler.monitor_db: Notify grid admin when a dead host is reverified

Sometimes, our test machines enter "Repair Failed" state,
and it might take a while for the test admin to realize
that particular machine has problems. Be proactive and
send a notification email to the grid admin in such an
occasion.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
utils_cgroup: Add option to check if cgconfig service exists

On systemd enabled machines the cgroup subsystem is managed by systemd
itself. The logic in utils_cgroup.cgconfig_is_running() returns False even
if cgroups are running in systemd.

This patch adds function cgconfig_exists() that returns True if cgconfig is
available to enable skipping tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
utils_cgroup: Strip the slash from cgroup path

We have to strip the slash from cgroup path because the "join" function
takes the last element starting with slash as the root path.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
utils_cgroup: Fix regexp for cgroup controllers

On some systems the cpu and cpuacct controllers are mounted together
like cpu,cpuacct and we should count with it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
install-autotest-server.sh: Add support to install on Debian.

Signed-off-by: Rudá Moura <rmoura@redhat.com>
web frontend: Use django.contrib.staticfiles to deliver static content

frontend.wsgi now delivers both static (/media/) and dynamic content,
by using django.contrib.staticfiles.handlers.StaticFilesHandler and
STATIC_URL setting, so we can remove ADMIN_MEDIA_PREFIX due its deprecation,
starting from Django 1.3. Fix issue #743.

Signed-off-by: Rudá Moura <rmoura@redhat.com>
install-autotest-server.sh: Abort script if failed to install deps

We count on yum and apt-get in a working condition, so
the autotest dependencies can be installed. But sometimes
that won't hold true, and the install process needs to
be aborted right there. Add this check to the script.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
installation_support/autotest-install-packages-deps: return exist status code

So that other scripts can determine if the installation was successful or not.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Merge pull request #749 from autotest/setup-fix

install-autotest-server.sh: Abort script if failed to install deps
docs: fix usage of autodata

Should really be autoattribute, since we're referring to a
class attribute. This fixes a documentation build error.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
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>