Skip to content

Commit c549531

Browse files
committed
ficed merge conflicts
2 parents 3d88e0e + d5105be commit c549531

File tree

10 files changed

+134
-11
lines changed

10 files changed

+134
-11
lines changed

host_vars/cisco_ios-00.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,8 +2495,7 @@ vars:
24952495
start: 0
24962496
transport:
24972497
input:
2498-
protocols:
2499-
- ssh
2498+
protocols: ssh
25002499
5to15:
25012500
escape_character: BREAK
25022501
exec_timeout:
@@ -2510,8 +2509,7 @@ vars:
25102509
start: 5
25112510
transport:
25122511
input:
2513-
protocols:
2514-
- ssh
2512+
protocols: ssh
25152513
logging:
25162514
facility: local6
25172515
hosts:

parsers/cisco_ios/banners/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- name: banner
66
template: banners/default.j2
77
lines:
8-
- regex: '^banner (\w+) (.+)$'
8+
- regex: '^banner (\w+) (\^C|.+).*$'
99
exmaples:
1010
- 'banner exec ^C'
1111
captures:

parsers/cisco_ios/interface/main.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@
145145
"{{ name }}":
146146
switchport:
147147
mode: "{{ mode.split() }}"
148+
- regex: '^ switchport voice vlan (\d{1,4})$'
149+
examples:
150+
- ' switchport voice vlan 1200'
151+
captures:
152+
- vlan
153+
path:
154+
interfaces:
155+
"{{ name }}":
156+
switchport:
157+
voice:
158+
vlan: "{{ vlan }}"
159+
- regex: '^ power inline police$'
160+
examples:
161+
- ' power inline police'
162+
path:
163+
interfaces:
164+
"{{ name }}":
165+
power:
166+
inline: "police"
148167
- regex: '^ channel-group (\d{1,3}) mode (.*)$'
149168
examples:
150169
- ' channel-group 1 mode desirable'
@@ -206,6 +225,28 @@
206225
ip:
207226
helper_addresses:
208227
- ipv4_helper_address: "{{ ipv4_helper_address }}"
228+
- regex: '^ ip access-group (.+) (in|out)$'
229+
examples:
230+
- ' ip access-group 10 in'
231+
captures:
232+
- acl_id
233+
- direction
234+
path:
235+
interfaces:
236+
"{{ name }}":
237+
ip:
238+
access_group:
239+
- direction: "{{ direction }}"
240+
acl_id: "{{ acl_id }}"
241+
- regex: '^ no ip route-cache$'
242+
examples:
243+
- ' no ip route-cache'
244+
path:
245+
interfaces:
246+
"{{ name }}":
247+
ip:
248+
route_cache:
249+
negate: True
209250
- regex: '^ ip route-cache (\w+)$'
210251
examples:
211252
- ' ip route-cache policy'

parsers/cisco_ios/vlan/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,29 @@
1313
path:
1414
vlan:
1515
internal_allocation_policy: "{{ direction }}"
16+
- name: vlans
17+
template: vlan/vlan_list.j2
18+
lines:
19+
- regex: '^vlan (\d+)-?(\d+)?$'
20+
examples:
21+
- 'vlan 10'
22+
captures:
23+
- number
24+
- end_range
25+
path:
26+
vlan:
27+
vlan_list:
28+
"{{ number }}":
29+
number: "{{ number }}"
30+
end_range: "{{ end_range }}"
31+
lines:
32+
- regex: '^ name (\S+)$'
33+
examples:
34+
- ' name users'
35+
captures:
36+
- name
37+
path:
38+
vlan:
39+
vlan_list:
40+
"{{ number }}":
41+
name: "{{ name }}"

runparse.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ def get_configurations():
146146
device['working_configuration'] = device['configuration']
147147
devices.append(device)
148148
print_log('ok', 'ok')
149+
""" Create the host_vars automatically for each configuration loaded. Assumes Cisco IOS. """
150+
host_vars_path = 'host_vars/'+device_config.rstrip('.svn')+'.yml'
151+
host_vars_file_to_create = open(host_vars_path,'w')
152+
host_vars_file_to_create.write('os: cisco_ios')
149153
return devices
150154

151155
def ensure_host_vars(devices, src_dir):

templates/cisco_ios/interface/default.j2

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
{% if 'mode' in vars['interfaces'][interface]['switchport'] %}
4040
- " switchport mode {{ vars['interfaces'][interface]['switchport']['mode']|join(' ') }}"
4141
{% endif %} #mode
42+
{% if 'voice' in vars['interfaces'][interface]['switchport'] %}
43+
{% if 'vlan' in vars['interfaces'][interface]['switchport']['voice'] %}
44+
- " switchport voice vlan {{ vars['interfaces'][interface]['switchport']['voice']['vlan'] }}"
45+
{% endif %} #vlan
46+
{% endif %} #voice
4247
{% if 'negate' in vars['interfaces'][interface]['switchport'] and vars['interfaces'][interface]['switchport']['negate'] %}
4348
- " no switchport"
4449
{% endif %} #negate
@@ -89,7 +94,16 @@
8994
{% endfor %}
9095
{% endif %} #access_group
9196
{% if 'route_cache' in vars['interfaces'][interface]['ip'] %}
97+
{% if 'access_group' in vars['interfaces'][interface]['ip'] %}
98+
{% for access_group in vars['interfaces'][interface]['ip']['access_group'] %}
99+
- " ip access-group {{ access_group['acl_id'] }} {{ access_group['direction'] }}"
100+
{% endfor %}
101+
{% endif %} #access-group
102+
{% if 'negate' in vars['interfaces'][interface]['ip']['route_cache'] %}
103+
- " no ip route-cache"
104+
{% else %}
92105
- " ip route-cache {{ vars['interfaces'][interface]['ip']['route_cache'] }}"
106+
{% endif %} #route-cache-negate
93107
{% endif %} #route-cache
94108
{% if 'no_route_cache' in vars['interfaces'][interface]['ip'] %}
95109
- " no ip route-cache"
@@ -104,6 +118,13 @@
104118
{% if 'shutdown' in vars['interfaces'][interface] and vars['interfaces'][interface]['shutdown'] %}
105119
- " shutdown"
106120
{% endif %} #shutdown
121+
{% if 'power' in vars['interfaces'][interface] %}
122+
{% if 'inline' in vars['interfaces'][interface]['power'] %}
123+
{% if 'police' in vars['interfaces'][interface]['power']['inline'] %}
124+
- " power inline police"
125+
{% endif %} #police
126+
{% endif %} #inline
127+
{% endif %} #power
107128
{% if 'negotiation' in vars['interfaces'][interface] and vars['interfaces'][interface]['negotiation']['negate'] %}
108129
- " no negotiation {{ vars['interfaces'][interface]['negotiation']['type'] }}"
109130
{% endif %} #no negotiation
@@ -114,7 +135,7 @@
114135
- " ip pim {{ vars['interfaces'][interface]['ip']['pim']['mode'] }}"
115136
{% endif %} #pim mode
116137
{% if 'service_policies' in vars['interfaces'][interface] %}
117-
{% for service_policy in vars['interfaces'][interface]['service_policies'] %}
138+
{% for service_policy in vars['interfaces'][interface] %}
118139
- " service-policy {{ service_policy['direction'] }} {{ service_policy['name'] }}"
119140
{% endfor %} # helpers
120141
{% endif %} #helper_addresses

templates/cisco_ios/ip/name-server.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- parents:
2-
lines:
31
{% for name_server in vars['ip']['name-servers'] %}
2+
- parents:
43
- 'ip name-server {{ name_server['name_server'] }}'
4+
lines:
55
{% endfor %}

templates/cisco_ios/line/con_aux.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
- parents:
55
- line {{ vars['line'][entry]['type'] }} {{ vars['line'][entry]['numbers'][number]['number'] }}
66
lines:
7+
{% if 'logging_synchronous' in vars['line'][entry]['numbers'][number] %}
8+
- " logging synchronous"
9+
{% endif %}
710
{% if 'exec_timeout' in vars['line'][entry]['numbers'][number] %}
811
- " exec-timeout {{ vars['line'][entry]['numbers'][number]['exec_timeout']['minutes'] }} {{ vars['line'][entry]['numbers'][number]['exec_timeout']['seconds'] }}"
912
{% endif %}
1013
{% if 'password' in vars['line'][entry]['numbers'][number] %}
1114
- " password {{ vars['line'][entry]['numbers'][number]['password']['encryption_type'] }} {{ vars['line'][entry]['numbers'][number]['password']['password'] }}"
1215
{% endif %}
16+
{% if 'login' in vars['line'][entry]['numbers'][number] and 'local' in vars['line'][entry]['numbers'][number]['login'] %}
17+
- " login local"
18+
{% endif %}
1319
{% if 'login' in vars['line'][entry]['numbers'][number] and 'authentication' in vars['line'][entry]['numbers'][number]['login'] %}
1420
- " login authentication {{ vars['line'][entry]['numbers'][number]['login']['authentication'] }}"
1521
{% endif %}

templates/cisco_ios/line/vty.j2

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
- parents:
33
- line vty {{ vars['line']['vty'][num]['start'] }} {{ vars['line']['vty'][num]['finish'] }}
44
lines:
5+
{% if 'access_class' in vars['line']['vty'][num] %}
6+
- " access-class {{ vars['line']['vty'][num]['access_class']['acl_id'] }} {{ vars['line']['vty'][num]['access_class']['direction'] }}"
7+
{% endif %}
8+
{% if 'logging_synchronous' in vars['line']['vty'][num] %}
9+
- " logging synchronous"
10+
{% endif %}
11+
{% if 'login_local' in vars['line']['vty'][num] %}
12+
- " login local"
13+
{% endif %}
514
{% if 'exec_timeout' in vars['line']['vty'][num] %}
615
- " exec-timeout {{ vars['line']['vty'][num]['exec_timeout']['minutes'] }} {{ vars['line']['vty'][num]['exec_timeout']['seconds'] }}"
716
{% endif %}
@@ -12,9 +21,15 @@
1221
- " password {{ vars['line']['vty'][num]['password']['encryption_type'] }} {{ vars['line']['vty'][num]['password']['password'] }}"
1322
{% endif %}
1423
{% if 'transport' in vars['line']['vty'][num] %}
15-
{% for direction in vars['line']['vty'][num]['transport'] %}
16-
- " transport {{ direction }} {{ vars['line']['vty'][num]['transport'][direction]['protocols']|join(' ') }}"
17-
{% endfor %}
24+
{% if 'preferred' in vars['line']['vty'][num]['transport'] %}
25+
- " transport preferred {{ vars['line']['vty'][num]['transport']['preferred']['protocols'] }}"
26+
{% endif %}
27+
{% if 'input' in vars['line']['vty'][num]['transport'] %}
28+
- " transport input {{ vars['line']['vty'][num]['transport']['input']['protocols'] }}"
29+
{% endif %}
30+
{% if 'output' in vars['line']['vty'][num][transport] %}
31+
- " transport preferred {{ vars['line']['vty'][num][transport]['output']['protocols'] }}"
32+
{% endif %}
1833
{% endif %}
1934
{% if 'escape_character' in vars['line']['vty'][num] %}
2035
- " escape-character {{ vars['line']['vty'][num]['escape_character'] }}"

templates/cisco_ios/vlan/vlan_list.j2

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% for vlan in vars['vlan']['vlan_list']|sort %}
2+
- parents:
3+
{% if vars['vlan']['vlan_list'][vlan]['end_range'] != 0 %}
4+
- vlan {{ vlan }}-{{ vars['vlan']['vlan_list'][vlan]['end_range'] }}
5+
{% else %}
6+
- vlan {{ vlan }}
7+
{% endif %}
8+
lines:
9+
{% if 'name' in vars['vlan']['vlan_list'][vlan] %}
10+
- " name {{ vars['vlan']['vlan_list'][vlan]['name'] }}"
11+
{% endif %}
12+
{% endfor %}

0 commit comments

Comments
 (0)