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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Automatically replace cdkeys in unattended_install scripts.
  A dummy string (KVM_TEST_CDKEY) is replaced by an actual cdkey (normally
  defined in cdkeys.cfg) before installation begins.
- Make all Windows unattended scripts use the same dummy string.
- Add dummy cdkeys to cdkeys.cfg.sample, for WinVista, Win2008 and Win7.
  These must be replaced manually by the user.

Warning: this patch has undergone zero testing.

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/cdkeys.cfg.sample                 |   13 +++++++------
 client/tests/kvm/scripts/unattended.py             |   17 ++++++++++++++++-
 client/tests/kvm/unattended/win2003-32.sif         |    2 +-
 client/tests/kvm/unattended/win2003-64.sif         |    2 +-
 .../kvm/unattended/win2008-32-autounattend.xml     |    2 +-
 .../kvm/unattended/win2008-64-autounattend.xml     |    2 +-
 .../kvm/unattended/win2008-r2-autounattend.xml     |    2 +-
 .../tests/kvm/unattended/win7-32-autounattend.xml  |    2 +-
 .../tests/kvm/unattended/win7-64-autounattend.xml  |    2 +-
 .../kvm/unattended/winvista-32-autounattend.xml    |    2 +-
 .../kvm/unattended/winvista-64-autounattend.xml    |    2 +-
 client/tests/kvm/unattended/winxp32.sif            |    2 +-
 12 files changed, 33 insertions(+), 17 deletions(-)

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=*
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux