|
|
@@ -18,21 +18,10 @@ sub bdcom_extract_onu_info {
|
|
|
return map([substr($_, 0, 11), split(' ', substr($_, 11, -1))], @lines[3..@lines-3]);
|
|
|
}
|
|
|
|
|
|
-sub bdcom_login {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-async bdcom_inspect => sub
|
|
|
-{
|
|
|
- my $ip = shift;
|
|
|
- my $login = shift;
|
|
|
+async bdcom_login => sub {
|
|
|
+ my $t = shift;
|
|
|
+ my $login = shift;
|
|
|
my $password = shift;
|
|
|
- my $tree = shift;
|
|
|
-
|
|
|
- ############################
|
|
|
-
|
|
|
- my $t = new telnet($ip);
|
|
|
-# $t->debug(1);
|
|
|
|
|
|
await $t->connect;
|
|
|
|
|
|
@@ -62,6 +51,21 @@ async bdcom_inspect => sub
|
|
|
await $t->cmd("terminal length 0");
|
|
|
await $t->cmd("terminal width 200");
|
|
|
|
|
|
+};
|
|
|
+
|
|
|
+async bdcom_inspect => sub
|
|
|
+{
|
|
|
+ my $ip = shift;
|
|
|
+ my $login = shift;
|
|
|
+ my $password = shift;
|
|
|
+ my $tree = shift;
|
|
|
+
|
|
|
+ ############################
|
|
|
+
|
|
|
+ my $t = new telnet($ip);
|
|
|
+# $t->debug(1);
|
|
|
+ await bdcom_login($t, $login, $password);
|
|
|
+
|
|
|
#######################
|
|
|
|
|
|
my @inactive_onu = await $t->cmd("show epon inactive-onu interface ePON 0/$tree");
|
|
|
@@ -116,33 +120,7 @@ async bdcom_onu => sub
|
|
|
my $t = new telnet($ip);
|
|
|
# $t->debug(1);
|
|
|
|
|
|
- await $t->connect;
|
|
|
-
|
|
|
- await $t->reply(qr/Username:/, $login);
|
|
|
- await $t->reply(qr/Password:/, $password);
|
|
|
-
|
|
|
- my @greeting = await $t->waitfor(qr/>/);
|
|
|
- my $version = "C";
|
|
|
-
|
|
|
- for (@greeting)
|
|
|
- {
|
|
|
- $version = $1 if /Welcome to BDCOM P3310(\w)/;
|
|
|
- }
|
|
|
-
|
|
|
- $t->print("enable");
|
|
|
-
|
|
|
- my @next = await $t->waitfor(qr/#|password:/);
|
|
|
-
|
|
|
- if (grep {$_ =~ /password:/} @next)
|
|
|
- {
|
|
|
- $t->print($password);
|
|
|
- await $t->waitfor(qr/#/);
|
|
|
- }
|
|
|
-
|
|
|
- $t->prompt(qr/#/);
|
|
|
-
|
|
|
- await $t->cmd("terminal length 0");
|
|
|
- await $t->cmd("terminal width 200");
|
|
|
+ await bdcom_login($t, $login, $password);
|
|
|
|
|
|
#######################
|
|
|
my @inactive_onu = await $t->cmd("show epon inactive-onu interface ePON 0/$tree");
|
|
|
@@ -186,33 +164,7 @@ async bdcom_purge => sub
|
|
|
my $t = new telnet($ip);
|
|
|
# $t->debug(1);
|
|
|
|
|
|
- await $t->connect;
|
|
|
-
|
|
|
- await $t->reply(qr/Username:/, $login);
|
|
|
- await $t->reply(qr/Password:/, $password);
|
|
|
-
|
|
|
- my @greeting = await $t->waitfor(qr/>/);
|
|
|
- my $version = "C";
|
|
|
-
|
|
|
- for (@greeting)
|
|
|
- {
|
|
|
- $version = $1 if /Welcome to BDCOM P3310(\w)/;
|
|
|
- }
|
|
|
-
|
|
|
- $t->print("enable");
|
|
|
-
|
|
|
- my @next = await $t->waitfor(qr/#|password:/);
|
|
|
-
|
|
|
- if (grep {$_ =~ /password:/} @next)
|
|
|
- {
|
|
|
- $t->print($password);
|
|
|
- await $t->waitfor(qr/#/);
|
|
|
- }
|
|
|
-
|
|
|
- $t->prompt(qr/#/);
|
|
|
-
|
|
|
- await $t->cmd("terminal length 0");
|
|
|
- await $t->cmd("terminal width 200");
|
|
|
+ await bdcom_login($t, $login, $password);
|
|
|
|
|
|
#######################
|
|
|
|