From patchwork Wed Feb 3 17:29:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 76759 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o13HVUXk028128 for ; Wed, 3 Feb 2010 17:31:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932731Ab0BCRb1 (ORCPT ); Wed, 3 Feb 2010 12:31:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27707 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932707Ab0BCRb0 (ORCPT ); Wed, 3 Feb 2010 12:31:26 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o13HVP0s028161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Feb 2010 12:31:25 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o13HVO6x026204; Wed, 3 Feb 2010 12:31:25 -0500 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o13HVMTN020600; Wed, 3 Feb 2010 12:31:23 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: automate handling of cdkeys in unattended_install scripts Date: Wed, 3 Feb 2010 19:29:51 +0200 Message-Id: <1265218191-19352-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Feb 2010 17:31:31 +0000 (UTC) diff --git a/client/tests/kvm/cdkeys.cfg.sample b/client/tests/kvm/cdkeys.cfg.sample index 17ec5cc..2d1d05d 100644 --- a/client/tests/kvm/cdkeys.cfg.sample +++ b/client/tests/kvm/cdkeys.cfg.sample @@ -1,8 +1,7 @@ # Copy this file to cdkeys.cfg and edit it. # # Replace the 'CDKEY' strings with real cdkeys where necessary. -# Guests that do not require cdkeys by default are commented out. -# You may uncomment them if necessary. +# Feel free to add additional guests as required. RHEL.5.3.i386: cdkey = CDKEY RHEL.5.3.x86_64: cdkey = CDKEY @@ -11,7 +10,9 @@ WinXP.32: cdkey = CDKEY WinXP.64: cdkey = CDKEY Win2003.32: cdkey = CDKEY Win2003.64: cdkey = CDKEY -#WinVista.32: cdkey = CDKEY -#WinVista.64: cdkey = CDKEY -#Win2008.32: cdkey = CDKEY -#Win2008.64: cdkey = CDKEY +WinVista.32: cdkey = CDKEY +WinVista.64: cdkey = CDKEY +Win2008.32: cdkey = CDKEY +Win2008.64: cdkey = CDKEY +Win7.32: cdkey = CDKEY +Win7.64: cdkey = CDKEY diff --git a/client/tests/kvm/scripts/unattended.py b/client/tests/kvm/scripts/unattended.py index 13f431a..87a8973 100755 --- a/client/tests/kvm/scripts/unattended.py +++ b/client/tests/kvm/scripts/unattended.py @@ -97,7 +97,22 @@ class UnattendedInstall(object): dest_fname = "autounattend.xml" dest = os.path.join(self.floppy_mount, dest_fname) - shutil.copyfile(self.unattended_file, dest) + + # Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey + # provided for this test + 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, + unattended_contents) + else: + print ("WARNING: 'cdkey' required but not specified for this " + "unattended installation") + + # Write the unattended file contents to 'dest' + open(dest, 'w').write(unattended_contents) if self.finish_program: dest_fname = os.path.basename(self.finish_program) diff --git a/client/tests/kvm/unattended/win2003-32.sif b/client/tests/kvm/unattended/win2003-32.sif index 901f435..5c90b03 100644 --- a/client/tests/kvm/unattended/win2003-32.sif +++ b/client/tests/kvm/unattended/win2003-32.sif @@ -25,7 +25,7 @@ OemSkipWelcome = 1 FullName = "rhqe" OrgName = "REDHAT" ComputerName = * -ProductKey = [replace-with-your-prodkey] +ProductKey = KVM_TEST_CDKEY [LicenseFilePrintData] AutoMode=PerServer diff --git a/client/tests/kvm/unattended/win2003-64.sif b/client/tests/kvm/unattended/win2003-64.sif index 9f09033..1d40d6d 100644 --- a/client/tests/kvm/unattended/win2003-64.sif +++ b/client/tests/kvm/unattended/win2003-64.sif @@ -25,7 +25,7 @@ OemSkipWelcome = 1 FullName = "rhqe" OrgName = "REDHAT" ComputerName = * -ProductKey = [replace-with-your-prodkey] +ProductKey = KVM_TEST_CDKEY [LicenseFilePrintData] AutoMode=PerServer diff --git a/client/tests/kvm/unattended/win2008-32-autounattend.xml b/client/tests/kvm/unattended/win2008-32-autounattend.xml index d8f7654..07c2889 100644 --- a/client/tests/kvm/unattended/win2008-32-autounattend.xml +++ b/client/tests/kvm/unattended/win2008-32-autounattend.xml @@ -53,7 +53,7 @@ - replace-with-your-prodkey + KVM_TEST_CDKEY OnError true diff --git a/client/tests/kvm/unattended/win2008-64-autounattend.xml b/client/tests/kvm/unattended/win2008-64-autounattend.xml index 4202b93..fc996d6 100644 --- a/client/tests/kvm/unattended/win2008-64-autounattend.xml +++ b/client/tests/kvm/unattended/win2008-64-autounattend.xml @@ -45,7 +45,7 @@ OnError - replace-with-your-prodkey + KVM_TEST_CDKEY true diff --git a/client/tests/kvm/unattended/win2008-r2-autounattend.xml b/client/tests/kvm/unattended/win2008-r2-autounattend.xml index 4202b93..fc996d6 100644 --- a/client/tests/kvm/unattended/win2008-r2-autounattend.xml +++ b/client/tests/kvm/unattended/win2008-r2-autounattend.xml @@ -45,7 +45,7 @@ OnError - replace-with-your-prodkey + KVM_TEST_CDKEY true diff --git a/client/tests/kvm/unattended/win7-32-autounattend.xml b/client/tests/kvm/unattended/win7-32-autounattend.xml index 46e7064..742915b 100644 --- a/client/tests/kvm/unattended/win7-32-autounattend.xml +++ b/client/tests/kvm/unattended/win7-32-autounattend.xml @@ -53,7 +53,7 @@ - replace-with-your-prodkey + KVM_TEST_CDKEY OnError true diff --git a/client/tests/kvm/unattended/win7-64-autounattend.xml b/client/tests/kvm/unattended/win7-64-autounattend.xml index 4202b93..fc996d6 100644 --- a/client/tests/kvm/unattended/win7-64-autounattend.xml +++ b/client/tests/kvm/unattended/win7-64-autounattend.xml @@ -45,7 +45,7 @@ OnError - replace-with-your-prodkey + KVM_TEST_CDKEY true diff --git a/client/tests/kvm/unattended/winvista-32-autounattend.xml b/client/tests/kvm/unattended/winvista-32-autounattend.xml index 5d2b038..5a0c524 100644 --- a/client/tests/kvm/unattended/winvista-32-autounattend.xml +++ b/client/tests/kvm/unattended/winvista-32-autounattend.xml @@ -47,7 +47,7 @@ - replace-with-your-prodkey + KVM_TEST_CDKEY OnError true diff --git a/client/tests/kvm/unattended/winvista-64-autounattend.xml b/client/tests/kvm/unattended/winvista-64-autounattend.xml index 812db40..bb52123 100644 --- a/client/tests/kvm/unattended/winvista-64-autounattend.xml +++ b/client/tests/kvm/unattended/winvista-64-autounattend.xml @@ -39,7 +39,7 @@ OnError - replace-with-your-prodkey + KVM_TEST_CDKEY true diff --git a/client/tests/kvm/unattended/winxp32.sif b/client/tests/kvm/unattended/winxp32.sif index dc4ef29..963795c 100644 --- a/client/tests/kvm/unattended/winxp32.sif +++ b/client/tests/kvm/unattended/winxp32.sif @@ -25,7 +25,7 @@ OEMSkipRegional=1 [UserData] - ProductKey=[replace-with-your-prodkey] + ProductKey=KVM_TEST_CDKEY FullName="Autotest Mindless Drone" OrgName="Autotest" ComputerName=*