diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 85044b908..3d87f293b 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -1,6 +1,13 @@ #!/usr/bin/perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::MacMap; + +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + require Exporter; our @ISA=qw/Exporter/; our @EXPORT_OK=qw/walkoid/; @@ -177,11 +184,19 @@ sub rvlan { #first order of business is to identify the target switches my $switchtab=xCAT::Table->new('switch',-create=>0); unless ($switchtab) { return; } - my $switchents = $switchtab->getNodesAttribs($nodes,[qw/switch port/]); + my $switchents = $switchtab->getNodesAttribs($nodes,[qw/switch port interface/]); my $node; foreach $node (keys %$switchents) { my $entry; foreach $entry (@{$switchents->{$node}}) { + #skip the none primary interface. + # The vlaue of the primary interface could be empty, primary or primary:ethx + if (defined($entry->{interface})) { + if ($entry->{interface} !~ /primary/) { + next; + } + } + $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $node; } } @@ -319,11 +334,17 @@ sub refresh_table { } } my %checked_pairs; - my @entries = $self->{switchtab}->getAllNodeAttribs(['node','port','switch']); + my @entries = $self->{switchtab}->getAllNodeAttribs(['node','port','switch','interface']); #Build hash of switch port names per switch $self->{switches} = {}; foreach my $entry (@entries) { if (defined($entry->{switch}) and $entry->{switch} ne "" and defined($entry->{port}) and $entry->{port} ne "") { + #skip the none primary interface. + # The vlaue of the primary interface could be empty, primary or primary:ethx + if (defined($entry->{interface})) { + if ($entry->{interface} !~ /primary/) { next;} + } + if ( !$self->{switches}->{$entry->{switch}}->{$entry->{port}}) { $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $entry->{node}; diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 69cc6b103..777a7bedf 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -194,6 +194,7 @@ sub makescript push @scriptd, "GROUP=$groups->{groups}\n"; push @scriptd, "export GROUP\n"; + # read the sshbetweennodes attribute and process my $enablessh=xCAT::TableUtils->enablessh($node); if ($enablessh == 1) { @@ -368,78 +369,17 @@ sub makescript } #get vlan related items - my $vlan; - my $swtab = xCAT::Table->new("switch", -create => 0); - if ($swtab) { - my $tmp = $swtab->getNodeAttribs($node, ['vlan'],prefetchcache=>1); - if (defined($tmp) && ($tmp) && $tmp->{vlan}) - { - $vlan = $tmp->{vlan}; - push @scriptd, "VLANID='" . $vlan . "'\n"; - push @scriptd, "export VLANID\n"; - } else { - my $vmtab = xCAT::Table->new("vm", -create => 0); - if ($vmtab) { - my $tmp1 = $vmtab->getNodeAttribs($node, ['nics'],prefetchcache=>1); - if (defined($tmp1) && ($tmp1) && $tmp1->{nics}) - { - push @scriptd, "VMNODE='YES'\n"; - push @scriptd, "export VMNODE\n"; - - my @nics=split(',', $tmp1->{nics}); - foreach my $nic (@nics) { - if ($nic =~ /^vl([\d]+)$/) { - $vlan = $1; - push @scriptd, "VLANID='" . $vlan . "'\n"; - push @scriptd, "export VLANID\n"; - last; - } - } - } - } - } - - if ($vlan) { - my $nwtab=xCAT::Table->new("networks", -create =>0); - if ($nwtab) { - my $sent = $nwtab->getAttribs({vlanid=>"$vlan"},'net','mask'); - my $subnet; - my $netmask; - if ($sent and ($sent->{net})) { - $subnet=$sent->{net}; - $netmask=$sent->{mask}; - } - if (($subnet) && ($netmask)) { - my $hoststab = xCAT::Table->new("hosts", -create => 0); - if ($hoststab) { - my $tmp = $hoststab->getNodeAttribs($node, ['otherinterfaces'],prefetchcache=>1); - if (defined($tmp) && ($tmp) && $tmp->{otherinterfaces}) - { - my $otherinterfaces = $tmp->{otherinterfaces}; - my @itf_pairs=split(/,/, $otherinterfaces); - foreach (@itf_pairs) { - my ($name,$ip)=split(/:/, $_); - if(xCAT::NetworkUtils->ishostinsubnet($ip, $netmask, $subnet)) { - if ($name =~ /^-/ ) { - $name = $node.$name; - } - push @scriptd, "VLANHOSTNAME='" . $name . "'\n"; - push @scriptd, "export VLANHOSTNAME\n"; - push @scriptd, "VLANIP='" . $ip . "'\n"; - push @scriptd, "export VLANIP\n"; - push @scriptd, "VLANSUBNET='" . $subnet . "'\n"; - push @scriptd, "export VLANSUBNET\n"; - push @scriptd, "VLANNETMASK='" . $netmask . "'\n"; - push @scriptd, "export VLANNETMASK\n"; - last; - } - } - } - } - } - } - } + my $module_name="xCAT_plugin::vlan"; + my @tmp_scriptd=(); + eval("use $module_name;"); + if (!$@) { + no strict "refs"; + if (defined(${$module_name."::"}{getNodeVlanConfData})) { + @tmp_scriptd=${$module_name."::"}{getNodeVlanConfData}->($node); + } } + @scriptd=(@scriptd,@tmp_scriptd); + #print Dumper(@tmp_scriptd); #get monitoring server and other configuration data for monitoring setup on nodes