From 0e28da180f1042c1b799e07a45e6f460cd2cb131 Mon Sep 17 00:00:00 2001 From: cklewar Date: Tue, 10 Apr 2018 14:23:53 +0200 Subject: [PATCH] - update mod template --- template/mod-flow-route.conf | 2 ++ ui/config.yml | 2 ++ utils/testdata.py | 8 ++------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/template/mod-flow-route.conf b/template/mod-flow-route.conf index bc1c7d2..53088d1 100644 --- a/template/mod-flow-route.conf +++ b/template/mod-flow-route.conf @@ -3,7 +3,9 @@ routing-options { route {{ flowRouteName }} { replace: match { + {%- if dstPrefix is defined and dstPrefix !=None %} destination {{dstPrefix}}; + {%- endif %} {%- if dstPort is defined and dstPort !=None %} destination-port {{ dstPort }}; {%- endif %} diff --git a/ui/config.yml b/ui/config.yml index 38ffe45..0a6b0e5 100644 --- a/ui/config.yml +++ b/ui/config.yml @@ -1,6 +1,8 @@ age_out_interval: 00:03:00 dev_pw: juniper123 dev_user: root +communities: + - bgp_flow_arbor:1000:1666 routers: - RR: type: rr diff --git a/utils/testdata.py b/utils/testdata.py index f333d14..84a6be6 100644 --- a/utils/testdata.py +++ b/utils/testdata.py @@ -18,6 +18,7 @@ dev_user = config['dev_user'] dev_pw = config['dev_pw'] routers = config['routers'] + communities = config['communities'] my_router = None for router in routers: @@ -34,7 +35,6 @@ step = 1 protocol = ['tcp', 'udp'] action = ['accept', 'discard', 'sample', 'community'] - communities = ['bgp_flow_arbor:1000:1666'] for idx in range(start, stop, step): testdata['flowRoute' + str(idx)] = { @@ -44,11 +44,9 @@ random.randint(1, 200)), 'protocol': protocol[random.randint(0, 1)], 'dstPort': '{0}'.format(random.randint(1, 9999)), 'srcPort': '{0}'.format(random.randint(1, 9999)), - 'action': '{0} {1}'.format(action[3],communities[0]) if 'community' in action[ + 'action': '{0} {1}'.format(action[3],communities[random.randint(0, len(communities)-1)]) if 'community' in action[ random.randint(0, 3)] else action[random.randint(0, 2)]} - #pprint.pprint(testdata) - env = Environment(autoescape=False, loader=FileSystemLoader('../template'), trim_blocks=False, lstrip_blocks=False) template = env.get_template('set-flow-route.conf') @@ -58,8 +56,6 @@ for key, flow in testdata.iteritems(): _template.write(template.render(flowRouteName=key, **flow)) - #print _template.getvalue() - try: cu = Config(dev)