Skip to content

Commit

Permalink
Update main.py - fix Mod issues
Browse files Browse the repository at this point in the history
  • Loading branch information
knewell committed Mar 19, 2019
1 parent a799bfe commit 235e111
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ def __init__(self):

def addNewFlowRoute(self, flowRouteData=None):

if flowRouteData['vrf'] == 'default':
flowRouteData.pop('vrf', None)

env = Environment(autoescape=False,
loader=FileSystemLoader('./template'), trim_blocks=False, lstrip_blocks=False)
template = env.get_template('set-flow-route.conf')

if flowRouteData['vrf'] == 'default':
flowRouteData.pop('vrf', None)
#print template.render(flowRouteData)


my_router = None
for router in self.routers:

Expand Down Expand Up @@ -87,6 +88,14 @@ def addNewFlowRoute(self, flowRouteData=None):

def modFlowRoute(self, flowRouteData=None):

if flowRouteData['vrf'] == 'default':
flowRouteData.pop('vrf', None)

env = Environment(autoescape=False,
loader=FileSystemLoader('./template'), trim_blocks=False, lstrip_blocks=False)
template = env.get_template('mod-flow-route.conf')
print template.render(flowRouteData)

my_router = None
for router in self.routers:

Expand Down Expand Up @@ -399,18 +408,20 @@ def loadFlowRouteConfig(self):
return True, self.flow_config

else:
options = dev.rpc.get_config(options={'format': 'json'}, filter_xml='routing-options')
instances = dev.rpc.get_config(options={'format': 'json'}, filter_xml='routing-instances')

data = options['configuration']
data.update(instances['configuration'])

for vrf in self.vrfs:
family = ''
if vrf == 'default':
_vrf_data = data['routing-options']
try:
options = dev.rpc.get_config(options={'format': 'json'}, filter_xml='routing-options')
except IndexError as error:
print(error)
_vrf_data = options['configuration']['routing-options']
else:
for instance in data['routing-instances']['instance']:
try:
instances = dev.rpc.get_config(options={'format': 'json'}, filter_xml='routing-instances')
except IndexError as error:
print(error)
for instance in instances['configuration']['routing-instances']['instance']:
if instance['name'] == vrf:
_vrf_data = instance['routing-options']

Expand Down

0 comments on commit 235e111

Please sign in to comment.