From ca341e5acdfcff5eae8bc042b3c0a70f64aee6f4 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 9 Mar 2011 20:22:57 +0000 Subject: [PATCH] Add UUID management to common 'Mac' management code. Helps with IPv6 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9021 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/VMCommon.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/perl-xCAT/xCAT/VMCommon.pm b/perl-xCAT/xCAT/VMCommon.pm index 2b709db2f..28856c90c 100644 --- a/perl-xCAT/xCAT/VMCommon.pm +++ b/perl-xCAT/xCAT/VMCommon.pm @@ -87,6 +87,7 @@ sub requestMacAddresses { my @allmacs; my $complete = 0; my $updatesneeded; + my $vpdupdates; srand(); #Re-seed the rng. This will make the mac address generation less deterministic while (not $complete and scalar @$neededmacs) { foreach $node (@$neededmacs) { @@ -130,12 +131,29 @@ sub requestMacAddresses { $updatesneeded->{$node}->{mac}=$macdata; $tablecfg->{dhcpneeded}->{$node}=1; #at our leisure, this dhcp binding should be updated } + #now that macs are done, do simple uuid... (done after to benefit from having at least one mac address) + unless ($tablecfg->{vpd}->{$node}->[0]->{uuid}) { + my $umac = $macs[0]; + my $uuid; + if ($umac) { + $uuid=xCAT::Utils::genUUID(mac=>$umac); + } else { #shouldn't be possible, but just in case + $uuid=xCAT::Utils::genUUID(); + } + $vpdupdates->{$node}->{uuid}=$uuid; + $tablecfg->{vpd}->{$node}=[{uuid=>$uuid}]; + $tablecfg->{dhcpneeded}->{$node}=1; #at our leisure, this dhcp binding should be updated + } #TODO: LOCK if a distributed lock management structure goes in place, that may be a faster solution than this #this code should be safe though as it is, if a tiny bit slower #can also be sped up by doing it for a noderange in a sweep instead of once per node #but the current architecture has this called at a place that is unaware of the larger context #TODO2.4 would be either the lock management or changing this to make large scale mkvm faster } + if (defined $vpdupdates) { + my $vpdtab = xCAT::Table->new('vpd',-create=>1); + $vpdtab->setNodesAttribs($vpdupdates); + } if (defined $updatesneeded) { my $mactab = xCAT::Table->new('mac',-create=>1); $mactab->setNodesAttribs($updatesneeded);