1+ # Copyright (C) 2007-2010 Samuel Abels.
2+ #
3+ # This program is free software; you can redistribute it and/or modify
4+ # it under the terms of the GNU General Public License version 2, as
5+ # published by the Free Software Foundation.
6+ #
7+ # This program is distributed in the hope that it will be useful,
8+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+ # GNU General Public License for more details.
11+ #
12+ # You should have received a copy of the GNU General Public License
13+ # along with this program; if not, write to the Free Software
14+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15+ """
16+ A driver for devices running Ericsson's Broadband Access Nodes (BAN) OS
17+ """
18+ import re
19+ from Exscript .protocols .drivers .driver import Driver
20+
21+ _user_re = [re .compile (r'user:' , re .I )]
22+ _password_re = [re .compile (r'pass:' , re .I )]
23+ _prompt_re = [re .compile (r'[\r\n][\-\w+\.]+(?:\([^\)]+\))?% ?$|(?:\(y/n\)\[n\])' )]
24+ _error_re = [re .compile (r'\(error\)' )]
25+
26+ _ban_re = re .compile (r"BLM\d+ - Broadband Loop Multiplexer" , re .I )
27+
28+ _banner_re = re .compile (r"Last login" , re .I )
29+
30+ _login_fail_re = [r'Login failed' ]
31+
32+
33+ class EricssonBanDriver (Driver ):
34+ def __init__ (self ):
35+ Driver .__init__ (self , 'ericsson_ban' )
36+
37+ self .user_re = _user_re
38+ self .password_re = _password_re
39+ self .prompt_re = _prompt_re
40+ self .error_re = _error_re
41+ self .login_error_re = _login_fail_re
42+
43+ # def auto_authorize(self, conn, account, flush, bailout):
44+ # conn.send('enable\r\n')
45+ # conn.app_authorize(account, flush, bailout)
46+
47+ def check_head_for_os (self , string ):
48+ if _ban_re .search (string ):
49+ return 90
50+ return 0
51+
52+ def check_response_for_os (self , string ):
53+ if _banner_re .search (string ):
54+ return 20
55+ return 0
0 commit comments