diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 268640ff6..350fe2e6c 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -471,7 +471,18 @@ sub get_win_prodkey { my $keytab = xCAT::Table->new("prodkey",-create=>0); my $keyent; if ($keytab) { - $keyent = $keytab->getAttribs({product=>$osvariant},"key"); + my @keyents = $keytab->getNodeAttribs($node,[qw/product key/]); + foreach my $tkey (@keyents) { + if ($tkey->{product} eq $osvariant) { + $keyent = $tkey; + last; + } elsif (not $tkey->{product}) { + $keyent = $tkey; + } + } + unless ($keyent) { + $keyent = $keytab->getAttribs({product=>$osvariant},"key"); + } } if ($keyent) { return "OnError".$keyent->{key}."";