-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtab_epg.py
More file actions
61 lines (45 loc) · 1.62 KB
/
tab_epg.py
File metadata and controls
61 lines (45 loc) · 1.62 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
50
51
52
53
54
55
56
57
58
59
60
# list of packages that should be imported for this code to work
import cobra.mit.access
import cobra.mit.request
import cobra.mit.session
import cobra.model.draw
import cobra.model.fv
import cobra.model.pol
import cobra.model.vz
from cobra.internal.codec.xmlcodec import toXMLStr
from tabulate import tabulate
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
def table(i):
# It's an EPG traffic statistics tabulate script
# log into an APIC and create a directory object
ls = cobra.mit.session.LoginSession('https://10.75.53.131', 'admin', 'Nbv!2345')
md = cobra.mit.access.MoDirectory(ls)
md.login()
fvAEPgCls = cobra.mit.access.ClassQuery('fvAEPg')
fvAEPgClsObjs = md.query(fvAEPgCls)
TableEntry = []
for mo in fvAEPgClsObjs:
# if int(mo.dropPkt) !=0:
row = {
"EPG":mo.name,
# "UnicastRate":mo.unicastRate,
# "DropPacketsPercentage":mo.dropPktPercentage,
# "ExcessPakets":mo.excessPkt,
# "ExcessPaketsPercentage":mo.excessPktPercentage,
# "TransceivePakets":mo.txPkt,
# "ReceivePakets":mo.rxPkt,
# "MulticastRate":mo.multicastRate,
# "TotalDropPacketsPercentage":mo.totDropPktPercentage,
}
TableEntry.append(row)
print tabulate(sorted(TableEntry,),tablefmt='grid',headers="keys")
return
def main():
for i in range (1,2):
# if i <= 2:
# time.sleep(5)
# y = i + 1
table(i)
if __name__ == '__main__':
main()