-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.web.ajOnuMenu(Bdcom_GP36)_toggle.pl
More file actions
50 lines (47 loc) · 1.81 KB
/
patch.web.ajOnuMenu(Bdcom_GP36)_toggle.pl
File metadata and controls
50 lines (47 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'menu_settings', after=>['Ponmon']
push @menuItems, { order => 21, title => L('Вкл/Викл ONU'), act=>'toggleOnuBdcom_GP3600' } if lc($p{vendor}) =~ 'bdcom' && lc($p{model}) =~ 'gp3600';
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'subs', after=>['Ponmon']
sub act_toggleOnuBdcom_GP3600 {
# 2024.08.31
# https://t.me/MrMethod
my $attr = shift;
return $ajax_url->a($lang::btn_Execute, act=>'toggleOnuBdcom_GP3600', go=>1) unless ses::input_int('go');
my $tc = _telnetConnect($attr);
my $res = '';
#my @output = (_tnCmd($tc, "show gpon onu by sn $attr->{sn}"));
my $addr = $attr->{name};
$addr =~ s/[A-Za-z]//mgi;
my @output = (_tnCmd($tc, "?"));
debug $tc->last_prompt();
if ($tc->last_prompt() =~ /\#\s*/) {
my $isOnuCmd = "show gpon interface GPON $addr onu port 1 state";
@output = (_tnCmd($tc, $isOnuCmd));
debug 'pre', \@output;
my $onu_enabled = 0;
foreach my $ln (@output) {
chomp($ln);
next if $ln !~ /$addr|error/i;
next if $ln =~ /$isOnuCmd/i;
$ln =~ s/^\s*//mg;
my @elms = split /\s+/, $ln;
$onu_enabled = 1 if $elms[-1] =~ /up/i;
debug "enabled: $onu_enabled";
}
_tnCmd($tc, "config");
if ($tc->last_prompt() =~ /config/) {
_tnCmd($tc, "interface GPON $addr");
if ($tc->last_prompt() =~ $addr) {
my $cmd = $onu_enabled ? "gpon onu disable" : "NO gpon onu disable";
_tnCmd($tc, $cmd);
} else {
$res = "Can`t open interface GPON $addr";
}
} else {
$res = "Can`t enter CONFIG mode";
}
} else {
$res = "error prompt";
}
_telnetClose($tc);
return $res;
}