From patchwork Tue Feb 22 15:16:43 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: 580661 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 p1MFGtC8025827 for ; Tue, 22 Feb 2011 15:16:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754000Ab1BVPQv (ORCPT ); Tue, 22 Feb 2011 10:16:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753871Ab1BVPQu (ORCPT ); Tue, 22 Feb 2011 10:16:50 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1MFGm9C026197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Feb 2011 10:16:48 -0500 Received: from freedom.redhat.com (vpn-10-58.rdu.redhat.com [10.11.10.58]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1MFGjS2000544; Tue, 22 Feb 2011 10:16:46 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Remove last references to env variables on unattended setup Date: Tue, 22 Feb 2011 12:16:43 -0300 Message-Id: <1298387803-25006-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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]); Tue, 22 Feb 2011 15:16:58 +0000 (UTC) diff --git a/client/tests/kvm/test_setup.py b/client/tests/kvm/test_setup.py index eebe0c3..b5c3a49 100644 --- a/client/tests/kvm/test_setup.py +++ b/client/tests/kvm/test_setup.py @@ -227,7 +227,8 @@ class UnattendedInstallConfig(object): 'unattended_file', 'medium', 'url', 'kernel', 'initrd', 'nfs_server', 'nfs_dir', 'install_virtio', 'floppy', 'cdrom_unattended', 'boot_path', 'extra_params', - 'qemu_img_binary'] + 'qemu_img_binary', 'cdkey', 'virtio_storage_path', + 'virtio_network_path', 'virtio_network_installer_path'] for a in attributes: setattr(self, a, params.get(a, '')) @@ -278,10 +279,9 @@ class UnattendedInstallConfig(object): error.context('Reading answer file %s' % self.unattended_file) unattended_contents = open(self.unattended_file).read() dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b' - real_cdkey = os.environ.get('KVM_TEST_cdkey') if re.search(dummy_cdkey_re, unattended_contents): - if real_cdkey: - unattended_contents = re.sub(dummy_cdkey_re, real_cdkey, + if self.cdkey: + unattended_contents = re.sub(dummy_cdkey_re, self.cdkey, unattended_contents) else: print ("WARNING: 'cdkey' required but not specified for " @@ -301,7 +301,7 @@ class UnattendedInstallConfig(object): unattended_contents = re.sub(dummy_medium_re, content, unattended_contents) - def replace_virtio_key(contents, dummy_re, env): + def replace_virtio_key(contents, dummy_re, attribute_name): """ Replace a virtio dummy string with contents. @@ -313,7 +313,7 @@ class UnattendedInstallConfig(object): @param env: Name of the environment variable. """ dummy_path = "C:" - driver = os.environ.get(env, '') + driver = getattr(self, attribute_name, '') if re.search(dummy_re, contents): if self.install_virtio == "yes": @@ -332,15 +332,17 @@ class UnattendedInstallConfig(object): return contents vdict = {r'\bKVM_TEST_STORAGE_DRIVER_PATH\b': - 'KVM_TEST_virtio_storage_path', + 'virtio_storage_path', r'\bKVM_TEST_NETWORK_DRIVER_PATH\b': - 'KVM_TEST_virtio_network_path', + 'virtio_network_path', r'\bKVM_TEST_VIRTIO_NETWORK_INSTALLER\b': - 'KVM_TEST_virtio_network_installer_path'} + 'virtio_network_installer_path'} for vkey in vdict: - unattended_contents = replace_virtio_key(unattended_contents, - vkey, vdict[vkey]) + unattended_contents = replace_virtio_key( + contents=unattended_contents, + dummy_re=vkey, + attribute_name=vdict[vkey]) logging.debug("Unattended install contents:") for line in unattended_contents.splitlines():