Blog Viewer

Scripting How-To: Limit the number of channelized e1 interfaces on a cstm1 interface

By Erdem posted 08-10-2015 05:49

  

Limit the Number of Channelized e1 Interfaces

 

For SLAX version 1.0 and higher, you can use this script to limit the number of channelized e1 interfaces on a cstm1 interface to avoid contention issues with per-unit-schedulers. The script ensures that there are no more than 16 chE1s per cstm1. 

 

This example tests the number of e1 interfaces configured on a cstm1 interface. For each cstm1 interface, the set of corresponding e1 interfaces is selected. The count() of those interfaces should not exceed the limit given in the global variable $limit (16). If there are more than $limit, a commit error is generated and the commit fails. 
 

Source Code and GitHub Links

 

The source code below is also available from the following GitHub locations:

 

Example Configuration

 
001	system {
002	    scripts {
003	    commit {
004	        file 16-e1-limit.xsl;
005	    }
006	    }
007	}
008	interfaces {
009	    cau4-0/1/0 {
010	        partition 1 interface-type ce1;
011	        partition 2-18 interface-type e1;
012	    }
013	    cstm1-0/1/0 {
014	        no-partition interface-type cau4;
015	    }
016	    ce1-0/1/0:1 {
017	        clocking internal;
018	        e1-options {
019	            framing g704;
020	        }
021	        partition 1 timeslots 1-4 interface-type ds;
022	    }
023	    ds-0/1/0:1:1 {
024	        no-keepalives;
025	        dce;
026	        encapsulation frame-relay;
027	        lmi {
028	            lmi-type ansi;
029	        }
030	        unit 100 {
031	            point-to-point;
032	            dlci 100;
033	            family inet {
034	                filter {
035	                    output fil-stresstest-1704-out;
036	                }
037	                address 10.0.0.0/31;
038	            }
039	        }
040	    }
041	    e1-0/1/0:2 {
042	        no-keepalives;
043	        per-unit-scheduler;
044	        dce;
045	        clocking internal;
046	        encapsulation frame-relay;
047	        lmi {
048	            lmi-type ansi;
049	        }
050	        e1-options {
051	            framing g704;
052	        }
053	        unit 100 {
054	            point-to-point;
055	            dlci 100;
056	            family inet {
057	                filter {
058	                    output fil-stresstest-1704-out;
059	                }
060	                address 10.0.0.2/31;
061	            }
062	        }
063	    }
064	    e1-0/1/0:3 {
065	        no-keepalives;
066	        per-unit-scheduler;
067	        dce;
068	        clocking internal;
069	        encapsulation frame-relay;
070	        lmi {
071	            lmi-type ansi;
072	        }
073	        e1-options {
074	            framing g704;
075	        }
076	        unit 100 {
077	            point-to-point;
078	            dlci 100;
079	            family inet {
080	                filter {
081	                    output fil-stresstest-1704-out;
082	                }
083	                address 10.0.0.4/31;
084	            }
085	        }
086	    }
087	    e1-0/1/0:4 {
088	        no-keepalives;
089	        per-unit-scheduler;
090	        dce;
091	        clocking internal;
092	        encapsulation frame-relay;
093	        lmi {
094	            lmi-type ansi;
095	        }
096	        e1-options {
097	            framing g704;
098	        }
099	        unit 100 {
100	            point-to-point;
101	            dlci 100;
102	            family inet {
103	                filter {
104	                    output fil-stresstest-1704-out;
105	                }
106	                address 10.0.0.6/31;
107	            }
108	        }
109	    }
110	    e1-0/1/0:5 {
111	        no-keepalives;
112	        per-unit-scheduler;
113	        dce;
114	        clocking internal;
115	        encapsulation frame-relay;
116	        lmi {
117	            lmi-type ansi;
118	        }
119	        e1-options {
120	            framing g704;
121	        }
122	        unit 100 {
123	            point-to-point;
124	            dlci 100;
125	            family inet {
126	                filter {
127	                    output fil-stresstest-1704-out;
128	                }
129	                address 10.0.0.8/31;
130	            }
131	        }
132	    }
133	    e1-0/1/0:6 {
134	        no-keepalives;
135	        per-unit-scheduler;
136	        dce;
137	        clocking internal;
138	        encapsulation frame-relay;
139	        lmi {
140	            lmi-type ansi;
141	        }
142	        e1-options {
143	            framing g704;
144	        }
145	        unit 100 {
146	            point-to-point;
147	            dlci 100;
148	            family inet {
149	                filter {
150	                    output fil-stresstest-1704-out;
151	                }
152	                address 10.0.0.10/31;
153	            }
154	        }
155	    }
156	    e1-0/1/0:7 {
157	        no-keepalives;
158	        per-unit-scheduler;
159	        dce;
160	        clocking internal;
161	        encapsulation frame-relay;
162	        lmi {
163	            lmi-type ansi;
164	        }
165	        e1-options {
166	            framing g704;
167	        }
168	        unit 100 {
169	            point-to-point;
170	            dlci 100;
171	            family inet {
172	                filter {
173	                    output fil-stresstest-1704-out;
174	                }
175	                address 10.0.0.12/31;
176	            }
177	        }
178	    }
179	    e1-0/1/0:8 {
180	        no-keepalives;
181	        per-unit-scheduler;
182	        dce;
183	        clocking internal;
184	        encapsulation frame-relay;
185	        lmi {
186	            lmi-type ansi;
187	        }
188	        e1-options {
189	            framing g704;
190	        }
191	        unit 100 {
192	            point-to-point;
193	            dlci 100;
194	            family inet {
195	                filter {
196	                    output fil-stresstest-1704-out;
197	                }
198	                address 10.0.0.14/31;
199	            }
200	        }
201	    }
202	    e1-0/1/0:9 {
203	        no-keepalives;
204	        per-unit-scheduler;
205	        dce;
206	        clocking internal;
207	        encapsulation frame-relay;
208	        lmi {
209	            lmi-type ansi;
210	        }
211	        e1-options {
212	            framing g704;
213	        }
214	        unit 100 {
215	            point-to-point;
216	            dlci 100;
217	            family inet {
218	                filter {
219	                    output fil-stresstest-1704-out;
220	                }
221	                address 10.0.0.16/31;
222	            }
223	        }
224	    }
225	    e1-0/1/0:10 {
226	        no-keepalives;
227	        per-unit-scheduler;
228	        dce;
229	        clocking internal;
230	        encapsulation frame-relay;
231	        lmi {
232	            lmi-type ansi;
233	        }
234	        e1-options {
235	            framing g704;
236	        }
237	        unit 100 {
238	            point-to-point;
239	            dlci 100;
240	            family inet {
241	                filter {
242	                    output fil-stresstest-1704-out;
243	                }
244	                address 10.0.0.18/31;
245	            }
246	        }
247	    }
248	    e1-0/1/0:11 {
249	        no-keepalives;
250	        per-unit-scheduler;
251	        dce;
252	        clocking internal;
253	        encapsulation frame-relay;
254	        lmi {
255	            lmi-type ansi;
256	        }
257	        e1-options {
258	            framing g704;
259	        }
260	        unit 100 {
261	            point-to-point;
262	            dlci 100;
263	            family inet {
264	                filter {
265	                    output fil-stresstest-1704-out;
266	                }
267	                address 10.0.0.20/31;
268	            }
269	        }
270	    }
271	    e1-0/1/0:12 {
272	        no-keepalives;
273	        per-unit-scheduler;
274	        dce;
275	        clocking internal;
276	        encapsulation frame-relay;
277	        lmi {
278	            lmi-type ansi;
279	        }
280	        e1-options {
281	            framing g704;
282	        }
283	        unit 100 {
284	            point-to-point;
285	            dlci 100;
286	            family inet {
287	                filter {
288	                    output fil-stresstest-1704-out;
289	                }
290	                address 10.0.0.22/31;
291	            }
292	        }
293	    }
294	    e1-0/1/0:13 {
295	        no-keepalives;
296	        per-unit-scheduler;
297	        dce;
298	        clocking internal;
299	        encapsulation frame-relay;
300	        lmi {
301	            lmi-type ansi;
302	        }
303	        e1-options {
304	            framing g704;
305	        }
306	        unit 100 {
307	            point-to-point;
308	            dlci 100;
309	            family inet {
310	                filter {
311	                    output fil-stresstest-1704-out;
312	                }
313	                address 10.0.0.24/31;
314	            }
315	        }
316	    }
317	    e1-0/1/0:14 {
318	        no-keepalives;
319	        per-unit-scheduler;
320	        dce;
321	        clocking internal;
322	        encapsulation frame-relay;
323	        lmi {
324	            lmi-type ansi;
325	        }
326	        e1-options {
327	            framing g704;
328	        }
329	        unit 100 {
330	            point-to-point;
331	            dlci 100;
332	            family inet {
333	                filter {
334	                    output fil-stresstest-1704-out;
335	                }
336	                address 10.0.0.26/31;
337	            }
338	        }
339	    }
340	    e1-0/1/0:15 {
341	        no-keepalives;
342	        per-unit-scheduler;
343	        dce;
344	        clocking internal;
345	        encapsulation frame-relay;
346	        lmi {
347	            lmi-type ansi;
348	        }
349	        e1-options {
350	            framing g704;
351	        }
352	        unit 100 {
353	            point-to-point;
354	            dlci 100;
355	            family inet {
356	                filter {
357	                    output fil-stresstest-1704-out;
358	                }
359	                address 10.0.0.28/31;
360	            }
361	        }
362	    }
363	    e1-0/1/0:16 {
364	        no-keepalives;
365	        per-unit-scheduler;
366	        dce;
367	        clocking internal;
368	        encapsulation frame-relay;
369	        lmi {
370	            lmi-type ansi;
371	        }
372	        e1-options {
373	            framing g704;
374	        }
375	        unit 100 {
376	            point-to-point;
377	            dlci 100;
378	            family inet {
379	                filter {
380	                    output fil-stresstest-1704-out;
381	                }
382	                address 10.0.0.30/31;
383	            }
384	        }
385	    }
386	    e1-0/1/0:17 {
387	        no-keepalives;
388	        per-unit-scheduler;
389	        dce;
390	        clocking internal;
391	        encapsulation frame-relay;
392	        lmi {
393	            lmi-type ansi;
394	        }
395	        e1-options {
396	            framing g704;
397	        }
398	        unit 100 {
399	            point-to-point;
400	            dlci 100;
401	            family inet {
402	                filter {
403	                    output fil-stresstest-1704-out;
404	                }
405	                address 10.0.0.32/31;
406	            }
407	        }
408	    }
409	    e1-0/1/0:18 {
410	        no-keepalives;
411	        per-unit-scheduler;
412	        dce;
413	        clocking internal;
414	        encapsulation frame-relay;
415	        lmi {
416	            lmi-type ansi;
417	        }
418	        e1-options {
419	            framing g704;
420	        }
421	        unit 100 {
422	            point-to-point;
423	            dlci 100;
424	            family inet {
425	                filter {
426	                    output fil-stresstest-1704-out;
427	                }
428	                address 10.0.0.34/31;
429	            }
430	        }
431	    }
432	}
 

Example Output

 
1	[edit interfaces]
2	  'cstm1-0/1/0'
3	    e1/cstm1 limit exceeded; 17 are configured but only 16 are allowed
4	error: 1 error reported by commit scripts
5	error: commit script failure
 

SLAX Script Contents 

 
01	/* Machine Crafted with Care (tm) by slaxWriter */
02	version 1.0;
03	 
04	 
05	/*
06	- $Id: 16-e1-limit.slax,v 1.1 2007/10/17 18:37:03 phil Exp $
07	-
08	- Copyright (c) 2004-2005, Juniper Networks, Inc.
09	- All rights reserved.
10	-
11	 */
12	ns junos = "http://xml.juniper.net/junos/*/junos";
13	ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
14	ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
15	 
16	import "../import/junos.xsl";
17	param $limit = 16;
18	 
19	/*
20	- This example tests the number of e1 interfaces configured
21	- on a cstm1 interface.   For each cstm1 interface, the set
22	- of corresponding e1 interfaces is selected.  The count()
23	- of those interfaces should not exceed the limit given in the
24	- global variable $limit.  If there are more than $limit, a
25	- commit error is generated and the commit fails.
26	 */
27	match configuration {
28	    var $interfaces = interfaces;
29	     
30	    for-each ($interfaces/interface[starts-with(name, "cstm1-")]) {
31	        var $triple = substring-after(name, "cstm1-");
32	        var $e1name = "e1-" _ $triple;
33	        var $count = count($interfaces/interface[starts-with(name, $e1name)]);
34	         
35	        if ($count > $limit) {
36	            <xnm:error> {
37	                <edit-path> "[edit interfaces]";
38	                <statement> name;
39	                <message> {
40	                    expr "e1/cstm1 limit exceeded; ";
41	                    expr $count;
42	                    expr " are configured but only ";
43	                    expr $limit;
44	                    expr " are allowed";
45	                }
46	            }
47	        }
48	    }
49	}
 

XML Script Contents

 
01	<?xml version="1.0"?>
02	<script version="0.1">
03	  <title>16-e1-limit.slax</title>
04	  <alternate>16-e1-limit.xsl</alternate>
05	  <author>phil</author>
06	  <synopsis>
07	    Limit the number of channelized e1 interfaces on a  cstm1 interface
08	  </synopsis>
09	  <keyword>channelization</keyword>
10	  <keyword>per-unit-scheduler</keyword>
11	 
12	  <description>
13	    This script limits the number of channelization on cstm1 interfaces
14	    to avoid contention issues with per-unit-schedulers. 
15	    The script ensures that there are no more than 16 chE1s per cstm1.
16	  </description>
17	  <implementation>
18	    This example tests the number of e1 interfaces configured
19	    on a cstm1 interface.   For each cstm1 interface, the set
20	    of corresponding e1 interfaces is selected.  The count()
21	    of those interfaces should not exceed the limit given in the
22	    global variable $limit (16).  If there are more than $limit, a
23	    commit error is generated and the commit fails.
24	  </implementation>
25	 
26	  <example>
27	    <config>16-e1-limit.conf</config>
28	    <errors>16-e1-limit.output</errors>
29	  </example>
30	  <xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
31	                src="../../../../../web/leaf.js" type="text/javascript"/>
32	</script>

#ScriptingHow-To
#commitscript
#How-To
#interface
#Slax
#cstm1

Permalink