multi vlan support
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@13623 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
d14d92acf0
commit
901e60d507
@ -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/;
|
||||
@ -174,11 +181,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;
|
||||
}
|
||||
}
|
||||
@ -313,11 +328,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};
|
||||
|
@ -372,77 +372,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $module_name="xCAT_plugin::vlan";
|
||||
eval("use $module_name;");
|
||||
if (!$@) {
|
||||
no strict "refs";
|
||||
if (defined(${$module_name."::"}{getNodeVlanConfData})) {
|
||||
my @tmp_scriptd=${$module_name."::"}{getNodeVlanConfData}->($node);
|
||||
#print Dumper(@tmp_scriptd);
|
||||
if (@tmp_scriptd > 0) {
|
||||
@scriptd=(@scriptd,@tmp_scriptd);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -997,8 +997,10 @@ sub xhrm_satisfy {
|
||||
my $vlanip;
|
||||
my $netmask;
|
||||
my $subnet;
|
||||
my $vlan;
|
||||
my $interface;
|
||||
if ($nic =~ /^vl([\d]+)$/) {
|
||||
my $vlan=$1;
|
||||
$vlan=$1;
|
||||
my $nwtab=xCAT::Table->new("networks", -create =>0);
|
||||
if ($nwtab) {
|
||||
my $sent = $nwtab->getAttribs({vlanid=>"$vlan"},'net','mask');
|
||||
@ -1026,9 +1028,38 @@ sub xhrm_satisfy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#get the nic that vlan tagged
|
||||
my $swtab = xCAT::Table->new("switch", -create => 0);
|
||||
if ($swtab) {
|
||||
my $tmp_switch = $swtab->getNodesAttribs([$hyp], ['vlan','interface']);
|
||||
if (defined($tmp_switch) && (exists($tmp_switch->{$hyp}))) {
|
||||
my $tmp_node_array=$tmp_switch->{$hyp};
|
||||
foreach my $tmp (@$tmp_node_array) {
|
||||
if (exists($tmp->{vlan})) {
|
||||
my $vlans = $tmp->{vlan};
|
||||
foreach my $vlan_tmp (split(',',$vlans)) {
|
||||
if ($vlan_tmp == $vlan) {
|
||||
if (exists($tmp->{interface})) {
|
||||
$interface=$tmp->{interface};
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print "nic=$nic\n";
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $nic $vlanip $netmask");
|
||||
if (($interface) || ($interface =~ /primary/)) {
|
||||
$interface =~ s/primary(:)?//g;
|
||||
}
|
||||
#print "interface=$interface nic=$nic vlanip=$vlanip netmask=$netmask\n";
|
||||
if ($interface) {
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $interface:$nic $vlanip $netmask");
|
||||
} else {
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $nic $vlanip $netmask");
|
||||
}
|
||||
|
||||
#TODO: surprise! there is relatively undocumented libvirt capability for this...
|
||||
#./tests/interfaceschemadata/ will have to do in lieu of documentation..
|
||||
|
Loading…
Reference in New Issue
Block a user