From patchwork Wed May 4 05:04:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 752602 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4454Yt0027966 for ; Wed, 4 May 2011 05:04:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752277Ab1EDFEV (ORCPT ); Wed, 4 May 2011 01:04:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35437 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997Ab1EDFEU (ORCPT ); Wed, 4 May 2011 01:04:20 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4454IMA001023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 4 May 2011 01:04:18 -0400 Received: from freedom.redhat.com (vpn-8-36.rdu.redhat.com [10.11.8.36]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4454GMT013859; Wed, 4 May 2011 01:04:17 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: installer: Fix KojiInstaller bug Date: Wed, 4 May 2011 02:04:18 -0300 Message-Id: <1304485458-28381-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 04 May 2011 05:04:34 +0000 (UTC) That code was not updated during the last version of the refactor patches, so it was referencing the old KojiDownloader class. Let's fix this. Signed-off-by: Lucas Meneghel Rodrigues --- client/virt/kvm_installer.py | 63 ++++++++++++++++++++++++++++++++++------- 1 files changed, 52 insertions(+), 11 deletions(-) diff --git a/client/virt/kvm_installer.py b/client/virt/kvm_installer.py index dc1ffce..54829f4 100644 --- a/client/virt/kvm_installer.py +++ b/client/virt/kvm_installer.py @@ -353,7 +353,9 @@ class YumInstaller(BaseInstaller): class KojiInstaller(YumInstaller): """ Class that handles installing KVM from the fedora build service, koji. - It uses yum to install and remove packages. + + It uses yum to install and remove packages. Packages are specified + according to the syntax defined in the PkgSpec class. """ load_stock_modules = True def set_install_params(self, test, params): @@ -364,27 +366,37 @@ class KojiInstaller(YumInstaller): @param params: Dictionary with test arguments """ super(KojiInstaller, self).set_install_params(test, params) - default_koji_cmd = '/usr/bin/koji' - default_src_pkg = 'qemu' - self.src_pkg = params.get("src_pkg", default_src_pkg) self.tag = params.get("koji_tag", None) - self.build = params.get("koji_build", None) - self.koji_cmd = params.get("koji_cmd", default_koji_cmd) + self.koji_cmd = params.get("koji_cmd", None) + if self.tag is not None: + virt_utils.set_default_koji_tag(self.tag) + self.koji_pkgs = eval(params.get("koji_pkgs", "[]")) def _get_packages(self): """ Downloads the specific arch RPMs for the specific build name. """ - downloader = virt_utils.KojiDownloader(cmd=self.koji_cmd) - downloader.get(src_package=self.src_pkg, tag=self.tag, - build=self.build, dst_dir=self.srcdir) + koji_client = virt_utils.KojiClient(cmd=self.koji_cmd) + for pkg_text in self.koji_pkgs: + pkg = virt_utils.KojiPkgSpec(pkg_text) + if pkg.is_valid(): + koji_client.get_pkgs(pkg, dst_dir=self.srcdir) + else: + logging.error('Package specification (%s) is invalid: %s', pkg, + pkg.describe_invalid()) + + + def _clean_previous_installs(self): + kill_qemu_processes() + removable_packages = " ".join(self._get_rpm_names()) + utils.system("yum -y remove %s" % removable_packages) def install(self): - super(KojiInstaller, self)._clean_previous_installs() + self._clean_previous_installs() self._get_packages() - super(KojiInstaller, self)._install_packages() + self._install_packages() self.install_unittests() create_symlinks(test_bindir=self.test_bindir, bin_list=self.qemu_bin_paths, @@ -394,6 +406,35 @@ class KojiInstaller(YumInstaller): virt_installer.save_build(self.srcdir, self.results_dir) + def _get_rpm_names(self): + all_rpm_names = [] + koji_client = virt_utils.KojiClient(cmd=self.koji_cmd) + for pkg_text in self.koji_pkgs: + pkg = virt_utils.KojiPkgSpec(pkg_text) + rpm_names = koji_client.get_pkg_rpm_names(pkg) + all_rpm_names += rpm_names + return all_rpm_names + + + def _get_rpm_file_names(self): + all_rpm_file_names = [] + koji_client = virt_utils.KojiClient(cmd=self.koji_cmd) + for pkg_text in self.koji_pkgs: + pkg = virt_utils.KojiPkgSpec(pkg_text) + rpm_file_names = koji_client.get_pkg_rpm_file_names(pkg) + all_rpm_file_names += rpm_file_names + return all_rpm_file_names + + + def _install_packages(self): + """ + Install all downloaded packages. + """ + os.chdir(self.srcdir) + rpm_file_names = " ".join(self._get_rpm_file_names()) + utils.system("yum --nogpgcheck -y localinstall %s" % rpm_file_names) + + class SourceDirInstaller(BaseInstaller): """ Class that handles building/installing KVM directly from a tarball or