refactor common parts into ZTE role
[APKPM.git] / lib / H1 / ZTEDSLAM.pm
1 package H1::ZTEDSLAM;
2 use warnings;
3 use strict;
4
5 use Moose;
6
7 with 'H1::ZTE';
8
9 use Data::Dump qw(dump);
10
11
12 sub login {
13         my ( $self, $t ) = @_;
14
15         $t->print("");
16         $t->waitfor('/Login:/');
17         $t->print('admin');
18         $t->waitfor('/Password:/');
19         $t->print('admin');
20         $t->waitfor('/>/');
21         $t->print('en');
22         $t->waitfor('/Please input password:/');
23         $t->print('admin');
24         $t->waitfor('/#/');
25
26         warn "login OK";
27 }
28
29
30 sub parse {
31         my ( $self, $out ) = @_;
32
33         my $hash;
34         foreach my $line ( split(/[\n\r]+/, $out) ) {
35                 warn "# $line\n" if $ENV{DEBUG};
36                 if ( $line =~ m/^(\S+.*?)\s+:\s+(\S+.*)$/ ) {
37                         my ($n,$v) = ($1,$2);
38                         $n =~ s/\(.+\)//;
39                         $hash->{$n} = $v;
40                         warn "## $n = $v\n" if $ENV{DEBUG};
41                 }
42
43         }
44
45         return $hash;
46 }
47
48 sub commands {{
49         'show interface ##' => [ qw(
50 AdminStatus
51 LinkStatus
52 LastLinkUpTime
53         )],
54         'show adsl status ##' => [ qw(
55 LineConfProfile
56         )],
57         'show adsl physical ##' => [ qw(
58 AtucCurrSnrMgn
59 AtucCurrAtn
60 AtucCurrStatus
61 AtucOutputPwr
62 AtucAttainableRate
63 AtucDMTState
64 AtucPrevSnrMgn
65 AturCurrAtn
66 AturCurrStatus
67 AturCurrOutputPwr
68 AturAttainableRate
69 AturDMTState
70         )],
71 }}
72
73 1;
74