diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 665a31d89..583e6c3f6 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -1430,6 +1430,8 @@ sub getAllNodeAttribs #Extract and substitute every node record, expanding groups and substituting as getNodeAttribs does my $self = shift; my $attribq = shift; + my $hashretstyle = shift; + my $rethash; my @results = (); my %donenodes ; #Remember those that have been done once to not return same node multiple times @@ -1476,7 +1478,12 @@ sub getAllNodeAttribs $att->{node} = $_; } $donenodes{$_} = 1; - push @results, @attrs; #$self->getNodeAttribs($_,@attribs); + + if ($hashretstyle) { + $rethash->{$_} = \@attrs; #$self->getNodeAttribs($_,\@attribs); + } else { + push @results, @attrs; #$self->getNodeAttribs($_,@attribs); + } } } } @@ -1484,7 +1491,11 @@ sub getAllNodeAttribs $self->{nodelist}->{_use_cache} = 0; xCAT::NodeRange::retain_cache(0); $query->finish(); - return @results; + if ($hashretstyle) { + return $rethash; + } else { + return @results; + } } #-------------------------------------------------------------------------- diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 7a03656ad..0051afaca 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -19,6 +19,7 @@ require DBI; our @ISA = qw(Exporter); our @EXPORT_OK = qw(genpassword); +my $utildata; #data to persist locally #-------------------------------------------------------------------------------- =head1 xCAT::Utils @@ -1917,7 +1918,7 @@ sub my_ip_facing #------------------------------------------------------------------------------- -=head3 nodeonmynet - checks to see if node is on the network +=head3 nodeonmynet - checks to see if node is on any network this server is attached to or remote network potentially managed by this system Arguments: Node name Returns: 1 if node is on the network @@ -1949,7 +1950,25 @@ sub nodeonmynet return 0; #Not supporting IPv6 here IPV6TODO } my $noden = unpack("N", inet_aton($nodeip)); - my @nets = split /\n/, `/sbin/ip route`; + my @nets; + if ($utildata->{nodeonmynetdata} and $utildata->{nodeonmynetdata}->{pid} == $$) { + } else { + @nets = split /\n/, `/sbin/ip route`; + my $nettab=xCAT::Table->new("networks"); + my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + foreach (@vnets) { + if ($_->{mgtifname} eq '!remote!') { #global scoped network + my $curm = unpack("N", inet_aton($_->{mask})); + my $bits=32; + until ($curm & 1) { + $bits--; + $curm=$curm>>1; + } + push @nets,$_->{'net'}."/".$bits." remote"; + } + } + $utildata->{nodeonmynetdata}->{pid}=$$; + $utildata->{nodeonmynetdata}->{n} foreach (@nets) { my @elems = split /\s+/; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 52c63906a..dc312b001 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -1580,6 +1580,7 @@ sub power { sub beacon { my $subcommand = shift; my $data; + unless ($subcommand) { $subcommand = "stat"; } if ($subcommand eq "stat") { } elsif ($subcommand eq "on") { $data = $session->set(new SNMP::Varbind([$beaconoid,$slot , 1,'INTEGER'])); diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index d84cc16db..8ebd4d221 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -16,6 +16,7 @@ use Fcntl ':flock'; my @dhcpconf; #Hold DHCP config file contents to be written back. my @nrn; # To hold output of networks table to be consulted throughout process +my $haveremotenics; my $domain; my $omshell; my $statements; #Hold custom statements to be slipped into host declarations @@ -474,6 +475,7 @@ sub process_request my $nm = $_->{mask}; #$callback->({data => ["array of nets $n : $if : $nm"]}); if ($if =~ /!remote!/) { #only take in networks with special interface + $haveremotenics=1; push @nrn, "$n:$if:$nm"; } } @@ -616,7 +618,7 @@ sub process_request } else { - unless (xCAT::Utils->nodeonmynet($_)) + unless ($haveremotenics or xCAT::Utils->nodeonmynet($_)) { next; } diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index df27f838a..127a346d8 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -42,6 +42,7 @@ my $vmmaxp=64; my $mactab; my $nrtab; my $machash; +my %usedmacs; my $status_noop="XXXno-opXXX"; sub handled_commands { @@ -185,26 +186,37 @@ sub build_nicstruct { push @macs,$macaddr; } } - unless (scalar(@macs)) { - 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 - my $leading=int(rand(65535)); - $leading=$leading|512; - $leading=$leading&65279; - my $n=inet_aton($node); - my $tail; - if ($n) { - $tail=unpack("N",$n); + unless (scalar(@macs) >= scalar(@nics)) { + my $neededmacs=scalar(@nics) - scalar(@macs); + my $macstr; + my $tmac; + my $leading; + 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; } - unless ($tail) { - $tail=int(rand(4294967295)); - } - my $macstr = sprintf("%04x%08x",$leading,$tail); - $macstr =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; - $mactab->setNodeAttribs($node,{mac=>$macstr}); + $mactab->setNodeAttribs($node,{mac=>join('|',@macs)}); $nrtab->setNodeAttribs($node,{netboot=>'pxe'}); $doreq->({command=>['makedhcp'],node=>[$node]}); - push @macs,$macstr; } my @rethashes; foreach (@macs) { @@ -775,7 +787,16 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes $vmhash = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','storage','memory','cpus','nics','bootorder','virtflags']); $mactab = xCAT::Table->new("mac",-create=>1); $nrtab= xCAT::Table->new("noderes",-create=>1); - $machash = $mactab->getNodesAttribs($noderange,['mac']); + $machash = $mactab->getAllNodeAttribs(['mac'],1); + my $macs; + my $mac; + foreach (keys %$machash) { + $macs=$machash->{$_}->[0]->{mac}; + foreach $mac (split /\|/,$macs) { + $mac =~ s/\!.*//; + $usedmacs{lc($mac)}=1; + } + } } sub process_request { diff --git a/xCAT-server/share/xcat/install/sles/service.sles11.tmpl b/xCAT-server/share/xcat/install/sles/service.sles11.tmpl index dd55001d4..0428205f9 100644 --- a/xCAT-server/share/xcat/install/sles/service.sles11.tmpl +++ b/xCAT-server/share/xcat/install/sles/service.sles11.tmpl @@ -44,7 +44,7 @@ xntp rsync - nmp + nmap perl-DBI vsftpd perl-DBD-mysql