-
Notifications
You must be signed in to change notification settings - Fork 0
/
monkey-skel.py
66 lines (52 loc) · 1.72 KB
/
monkey-skel.py
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
61
62
63
64
65
66
#/usr/bin/env python3
import copy
from jinja2 import Environment, FileSystemLoader, Template
env = Environment(loader=FileSystemLoader('templates/'))
#env = Environment()
node_template = env.get_template('monkey.j2')
output_template = env.get_template('output-templates/dokuwiki.j2')
mask16 = '255.255.0.0'
mask24 = '255.255.255.0'
mask32 = '255.255.255.255'
number_of_routers = 7
number_of_loopback_interfaces = 0
number_of_gigabit_ethernet_interfaces = 0
general_count = 7
# render_params = copy.deepcopy(params)
loBase = 1
gigBase = 0
render_params = {
'nodes': [],
}
i = 1
for node in range(number_of_routers):
node = {}
render_params['nodes'].append(node)
node['hostname'] = 'R%d' % i
node['router_id'] = '%d.%d.%d.%d' % (i, i, i, i)
#node['interfaces'] = []
node['pings'] = []
interfaceIndex = 0
# for loIndex in range(number_of_loopback_interfaces):
# node['interfaces'].append({
# 'name': 'Loopback %d' % (loBase + loIndex),
# 'address': '100.10.%d.0' % (loBase + loIndex),
# 'mask': mask24,
# })
# for gigIndex in range(number_of_gigabit_ethernet_interfaces):
# node['interfaces'].append({
# 'name': 'GigabitEthernet 0/%d' % (gigBase + gigIndex),
# 'address': '0.0.0.0',
# 'mask': mask24,
# })
for genralIdx in range(general_count):
octet = 1 + genralIdx
node['pings'].append({
'address': '%d.%d.%d.%d' % (octet, octet, octet, octet),
})
i += 1
output_render_data = copy.deepcopy(render_params)
#{**x, **y}
for node in output_render_data['nodes']:
node['config'] = node_template.render(node)
print(output_template.render(output_render_data))