-
Notifications
You must be signed in to change notification settings - Fork 9
/
fhtli1.py
62 lines (46 loc) · 978 Bytes
/
fhtli1.py
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
50
51
52
53
54
55
56
57
#!/usr/bin/python
# Jorge Luiz Taioque
# jorgeluiztaioque at gmail dot com
#
# Usege fhtl1.py [ip_tl1_server] [ip_olt] [pon_port]
# use last two numbers of pon port link 1-1
#
#
import time
import sys
from socket import *
tl1host = sys.argv[1]
tl1port = 3337
oltip = sys.argv[2]
oltport = 'NA-NA-'+sys.argv[3]
name = []
onuid = []
#connecting socket on TL1 service
s = socket(AF_INET, SOCK_STREAM)
s.connect((tl1host, tl1port))
s.send('LOGIN:::CTAG::UN=1,PWD=1;')
time.sleep(2)
def logout ():
s.send('LOGOUT:::CTAG::;')
time.sleep(2)
s.close()
return
def getonus ():
s.send('LST-ONU::OLTID='+oltip+',PONID='+oltport+':CTAG::;')
time.sleep(2)
data = s.recv(80000)
return data
def getonuid ():
data = getonus()
for line in data.splitlines():
fields = line.split()
if len(fields) >= 11:
name.append(fields[3:6])
onuid.append(fields[10])
return name, onuid
def showonus ():
data = getonus()
logout();
print data
return data
showonus()