This replaces the method previously used in lib/autotest/site_packages.py. To
avoid non-standard file permissions for tests in
/usr/share/autotest/client/site_tests, this patch creates site_autotest.py to
perform additional steps when preparing an autotest client for jobs. In
site_autotest.py, we extend the existing BaseAutotest._install() method to
perform several tasks prior to the standard autotest client preparation. Those
tasks include:
* Optionally install additional yum repositories (based on optional global_config.ini
option)
* Install, or upgrade, autoqa
* Copy all files in /etc/autoqa to the client
This patch also updates autoqa.spec and Makefile to include the new file.
---
Makefile | 3 +-
autoqa.spec | 3 +-
lib/autotest/site_autotest.py | 42 +++++++++++++++++++++++++++++++++++++++++
lib/autotest/site_packages.py | 34 ---------------------------------
4 files changed, 46 insertions(+), 36 deletions(-)
create mode 100644 lib/autotest/site_autotest.py
delete mode 100644 lib/autotest/site_packages.py
diff --git a/Makefile b/Makefile
index f8d65ad..4a2134a 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,8 @@ install: build
for t in tests/*; do cp -a $$t $(PREFIX)$(TEST_DIR); done
install -d $(PREFIX)$(AUTOTEST_DIR)/client/{bin,common_lib}
install -m 0644 lib/autotest/site_utils.py $(PREFIX)$(AUTOTEST_DIR)/client/bin/
- install -m 0644 lib/autotest/site_packages.py
$(PREFIX)$(AUTOTEST_DIR)/client/common_lib/
+ install -d $(PREFIX)$(AUTOTEST_DIR)/server
+ install -m 0644 lib/autotest/site_autotest.py $(PREFIX)$(AUTOTEST_DIR)/server/
( cd lib/python; $(PYTHON) setup.py install --skip-build --root $(PREFIX)/ )
build: lib/python/build
diff --git a/autoqa.spec b/autoqa.spec
index a2189bd..b8112b6 100644
--- a/autoqa.spec
+++ b/autoqa.spec
@@ -15,6 +15,7 @@ Requires: autotest
Requires: koji
Requires: python-fedora
Requires: mod_wsgi
+BuildRequires: autotest
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
@@ -59,7 +60,7 @@ rm -rf $RPM_BUILD_ROOT
%{testdir}
%{hookdir}
%{_datadir}/autotest/client/bin/site_utils.py*
-%{_datadir}/autotest/client/common_lib/site_packages.py*
+%{_datadir}/autotest/server/site_autotest.py*
%{python_sitelib}/autoqa*
diff --git a/lib/autotest/site_autotest.py b/lib/autotest/site_autotest.py
new file mode 100644
index 0000000..04bbd2c
--- /dev/null
+++ b/lib/autotest/site_autotest.py
@@ -0,0 +1,42 @@
+# site_autotest.py - site-specific autotest extensions for use in autoqa
+#
+# this must be copied to autotest/server/, because it is imported by
+# autotest/server/server.py
+#
+# Author: James Laska <jlaska(a)redhat.com>
+
+import os
+import logging
+import common
+from autotest_lib.server.autotest import BaseAutotest
+from autotest_lib.client.common_lib import global_config
+
+class SiteAutotest(BaseAutotest):
+ def _install(self, host=None, autodir=None, use_autoserv=True,
+ use_packaging=True):
+
+ # First, enable any requested yum repositories
+ logging.info("Installing autoqa on %s", host.hostname)
+ c = global_config.global_config
+ repository_cfg_urls = c.get_config_value(
+ "FEDORA.AUTOQA", "repository_cfg_urls", type=list,
default=list())
+
+ for url in repository_cfg_urls:
+ logging.debug("Enabling %s package repo" % os.path.basename(url))
+ host.run("cd /etc/yum.repos.d && (test -f %s || curl -s -O
%s)" % \
+ (os.path.basename(url), url))
+
+ # Next, ensure autoqa is installed and up-to-date
+ logging.debug("Installing or upgrading autoqa package")
+ host.run("yum -y install autoqa")
+
+ # Next, copy any autoqa config files
+ logging.debug("Copying autoqa configuration files")
+ host.send_file('/etc/autoqa', '/etc/autoqa', delete_dest=True)
+
+ result = host.run("rpm -q autoqa")
+ logging.info("Installation of %s completed" % result.stdout)
+
+ # Finally, continue installation by calling our parent
+ super(SiteAutotest, self)._install(host, autodir, use_autoserv, use_packaging)
+
diff --git a/lib/autotest/site_packages.py b/lib/autotest/site_packages.py
deleted file mode 100644
index 280e064..0000000
--- a/lib/autotest/site_packages.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# site_packages.py - site-specific autotest packages methods for use in autoqa
-#
-# this must be copied to autotest/client/common_lib, because it is imported by
-# autotest/client/common_lib/packages.py
-#
-# Author: Kamil Paral <kparal(a)redhat.com>
-
-import os, glob, shutil
-from autotest_lib.client.common_lib import base_packages
-
-class SitePackageManager(base_packages.BasePackageManager):
- def tar_package(self, pkg_name, src_dir, dest_dir, exclude_string=None):
- '''
- Same as common_lib.base_packages.tar_package, but it also copies all
- AutoQA config files into src_dir for our site_tests.
- '''
- autoqa_test = (os.path.basename(os.path.dirname(src_dir)) ==
'site_tests')
- configs = glob.glob('/etc/autoqa/*')
-
- # if this is our test, copy all config files to src_dir to be tarred
- # and transferred to client
- if autoqa_test:
- for config in configs:
- shutil.copy(config, src_dir)
-
- # run the parent method
- result = super(SitePackageManager, self).tar_package(pkg_name, src_dir, dest_dir,
exclude_string)
-
- # remove all the config files
- if autoqa_test:
- for config in configs:
- os.remove(os.path.join(src_dir, os.path.basename(config)))
-
- return result
--
1.7.3.4