Commit 8df8b297 authored by Mac Newbold's avatar Mac Newbold

Fixed some bugs. Can now run using "su1 ifc_<...> ..." from plastic.

parent 80bffc81
#!/usr/bin/perl #!/usr/bin/perl
my $rsh = "ssh";
if ( $#ARGV < 0) { if ( $#ARGV < 0) {
die("Usage: ifc_all <ifc_file>\n"); die("Usage: ifc_all <ifc_file>\n");
} }
...@@ -40,7 +43,7 @@ while (<IN>) { ...@@ -40,7 +43,7 @@ while (<IN>) {
do { } until ( <PING> =~ /transmitted, (\d*) packets received/ ); do { } until ( <PING> =~ /transmitted, (\d*) packets received/ );
print "Got $1 ping packet(s) back from $IP.\n"; print "Got $1 ping packet(s) back from $IP.\n";
if ( $1 > 0 ) { if ( $1 > 0 ) {
open(UNAME,"rsh $IP uname -a 2>&1 |"); open(UNAME,"$rsh $IP uname -a 2>&1 |");
$_ = <UNAME>; $_ = <UNAME>;
#print $_; #print $_;
if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; } if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; }
...@@ -61,7 +64,7 @@ while (<IN>) { ...@@ -61,7 +64,7 @@ while (<IN>) {
} }
print "Setting $IP $ifstr$IF to $newIP...\n"; print "Setting $IP $ifstr$IF to $newIP...\n";
open(IFC, open(IFC,
"rsh $IP /sbin/ifconfig $ifstr$IF inet $newIP ". "$rsh $IP /sbin/ifconfig $ifstr$IF inet $newIP ".
"netmask 255.255.255.0 2>&1 |" "netmask 255.255.255.0 2>&1 |"
); );
while ( <IFC> ) { while ( <IFC> ) {
......
#!/usr/bin/perl #!/usr/bin/perl
my $rsh = "ssh";
my $rcp = "scp";
if ( $#ARGV < 0) { if ( $#ARGV < 0) {
die("Usage: ifc_boot <ifc_file>\n". die("Usage: ifc_boot <ifc_file>\n".
"(Sets network configurations for booting)\n"); "(Sets network configurations for booting)\n");
...@@ -41,7 +45,7 @@ while (<IN>) { ...@@ -41,7 +45,7 @@ while (<IN>) {
do { } until ( <PING> =~ /transmitted, (\d*) packets received/ ); do { } until ( <PING> =~ /transmitted, (\d*) packets received/ );
print "Got $1 ping packet(s) back from $IP.\n"; print "Got $1 ping packet(s) back from $IP.\n";
if ( $1 > 0 ) { if ( $1 > 0 ) {
open(UNAME,"rsh $IP uname -a 2>&1 |"); open(UNAME,"$rsh $IP uname -a 2>&1 |");
$_ = <UNAME>; $_ = <UNAME>;
#print $_; #print $_;
if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; } if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; }
...@@ -81,8 +85,8 @@ while (<IN>) { ...@@ -81,8 +85,8 @@ while (<IN>) {
my $host = `uname -n`; my $host = `uname -n`;
$host =~ s/\n//; $host =~ s/\n//;
open(IFC, open(IFC,
"rsh $IP rcp $host:/tmp/ifc_boot_file ". "$rcp /tmp/ifc_boot_file ".
"/etc/sysconfig/network-scripts/ifcfg-$ifstr$IF |" "$IP:/etc/sysconfig/network-scripts/ifcfg-$ifstr$IF |"
); );
while ( <IFC> ) { while ( <IFC> ) {
print ">> $_"; print ">> $_";
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# Takes input IR file on STDIN, and dumps IFC file to STDOUT. # Takes input IR file on STDIN, and dumps IFC file to STDOUT.
# #
my $d = 0; #debug
my $go=0; my $go=0;
my $ipsection=0; my $ipsection=0;
my %ips = (); my %ips = ();
...@@ -11,29 +13,41 @@ my %nodeips = (); ...@@ -11,29 +13,41 @@ my %nodeips = ();
my %ifs = (); my %ifs = ();
while ( <> ) { while ( <> ) {
if ( /^start ip/i ) { $ipsection=1; } if ( /^start ip/i ) {
$ipsection=1;
print STDERR "Found IP section...\t" if $d;
}
elsif ( /^end ip/i ) { $ipsection=0; } elsif ( /^end ip/i ) { $ipsection=0; }
elsif ( /^start mac/i ) { $go=1; } elsif ( /^start mac/i ) {
$go=1;
print STDERR "Found MAC section:\n" if $d;
}
elsif ( /^end mac/i ) { $go=0; } elsif ( /^end mac/i ) { $go=0; }
elsif ( $go ) { elsif ( $go ) {
my ($mac,$ip) = split(); my ($mac,$ip) = split();
print STDERR "Read: $mac <==> $ip\n" if $d;
$ips{$mac} = $ip; $ips{$mac} = $ip;
} }
} }
print STDERR "Input done.\n" if $d;
my $path=""; my $path="";
if ( -x "/usr/testbed/bin/mac2if" ) { $path="/usr/testbed/bin/" } if ( -x "/usr/testbed/bin/mac2if" ) { $path="/usr/testbed/bin/" }
elsif ( -x "mac2if" ) { $path=""; } elsif ( -x "mac2if" ) { $path=""; }
elsif ( -x "./mac2if" ) { $path="./"; } elsif ( -x "./mac2if" ) { $path="./"; }
elsif ( -x "/home/newbold/db/mac2if" ) { $path="/home/newbold/db/"; } elsif ( -x "/home/newbold/db/mac2if" ) { $path="/home/newbold/db/"; }
open(MAC2IF,"$path"."mac2if ".join(" ",keys %ips)." |"); my $cmd = "$path"."mac2if ".join(" ",keys %ips)." |";
print STDERR "Calling $cmd\n" if $d;
open(MAC2IF,$cmd);
while ( <MAC2IF> ) { while ( <MAC2IF> ) {
if (! /^\|/ ) {next;} if (! /^\|/ ) {next;}
if ( /^\|node_id/ ) {next;} if ( /^\|node_id/ ) {next;}
s/ *|\t*//g; s/ *|\t*//g;
s/^\|//; s/^\|//;
my ($node,$ifc,$mac) = split(/\|/,$_); my ($node,$ifc,$mac) = split(/\|/,$_);
print STDERR "Read $node:$ifc <==> $mac\n" if $d;
$nodes{$mac} = $node; $nodes{$mac} = $node;
$ifs{$mac} = $ifc; $ifs{$mac} = $ifc;
} }
...@@ -43,7 +57,9 @@ elsif ( -x "nodeip" ) { $path=""; } ...@@ -43,7 +57,9 @@ elsif ( -x "nodeip" ) { $path=""; }
elsif ( -x "./nodeip" ) { $path="./"; } elsif ( -x "./nodeip" ) { $path="./"; }
elsif ( -x "/home/newbold/db/nodeip" ) { $path="/home/newbold/db/"; } elsif ( -x "/home/newbold/db/nodeip" ) { $path="/home/newbold/db/"; }
open(NODEIP,"$path"."nodeip ".join(" ",values %nodes)." |"); $cmd = "$path"."nodeip ".join(" ",values %nodes)." |";
print STDERR "Calling $cmd\n" if $d;
open(NODEIP,$cmd);
while ( <NODEIP> ) { while ( <NODEIP> ) {
if (! /^\|/ ) {next;} if (! /^\|/ ) {next;}
if ( /^\|node_id/ ) {next;} if ( /^\|node_id/ ) {next;}
...@@ -52,6 +68,7 @@ while ( <NODEIP> ) { ...@@ -52,6 +68,7 @@ while ( <NODEIP> ) {
my ($node,$ifc,$ip) = split(/\|/,$_); my ($node,$ifc,$ip) = split(/\|/,$_);
if ($node =~ /^tbpc/) { if ($ifc==4) { $nodeip{$node} = $ip; } } if ($node =~ /^tbpc/) { if ($ifc==4) { $nodeip{$node} = $ip; } }
else { if ($ifc==1) { $nodeip{$node} = $ip; } } else { if ($ifc==1) { $nodeip{$node} = $ip; } }
print STDERR "Read $node <==> $nodeip{$node}\n" if $d;
} }
print "# This ifc file generated by ir2ifc\n"; print "# This ifc file generated by ir2ifc\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment