# Prompt => '/[^\s\(]+(\([^\(]\)){0,1}[#>]/');
if (!defined($ios)) {
print "Could not connect to $dip";
- return;
+ return 0;
}
$ios->login($nms::config::ios_user, $nms::config::ios_pass);
$ios->enable;
if (ios_getroute($ios, "192.168.1.0") == 1) {
print "Already routed up 192.168.1.0/24\n" ;
- return;
+ return 0;
}
my $zyxeloldip = "192.168.1.1";
print "Waiting for zyxel on $dip:$vlan timed out, wanted to set ip: $newip\n";
print LOG "Could not connect to $switchname\n";
stop_vlan($ios, $vlan);
- return;
+ return 0;
}
last if $p->ping($zyxeloldip);
print "pinging...\n";
$ios->close();
+ return 1;
}
## Collect switch ips
while (1) {
if ($counter > 4) {
print "No answer from $dip:$vlan $ip, trying to route it up\n";
- do_distro($dip, $ip, $vlan, $switch);
- my $pid = fork();
- if ($pid == 0) {
- sleep 100;
- system("perl ./ciscong2.pl $switch");
- exit 0;
+ my $ret = do_distro($dip, $ip, $vlan, $switch);
+ if ($ret == 0) {
+ # No answer from zyxel
+ last;
}
+ print "Waiting for telnet to time out so we can do run ciscong.pl\n";
+ sleep 100;
+ system("perl ./ciscong2.pl $switch");
last;
}
last if $p->ping($ip);