Skip to content

Commit

Permalink
Update main.py - revert port to 8080. VRF
Browse files Browse the repository at this point in the history
  reporting is standardized - VRFname (v#)
Update ui/index.html
  • Loading branch information
knewell committed Mar 18, 2019
1 parent e5ca08b commit ad3d0e0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
48 changes: 43 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self):
self.flow_config = dict()
self.filter_active = dict()
self.routers = list()
self.vrfs = list()

def addNewFlowRoute(self, flowRouteData=None):

Expand Down Expand Up @@ -152,9 +153,32 @@ def getActiveFlowRoutes(self):

# data = dev.rpc.get_config(filter_xml='routing-options/flow/route/name')
frt = FlowRoutesTable(dev)
for flowtable in ['inetflow.0', 'inet6flow.0', 'trcps.inetflow.0', 'trcps.inet6flow.0']:
flowtables = list()
for vrf in self.vrfs:
if vrf == 'default':
flowtables.extend(['inetflow.0', 'inet6flow.0'])
else:
flowtables.extend(['{}.inetflow.0'.format(vrf), '{}.inet6flow.0'.format(vrf)])
# for flowtable in ['inetflow.0', 'inet6flow.0', 'trcps.inetflow.0', 'trcps.inet6flow.0']:
for flowtable in flowtables:
frt.get(table=flowtable)

_flowtable = flowtable.split('.')
_vrf = ['','']
if len(_flowtable) == 2:
_vrf[0] = 'default'
if _flowtable[0] == 'inetflow':
_vrf[1] = 'v4'
if _flowtable[0] == 'inet6flow':
_vrf[1] = 'v6'
if len(_flowtable) > 2:
_vrf[0] = _flowtable[0]
if _flowtable[1] == 'inetflow':
_vrf[1] = 'v4'
if _flowtable[1] == 'inet6flow':
_vrf[1] = 'v6'
vrf = '{} ({})'.format(_vrf[0], _vrf[1])

for flow in frt:

destination = flow.destination.split(',')
Expand Down Expand Up @@ -223,7 +247,7 @@ def getActiveFlowRoutes(self):

if hex_dig not in self.flow_active:

self.flow_active[hex_dig] = {'router': name, 'vrf': flowtable, 'term': flow.term, 'destination': destination,
self.flow_active[hex_dig] = {'router': name, 'vrf': vrf, 'term': flow.term, 'destination': destination,
'commAction': commAction, 'krtAction': krt_actions,
'age': str(_age['current']),
'hash': hex_dig, 'status': 'new'}
Expand Down Expand Up @@ -262,7 +286,13 @@ def getActiveFlowRouteFilter(self):
with Device(host=value['ip'], user=self.dev_user, password=self.dev_pw) as dev:

frft = FlowFilterTable(dev)
for table in ['__flowspec_default_inet__', '__flowspec_default_inet6__', '__flowspec_trcps_inet__', '__flowspec_trcps_inet6__']:
flowfilters = list()
for vrf in self.vrfs:
flowfilters.extend(['__flowspec_{}_inet__'.format(vrf), '__flowspec_{}_inet6__'.format(vrf)])

for table in flowfilters:
# for table in ['__flowspec_default_inet__', '__flowspec_default_inet6__', '__flowspec_trcps_inet__', '__flowspec_trcps_inet6__']:

frft.get(filtername=table)

for filter in frft:
Expand All @@ -273,7 +303,14 @@ def getActiveFlowRouteFilter(self):
_item = item.split('=')
data[didx] = _item[1] if len(_item) > 1 else _item[0]

self.filter_active[name].append({'vrf': table, 'data': data, 'packet_count': filter.packet_count,
_vrf = table.split('_')
if _vrf[4] == 'inet':
_vrf[4] = 'v4'
if _vrf[4] == 'inet6':
_vrf[4] = 'v6'
vrf = '{} ({})'.format(_vrf[3], _vrf[4])

self.filter_active[name].append({'vrf': vrf, 'data': data, 'packet_count': filter.packet_count,
'byte_count': filter.byte_count})

return True, self.filter_active
Expand Down Expand Up @@ -403,6 +440,7 @@ def load_settings(self):
self.dev_pw = config['dev_pw']
self.age_out_interval = config['age_out_interval']
self.routers = config['routers']
self.vrfs = config['vrfs']


class BGPFlow(object):
Expand Down Expand Up @@ -536,6 +574,6 @@ def POST(self):
webapp.api.frft = Frft(my_dev=my_dev)
cherrypy.config.update({'log.screen': True,
'server.socket_host': '0.0.0.0',
'server.socket_port': 8088,
'server.socket_port': 8080,
})
cherrypy.quickstart(webapp, '/', conf)
2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2 style="text-align:right;float:right;" class="mainheader">Monitoring BGP Flow
<table id="t_active_filter" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Router</th>
<th>VRF</th>
<th>Destination Prefix</th>
<th>Source Prefix</th>
Expand Down

0 comments on commit ad3d0e0

Please sign in to comment.