diff mbox

[KVM-AUTOTEST] KVM test: automate handling of cdkeys in unattended_install scripts

Message ID 1265218191-19352-1-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Feb. 3, 2010, 5:29 p.m. UTC
None
diff mbox

Patch

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 @@ 
             </ImageInstall>
             <UserData>
                 <ProductKey>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                     <WillShowUI>OnError</WillShowUI>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
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 @@ 
             <UserData>
                 <ProductKey>
                     <WillShowUI>OnError</WillShowUI>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
             </UserData>
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 @@ 
             <UserData>
                 <ProductKey>
                     <WillShowUI>OnError</WillShowUI>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
             </UserData>
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 @@ 
             </ImageInstall>
             <UserData>
                 <ProductKey>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                     <WillShowUI>OnError</WillShowUI>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
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 @@ 
             <UserData>
                 <ProductKey>
                     <WillShowUI>OnError</WillShowUI>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
             </UserData>
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 @@ 
             </ImageInstall>
             <UserData>
                 <ProductKey>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                     <WillShowUI>OnError</WillShowUI>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
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 @@ 
             <UserData>
                 <ProductKey>
                     <WillShowUI>OnError</WillShowUI>
-                    <Key>replace-with-your-prodkey</Key>
+                    <Key>KVM_TEST_CDKEY</Key>
                 </ProductKey>
                 <AcceptEula>true</AcceptEula>
             </UserData>
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=*