-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_ops_conf.py
251 lines (220 loc) · 8.23 KB
/
template_ops_conf.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
try:
from junos import Junos_Context
PATH = '/var/db/scripts/op/'
except:
from os import getcwd
PATH = getcwd() + '/'
SSH_KEY = PATH + 'id_rsa'
REMOVE_DEL_CMDS_DURING_PUSH_DIFF_ERR_ENABLE = 1
TEMPLATE_EXEC_ENABLE = 1
TEMPLATE_SEARCH_PATH = PATH + 'xtemplate'
# maximum devices for multi-threaded profile operation
MAX_PROFILE_DEV = 16
COMMIT_TIMEOUT = 30
SAVE_COMMIT_J2_ENABLE = 1
SAVE_COMMIT_CFG_ENABLE = 1
SAVE_EXEC_J2_ENABLE = 1
SAVE_EXEC_PY_ENABLE = 1
SAVE_PATH_COMMIT_J2 = PATH + 'xarchive'
SAVE_PATH_COMMIT_CFG = PATH + 'xarchive'
SAVE_PATH_EXEC_J2 = PATH + 'xarchive'
SAVE_PATH_EXEC_PY = PATH + 'xarchive'
# groups
vsrx = { 'vsrx-01':{}, 'vsrx-02':{}, 'vsrx-03':{}, 'vsrx-04':{}, }
push_profiles = {
'add_srx_1': { 'comment':['add MX/SRX config 1'] },
'add_srx_2': { 'comment':['add MX/SRX config 2'] },
'add_srx_3': { 'comment':['add MX/SRX config 3'] },
'add_srx_4': { 'comment':['add MX/SRX config 4'] },
'del_srx_1': { 'comment':['del MX/SRX config 1'] },
'del_srx_2': { 'comment':['del MX/SRX config 2'] },
'del_srx_3': { 'comment':['del MX/SRX config 3'] },
'del_srx_4': { 'comment':['del MX/SRX config 4'] },
'update_srx_all':{ 'comment':['update srx config all'] },
'sessions': { 'comment':['retrieve sessions for specific source IP'] },
'pl_1_add_json': { 'comment':['loads prefix list pl-1 into eph instance pl, json fmt'] },
'pl_1_add_set': { 'comment':['loads prefix list pl-1 into eph instance pl, set fmt'] },
'pl_1_del': { 'comment':['empty prefix list pl-1 in ephemeral instance pl'] },
'filter': { 'comment':['displays counters from FF counters'] },
'version': { 'comment':['show Junos versions'] },
'mx_local': { 'comment':['show Junos versions, mx local'] },
'alarm': { 'comment':['show system alarms'] },
'shutdown': { 'comment':['shutdown all'] },
'bgp': { 'comment':['show bgp peers'] },
'load': { 'comment':['collect load data'] },
'mp_load_sum': { 'comment':['aggregate load data'] },
}
multi_profiles = {
"sessions": {
"comment": ["retrieve session info"],
"push_profiles": [
{"sessions": {}},
{"mp_sessions_sum": {"post-delay": 2, "pre-delay": 0}},
],
},
"status": {
"comment": ["alarm and version info"],
"push_profiles": [{"version": {"pre-delay": 1}}, {"alarm": {}}],
},
"add_srx_all": {
"comment": ["add all srx and mx"],
"push_profiles": [
{"add_srx_1": {"post-delay": 2}},
{"add_srx_2": {"post-delay": 2}},
{"add_srx_3": {"post-delay": 2}},
{"add_srx_4": {"post-delay": 2}},
{"bgp": {"pre-delay":10}},
{"sessions": {}},
{"mp_sessions_sum": {}},
],
},
"del_srx_all": {
"comment": ["del all srx and mx"],
"push_profiles": [
{"del_srx_1": {}},
{"del_srx_2": {}},
{"del_srx_3": {}},
{"del_srx_4": {}},
{"bgp": {}},
],
},
"load": {
"comment": ["show SRX load summary"],
"push_profiles": [
{"load": {}},
{"mp_load_sum": {}},
],
},
}
auth_profiles = {
'default':{ 'user':['template-ops'], 'port':[830], 'ssh_key':[SSH_KEY] },
'vmx-01':{ 'host':['10.0.0.10'],},
'vsrx-01':{ 'host':['10.0.0.11'] },
'vsrx-02':{ 'host':['10.0.0.12'] },
'vsrx-03':{ 'host':['10.0.0.13'] },
'vsrx-04':{ 'host':['10.0.0.14'] },
}
sessions = {
'default':{ 'template_vars':['exec1'], 'template':['sessions'], 'input':['0/0'], 'exec':[True] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
mp_sessions = {
'default':{ 'template_vars':['exec1'], 'template':['mp_sessions'], 'input':['0/0'], 'exec':[True] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
mp_sessions_sum = {
'default':{ 'template_vars':['exec1'], 'template':['mp_sessions_sum'], 'input':['0/0'], 'exec':[True] },
'vsrx-01':{ },
}
update_srx_all = {
'default':{ 'template_vars':['vsrx'], 'template':['cgn_srx_add'] },
'vsrx-01':{ 'input':['1'] },
'vsrx-02':{ 'input':['2'] },
'vsrx-03':{ 'input':['3'] },
'vsrx-04':{ 'input':['4'] },
}
add_srx_1 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_add'], 'input':['1'] },
'vsrx-01':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_add'], 'input':['1'] },
}
add_srx_2 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_add'], 'input':['2'] },
'vsrx-02':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_add'], 'input':['2'] },
}
add_srx_3 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_add'], 'input':['3'] },
'vsrx-03':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_add'], 'input':['3'] },
}
add_srx_4 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_add'], 'input':['4'] },
'vsrx-04':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_add'], 'input':['4'] },
}
del_srx_1 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_del'], 'input':['1'] },
'vsrx-01':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_del'], 'input':['1'] },
}
del_srx_2 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_del'], 'input':['2'] },
'vsrx-02':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_del'], 'input':['2'] },
}
del_srx_3 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_del'], 'input':['3'] },
'vsrx-03':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_del'], 'input':['3'] },
}
del_srx_4 = {
'vmx-01':{ 'template_vars':['mx'] , 'template': ['cgn_mx_del'], 'input':['4'] },
'vsrx-04':{ 'template_vars':['vsrx'], 'template': ['cgn_srx_del'], 'input':['4'] },
}
pl_1_add_json = {
'vsrx-01':{ 'template_vars':['vsrx'], 'template':['pl_1_add_json'], 'input':['1'], 'eph_inst':['pl','json'], 'save_rendered_j2':[False, False] },
'vsrx-02':{ 'template_vars':['vsrx'], 'template':['pl_1_add_json'], 'input':['2'], 'eph_inst':['pl','json'], 'save_rendered_j2':[False, False] },
'vsrx-03':{ 'template_vars':['vsrx'], 'template':['pl_1_add_json'], 'input':['3'], 'eph_inst':['pl','json'], 'save_rendered_j2':[False, False] },
'vsrx-04':{ 'template_vars':['vsrx'], 'template':['pl_1_add_json'], 'input':['4'], 'eph_inst':['pl','json'], 'save_rendered_j2':[False, False] },
}
pl_1_add_set = {
'default':{ 'template_vars':['vsrx'], 'template':['pl_1_add_set'], 'input':['1'], 'eph_inst':['pl','set'] },
'vsrx-01':{},
'vsrx-02':{},
'vsrx-03':{},
'vsrx-04':{},
}
filter = {
'default':{ 'template_vars':['exec1'], 'template':['filter'], 'input':['accept'], 'exec':[True], 'save_rendered_j2':[True, False] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
pl_1_del = {
'vsrx-01':{ 'template_vars':['vsrx'], 'template':['pl_1_del'], 'input':['1'], 'eph_inst':['pl','text'] },
'vsrx-02':{ 'template_vars':['vsrx'], 'template':['pl_1_del'], 'input':['2'], 'eph_inst':['pl','text'] },
'vsrx-03':{ 'template_vars':['vsrx'], 'template':['pl_1_del'], 'input':['3'], 'eph_inst':['pl','text'] },
'vsrx-04':{ 'template_vars':['vsrx'], 'template':['pl_1_del'], 'input':['4'], 'eph_inst':['pl','text'] },
}
version = {
'default':{ 'template_vars':['exec1'], 'template':['version'], 'input':[''], 'exec':[True] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
alarm = {
'default':{ 'template_vars':['exec1'], 'template':['alarm'], 'input':[''], 'exec':[True] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
shutdown = {
'default':{ 'template_vars':['exec1'], 'template':['shutdown'], 'input':[''], 'exec':[True] },
'vmx-01':{ },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
bgp = {
'default':{ 'template_vars':['exec1'], 'template':['bgp'], 'input':[''], 'exec':[True] },
'vsrx-01':{ },
'vsrx-02':{ },
'vsrx-03':{ },
'vsrx-04':{ },
}
mx_local = {
'default':{ 'template_vars':['exec1'], 'template':['version'], 'input':[''], 'exec':[True] },
'local':{ },
}
load = {
'default':{ 'template_vars':['exec1'], 'template':['load'], 'input':[''], 'exec':[True] },
}
load = {**load, **vsrx }
mp_load_sum = {
'default':{ 'template_vars':['exec1'], 'template':['mp_load_sum'], 'input':[''], 'exec':[True] },
'vsrx-01':{},
}