From f75dda0e205df5dd2a4a608e8713097541318c12 Mon Sep 17 00:00:00 2001 From: cjhardee Date: Tue, 30 Nov 2010 20:19:52 +0000 Subject: [PATCH] updated rspconfig to allow for the swnet to be specified, rather than always running on switch[1] git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8288 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/blade.pm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 5c9294d21..1b3b34305 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -3541,7 +3541,9 @@ sub telnetcmds { next; } my ($command,$value) = split /=/,$cmd; - if (grep(/^$command$/,@tcmds)) { + + #$command =~ /^swnet/) allows for swnet1, swnet2, etc. + if (grep(/^$command$/,@tcmds) || $command =~ /^swnet/) { $handled{$command} = $value; next; } @@ -3584,7 +3586,7 @@ sub telnetcmds { if (/^snmpcfg/) { $result = snmpcfg($t,$handled{$_},$user,$pass,$mm); } elsif (/^sshcfg$/) { $result = sshcfg($t,$handled{$_},$user,$mm); } elsif (/^network$/) { $result = network($t,$handled{$_},$mpa,$mm); } - elsif (/^swnet$/) { $result = swnet($t,$handled{$_}); } + elsif (/^swnet/) { $result = swnet($t,$_,$handled{$_}); } elsif (/^pd1|pd2$/) { $result = pd($t,$_,$handled{$_}); } elsif (/^textid$/) { $result = mmtextid($t,$mpa,$handled{$_},$mm); } elsif (/^network_reset$/) { $result = network($t,$handled{$_},$mpa,$mm,1); } @@ -3710,12 +3712,21 @@ sub network { sub swnet { my $t = shift; + my $command = shift; my $value = shift; my @result; my ($ip,$gateway,$mask); + #default is switch[1]. if the user specificed a number, use it instead + my $switch = "switch[1]"; + if ($command !~ /^swnet$/) { + my $switchNum = $command; + $switchNum =~ s/swnet//; + $switch = "switch[$switchNum]"; + } + if (!$value) { - my @data = $t->cmd("ifconfig -T system::switch[1]"); + my @data = $t->cmd("ifconfig -T system::$switch"); my $s = join('',@data); if ($s =~ /-i\s+(\S+)/) { $ip = $1; } if ($s =~ /-g\s+(\S+)/) { $gateway = $1; } @@ -3723,7 +3734,7 @@ sub swnet { } else { my $cmd = - "ifconfig -em disabled -ep enabled -pip enabled -T system:switch[1]"; + "ifconfig -em disabled -ep enabled -pip enabled -T system:$switch"; ($ip,$gateway,$mask) = split /,/,$value; if (!$ip and !$gateway and !$mask) {