From 1762312121a03e6acab45a1db6069f2ac8624a28 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 20 Jun 2012 16:35:21 +0000 Subject: [PATCH] Add a template directive for mostly FSM use for now, enable a non-dhcp address management scheme git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13133 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/Template.pm | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 53011d54a..b4a4d0500 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -172,6 +172,7 @@ sub subvars { $inc =~ s/#TABLEBLANKOKAY:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3,'1')/eg; $inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg; $inc =~ s/#COMMAND:([^#]+)#/command($1)/eg; + $inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg; $inc =~ s/#INCLUDE_NOP:([^#^\n]+)#/includefile($1,1,0)/eg; $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1,0,1)/eg; $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1,0,2)/eg; @@ -193,6 +194,39 @@ sub subvars { close($outh); return 0; } + +sub kickstartnetwork { + my $line = "network --bootproto="; + my $mactab = xCAT::Table->new('mac',-create=>0); + unless ($mactab) { die "mac table should always exist prior to flexcat specific template processing"; } + my $ent = $mactab->getNodeAttribs($node,['mac']); + unless ($ent and $ent->{mac}) { die "missing mac data for $node"; } + my $suffix = $ent->{mac}; + $suffix = lc($suffix); + if ($::XCATSITEVALS{managedaddressmode} eq "autoula") { + $line .= "static --device=$suffix --noipv4 --ipv6="; + $line .= autoulaaddress($suffix); + } else { + $line .= "dhcp"; + } + return $line; +} +sub autoulaaddress { + my $suffix = shift; + my $prefix = $::XCATSITEVALS{autoulaprefix}; + $suffix =~ /(..):(..:..):(..:..):(..)/; + my $leadbyte = $1; + my $mask = (($leadbyte & 2) ^ 2); + if ($mask) { + $leadbyte = $leadbyte | $mask; + } else { + $leadbyte = $leadbyte & 0xfd; #mask out the one bit + } + $suffix = "$leadbyte$2ff:fe$3$4"; + + return $prefix.$suffix; +} + sub machinepassword { if ($lastmachinepass) { #note, this should only happen after another call #to subvars that does *not* request reuse