Skip to content

Commit

Permalink
- update add/mod/del
Browse files Browse the repository at this point in the history
  • Loading branch information
cklewar committed Apr 10, 2018
1 parent 934b08c commit 688bef9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
32 changes: 25 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#


import os.path
import os
import cherrypy
import hashlib
import datetime
Expand Down Expand Up @@ -49,7 +49,14 @@ def addNewFlowRoute(self, flowRouteData=None):
# loader=FileSystemLoader('./template'), trim_blocks=False, lstrip_blocks=False)
#template = env.get_template('set-flow-route.conf')

with Device(host=self.routers[0]['rt1']['ip'], user=self.dev_user, password=self.dev_pw) as dev:
my_router = None
for router in self.routers:

for name, value in router.iteritems():
if 'rr' in value['type']:
my_router = [value['ip']]

with Device(host=my_router[0], user=self.dev_user, password=self.dev_pw) as dev:

try:

Expand All @@ -73,7 +80,14 @@ def addNewFlowRoute(self, flowRouteData=None):

def modFlowRoute(self, flowRouteData=None):

with Device(host=self.routers[0]['rt1']['ip'], user=self.dev_user, password=self.dev_pw) as dev:
my_router = None
for router in self.routers:

for name, value in router.iteritems():
if 'rr' in value['type']:
my_router = [value['ip']]

with Device(host=my_router[0], user=self.dev_user, password=self.dev_pw) as dev:
cu = Config(dev)
cu.lock()
cu.load(template_path='template/mod-flow-route.conf', template_vars=flowRouteData)
Expand All @@ -89,7 +103,14 @@ def modFlowRoute(self, flowRouteData=None):

def delFlowRoute(self, flowRouteData=None):

with Device(host=self.routers[0]['rt1']['ip'], user=self.dev_user, password=self.dev_pw) as dev:
my_router = None
for router in self.routers:

for name, value in router.iteritems():
if 'rr' in value['type']:
my_router = [value['ip']]

with Device(host=my_router[0], user=self.dev_user, password=self.dev_pw) as dev:

try:

Expand Down Expand Up @@ -278,7 +299,6 @@ def loadFlowRouteConfig(self):
for child in item.iterchildren():

for value in child.iter():
print value.tag, value.text
_action[child.tag] = {'value': value.text}

self.flow_config[my_list[0]]['action'] = _action
Expand All @@ -301,8 +321,6 @@ def loadFlowRouteConfig(self):
else:
_action[key] = {'value': None}

print route

self.flow_config[route['name']] = {'dstPrefix': route['match']['destination'] if 'destination' in route['match'] else '*',
'srcPrefix': route['match']['source'] if 'source' in route['match'] else '*',
'protocol': route['match']['protocol'] if 'protocol' in route['match'] else '*',
Expand Down
4 changes: 2 additions & 2 deletions ui/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ age_out_interval: 00:03:00
dev_pw: juniper123
dev_user: root
routers:
- rt1:
- RR:
type: rr
ip: 10.11.111.120
- rt2:
- PE:
type: asbr
ip: 10.11.111.121
2 changes: 0 additions & 2 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ $(document).ready(function () {

if (data.age <= ageOutInterval) {
$(row).css( 'color', 'red' ).animate( { color: 'black' });


}
},
"columns": [
Expand Down

0 comments on commit 688bef9

Please sign in to comment.