diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm
index 01607c92d..8b46de512 100644
--- a/xCAT-server/lib/perl/xCAT/Template.pm
+++ b/xCAT-server/lib/perl/xCAT/Template.pm
@@ -1,6 +1,7 @@
#!/usr/bin/perl
-use xCAT::TZUtils;
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
+use xCAT::TZUtils;
+use xCAT::WinUtils;
package xCAT::Template;
use strict;
@@ -186,7 +187,8 @@ sub subvars {
$inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1,0,2)/eg;
$inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1,0,3)/eg;
$inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg;
- $inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/e;
+ $inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg;
+ $inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg;
$inc =~ s/#HOSTNAME#/$node/g;
my $nrtab = xCAT::Table->new("noderes");
@@ -256,6 +258,18 @@ sub subvars {
close($outh);
return 0;
}
+sub get_win_prodkey {
+ my $osvariant = shift;
+ my $keytab = xCAT::Table->new("prodkey",-create=>0);
+ my $keyent = $keytab->getAttribs({product=>$osvariant},"key");
+ if ($keyent) {
+ return "OnError".$keyent->{key}."";
+ }
+ if ($xCAT::WinUtils::kmskeymap{$osvariant}) {
+ return "OnError".$xCAT::WinUtils::kmskeymap{$osvariant}."";
+ }
+ return ""; #in the event that we have no specified key and no KMS key, then try with no key, user may have used some other mechanism
+}
sub esxipv6setup {
if ($::XCATSITEVALS{managedaddressmode} ne "autoula") { return ""; } # blank unless autoula
diff --git a/xCAT-server/lib/perl/xCAT/WinUtils.pm b/xCAT-server/lib/perl/xCAT/WinUtils.pm
index 487f368d4..6c3d1ca23 100644
--- a/xCAT-server/lib/perl/xCAT/WinUtils.pm
+++ b/xCAT-server/lib/perl/xCAT/WinUtils.pm
@@ -8,20 +8,20 @@ use strict;
#ms uniquely identifies the version and 'flavor', processor architecture does not factor in
#reference: http://technet.microsoft.com/en-us/library/jj612867.aspx
#fyi, hyper-v 2012 has no license key, it's a free product
-my %kmskeymap = (
- "win8-professional" => "NG4HW-VH26C-733KW-K6F98-J8CK4",
- "win8-professional_n" => "XCVCF-2NXM9-723PB-MHCB7-2RYQQ",
- "win8-enterprise" => "32JNW-9KQ84-P47T8-D8GGY-CWCK7",
- "win8-enterprise_n" => "JMNMF-RHW7P-DMY6X-RF3DR-X2BQT",
- "win2012-standard" => "XC9B7-NBPP2-83J2H-RHMBY-92BT4", #note that core and non-core share KMS key
- "win2012-datacenter" => "48HP8-DN98B-MYWDG-T2DCC-8W83P",
- "win7-professional" => "FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4",
- "win7-professional_n" => "MRPKT-YTG23-K7D7T-X2JMM-QY7MG",
- "win7-professional_e" => "W82YF-2Q76Y-63HXB-FGJG9-GF7QX",
- "win7-enterprise" => "33PXH-7Y6KF-2VJC9-XBBR8-HVTHH",
- "win7-enterprise_n" => "YDRBP-3D83W-TY26F-D46B2-XCKRJ",
- "win7-enterprise_e" => "C29WB-22CC8-VJ326-GHFJW-H9DH4",
- "win2k8r2-standard" => "YC6KT-GKW9T-YTKYR-T4X34-R7VHC",
- "win2k8r2-enterprise" => "489J6-VHDMP-X63PK-3K798-CPX3Y",
- "win2k8r2-datacenter" => "74YFP-3QFB3-KQT8W-PMXWJ-7M648", #note, itanium had a different key, but we won't support that...
+our %kmskeymap = (
+ "win8.professional" => "NG4HW-VH26C-733KW-K6F98-J8CK4",
+ "win8.professional_n" => "XCVCF-2NXM9-723PB-MHCB7-2RYQQ",
+ "win8.enterprise" => "32JNW-9KQ84-P47T8-D8GGY-CWCK7",
+ "win8.enterprise_n" => "JMNMF-RHW7P-DMY6X-RF3DR-X2BQT",
+ "win2012.standard" => "XC9B7-NBPP2-83J2H-RHMBY-92BT4", #note that core and non-core share KMS key
+ "win2012.datacenter" => "48HP8-DN98B-MYWDG-T2DCC-8W83P",
+ "win7.professional" => "FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4",
+ "win7.professional_n" => "MRPKT-YTG23-K7D7T-X2JMM-QY7MG",
+ "win7.professional_e" => "W82YF-2Q76Y-63HXB-FGJG9-GF7QX",
+ "win7.enterprise" => "33PXH-7Y6KF-2VJC9-XBBR8-HVTHH",
+ "win7.enterprise_n" => "YDRBP-3D83W-TY26F-D46B2-XCKRJ",
+ "win7.enterprise_e" => "C29WB-22CC8-VJ326-GHFJW-H9DH4",
+ "win2k8r2.standard" => "YC6KT-GKW9T-YTKYR-T4X34-R7VHC",
+ "win2k8r2.enterprise" => "489J6-VHDMP-X63PK-3K798-CPX3Y",
+ "win2k8r2.datacenter" => "74YFP-3QFB3-KQT8W-PMXWJ-7M648", #note, itanium had a different key, but we won't support that...
);
diff --git a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
index 262f2a901..7ec38d2ea 100644
--- a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
@@ -57,6 +57,7 @@
true
xCAT USER
xCAT
+ #WINPRODKEY:win2012.datacenter#
diff --git a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
index 262f2a901..7ec38d2ea 100644
--- a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
+++ b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
@@ -57,6 +57,7 @@
true
xCAT USER
xCAT
+ #WINPRODKEY:win2012.datacenter#
diff --git a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
index 769004f2e..7b76f1c12 100644
--- a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
@@ -47,6 +47,7 @@
true
xCAT USER
xCAT
+ #WINPRODKEY:win2012.standard#
diff --git a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
index 1a0e6a27a..9db2b8f1a 100644
--- a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
+++ b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
@@ -57,6 +57,7 @@
true
xCAT USER
xCAT
+ #WINPRODKEY:win2012.standard#