From f6b9fc6a5f4463e33b223e45c0ee9a8a5d6b0c1a Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 30 Aug 2010 19:45:10 +0000 Subject: [PATCH] -Switch to common getMacAddress code git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7312 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kvm.pm | 43 +---------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 282683d46..31de0081f 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -462,54 +462,13 @@ sub getNodeUUID { sub build_nicstruct { my $rethash; my $node = shift; - my @macs=(); my @nics=(); if ($confdata->{vm}->{$node}->[0]->{nics}) { @nics = split /,/,$confdata->{vm}->{$node}->[0]->{nics}; } else { @nics = ('virbr0'); } - if ($confdata->{mac}->{$node}->[0]->{mac}) { - my $macdata=$confdata->{mac}->{$node}->[0]->{mac}; - foreach my $macaddr (split /\|/,$macdata) { - $macaddr =~ s/\!.*//; - push @macs,$macaddr; - } - } - unless (scalar(@macs) >= scalar(@nics)) { - #TODO: MUST REPLACE WITH VMCOMMON CODE - my $neededmacs=scalar(@nics) - scalar(@macs); - my $macstr; - my $tmac; - my $leading; - srand; - while ($neededmacs--) { - my $allbutmult = 65279; # & mask for bitwise clearing of the multicast bit of mac - my $localad=512; # | to set the bit for locally admnistered mac address - $leading=int(rand(65535)); - $leading=$leading|512; - $leading=$leading&65279; - my $n=inet_aton($node); - my $tail; - if ($n) { - $tail=unpack("N",$n); - } - unless ($tail) { - $tail=int(rand(4294967295)); - } - $tmac = sprintf("%04x%08x",$leading,$tail); - $tmac =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; - if ($usedmacs{$tmac}) { #If we have a collision we can actually perceive, retry the generation of this mac - $neededmacs++; - next; - } - $usedmacs{$tmac}=1; - push @macs,$tmac; - } - #$mactab->setNodeAttribs($node,{mac=>join('|',@macs)}); - #$nrtab->setNodeAttribs($node,{netboot=>'pxe'}); - #$doreq->({command=>['makedhcp'],node=>[$node]}); - } + my @macs=xCAT::VMCommon::getMacAddresses($confdata,$node,scalar @nics); my @rethashes; foreach (@macs) { my $rethash;