| author | "Tomas Zeman <tzeman@volny.cz>" |
| Wed, 02 Dec 2009 22:19:55 +0100 | |
| changeset 19 | 0f5d67d6ed04 |
| parent 16 | 6822d0e5df57 |
| child 20 | 2635a9301907 |
| permissions | -rw-r--r-- |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
1 |
# Grammar for Cisco devices |
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
2 |
# Configuration is expected to be preprocessed via following command: |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
3 |
# perl -ne '/(^\s*)(\S.*)$/; print length($1)." $2\n"' |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
4 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
5 |
#<autotree> |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
6 |
{ # perl code follows
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
7 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
8 |
$::res = {};
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
9 |
|
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
10 |
# Returns pointer to context hashref as specified by ctx stack. |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
11 |
# @param ctx_path array of ctx stack. |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
12 |
sub ctx {
|
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
13 |
return ctx_rel($::res, @_); |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
14 |
} |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
15 |
|
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
16 |
# Returns pointer to context hashref as specified by ctx stack, |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
17 |
# relative to the supplied ctx pointer. |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
18 |
# @param ptr current ctx pointer from which ctx build starts. |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
19 |
# @param ctx_path array of ctx stack. |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
20 |
sub ctx_rel {
|
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
21 |
my $ptr = shift; |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
22 |
my @ctx_path = @_; |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
23 |
foreach my $part (@ctx_path) {
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
24 |
$ptr->{$part} = {} unless exists ($ptr->{$part});
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
25 |
$ptr = $ptr->{$part};
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
26 |
} |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
27 |
return $ptr; |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
28 |
} |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
29 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
30 |
} # end of perl code |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
31 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
32 |
file: <skip: qr/[^\S\n]*/> # Ignore non-newline whitespace |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
33 |
line(s) eofile |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
34 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
35 |
line: s_controller |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
36 |
| s_interface |
| 12 | 37 |
| s_vrf |
| 13 | 38 |
| s_vlan |
| 14 | 39 |
| vtp_line |
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
40 |
| indent comment |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
41 |
| indent cmdline |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
42 |
| indent emptyline |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
43 |
| <error> |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
44 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
45 |
emptyline: eol |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
46 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
47 |
comment: /!.*/ eol |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
48 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
49 |
cmdline: l_hostname eol |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
50 |
| l_hash eol |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
51 |
| word(s) eol |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
52 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
53 |
word: /[0-9a-zA-Z:\/_\#\"\.,+<>()&{}-]+/
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
54 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
55 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
56 |
type: /\w+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
57 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
58 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
59 |
num: /\d+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
60 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
61 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
62 |
indent: /\d+/ |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
63 |
{ $item[1] }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
64 |
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
65 |
range: /\d+/"-"/\d+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
66 |
{ { from => $item[1], to => $item[3] } }
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
67 |
| /\d+/ |
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
68 |
{ { from => $item[1], to => $item[1] } }
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
69 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
70 |
keyword: /[\w-]+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
71 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
72 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
73 |
identifier: /[0-9a-zA-Z:_-]+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
74 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
75 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
76 |
quoted_text: <perl_quotelike> |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
77 |
{ $item[1][2] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
78 |
| /[0-9a-zA-Z:\/_\#\"\.,-]+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
79 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
80 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
81 |
value: /[0-9a-zA-Z:\/_\#\"\.,-]+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
82 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
83 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
84 |
eofile: /^\Z/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
85 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
86 |
eol: /\n/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
87 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
88 |
rest_of_line: word(s) |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
89 |
| eol |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
90 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
91 |
# section |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
92 |
section: cmdline(s) "!" |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
93 |
{ print "section\n"; }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
94 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
95 |
l_section: /[1-9]/ word(s) eol |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
96 |
| /[1-9]/ "!" eol |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
97 |
| /[1-9]/ eol |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
98 |
| <error> |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
99 |
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
100 |
# Lines w/ hash (passwd, secret etc) |
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
101 |
l_hash: word(s) /\S+/ word(s) |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
102 |
| word(s) /\S+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
103 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
104 |
# Hostname |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
105 |
l_hostname: "hostname" identifier |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
106 |
{ $::res->{hostname} = $item{identifier} }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
107 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
108 |
# Description |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
109 |
l_description: "description" /[^\n]+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
110 |
{ $arg{ctx}->{description} = $item[2] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
111 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
112 |
# controller section |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
113 |
controller_num: /\d+\/\d+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
114 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
115 |
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
116 |
chan_grp_content: "channel-group" num "timeslots" range |
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
117 |
{ $arg{ctx}->{"channel-group"}->{$item{num}}->{ts} = $item{range} }
|
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
118 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
119 |
s_controller: "0" "controller" type controller_num eol s_controller_l[ctx => ctx('controller', $item{controller_num}) ](s) "0" "!" eol
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
120 |
{ $::res->{controller}->{$item{controller_num}}->{type} = $item{type} }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
121 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
122 |
s_controller_l: "1" s_controller_content[ctx => $arg{ctx}] eol
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
123 |
| l_section |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
124 |
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
125 |
s_controller_content: l_description[ctx => $arg{ctx}]
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
126 |
| chan_grp_content[ctx => $arg{ctx}]
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
127 |
| "channel-group" num "unframed" |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
128 |
{ $arg{ctx}->{"channel-group"}->{$item{num}}->{unframed} = 1 }
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
129 |
| "framing" keyword |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
130 |
{ $arg{ctx}->{framing} = $item{keyword} }
|
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
131 |
| "au-4" num "tug-3" num eol s_tug_l[ctx => ctx_rel($arg{ctx}, 'au', $item[2], 'tug', $item[4]) ](s)
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
132 |
| s_e3_l[ctx => $arg{ctx}]
|
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
133 |
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
134 |
# SONET controller specific |
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
135 |
s_tug_l: "2" "tug-2" num "e1" num tug_content[ctx => ctx_rel($arg{ctx}, $item[3].'/'.$item[5]) ] eol
|
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
136 |
|
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
137 |
tug_content: l_description[ctx => $arg{ctx}]
|
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
138 |
| "unframed" |
|
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
139 |
{ $arg{ctx}->{unframed} = 1 }
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
140 |
| chan_grp_content[ctx => $arg{ctx}]
|
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
141 |
| word(s) |
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
142 |
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
143 |
# E3 controller specific |
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
144 |
s_e3_l: "e1" num chan_grp_content[ctx => ctx_rel($arg{ctx}, 'e1', $item{num})]
|
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
145 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
146 |
# Vlan range |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
147 |
vlan_s_range: /\d+/"-"/\d+/ |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
148 |
{
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
149 |
for (my $i = $item[1]; $i <= $item[3]; $i++) {
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
150 |
$arg{ctx}->{$arg{key}}->{$i} = 1; }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
151 |
} |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
152 |
| /\d+/ |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
153 |
{ $arg{ctx}->{$arg{key}}->{$item[1]} = 1 }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
154 |
vlan_range: vlan_s_range","vlan_range |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
155 |
| vlan_s_range |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
156 |
|
| 13 | 157 |
# vlan section |
158 |
s_vlan: "0" "vlan" num eol "1" "name" identifier eol |
|
159 |
{ $::res->{vlans}->{$item{num}}->{name} = $item{identifier} }
|
|
160 |
||
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
161 |
# interface section |
| 12 | 162 |
iface_name: /\w+(-\w+)?\d+[0-9\/\.:]*/ |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
163 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
164 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
165 |
s_interface: "0" "interface" iface_name /\S*/ eol s_interface_l[ctx => ctx("interface", $item{iface_name}) ](s) "0" "!" eol
|
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
166 |
{
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
167 |
$::res->{interface}->{$item{iface_name}}->{type} = $item[4]
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
168 |
if length($item[4]) > 0 |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
169 |
} |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
170 |
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
171 |
ip: /\d+\.\d+\.\d+\.\d+/ |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
172 |
{ $item[1] }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
173 |
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
174 |
s_interface_l: "1" s_interface_content[ctx => $arg{ctx}] eol
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
175 |
| l_section |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
176 |
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
177 |
s_interface_content: l_description[ctx => $arg{ctx}]
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
178 |
| /(no)?/ "shutdown" |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
179 |
{ $arg{ctx}->{shutdown} = ($item[1] eq 'no') ? 0 : 1 }
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
180 |
| "ip" "address" ip ip |
|
15
fb5c38cb93a9
cisco.grammar: parse au/tug inside sonet controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
14
diff
changeset
|
181 |
{ $arg{ctx}->{ip} = $item[3]; $arg{ctx}->{mask} = $item[4] }
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
182 |
| "encapsulation" keyword /\S*/ |
|
10
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
183 |
{
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
184 |
$arg{ctx}->{encap} = $item[2];
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
185 |
$arg{ctx}->{encap_param} = $item[3] if length($item[3]) > 0
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
186 |
} |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
187 |
| "frame-relay" keyword keyword |
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
188 |
{ $arg{ctx}->{"frame-relay"} = {type => $item[2], value => $item[3]} }
|
|
91148603fd70
added cisco.grammar: parse hostname, controllers, interfaces
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff
changeset
|
189 |
| "bandwidth" num |
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
190 |
{ $arg{ctx}->{bandwidth} = $item{num} }
|
|
16
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
191 |
| "speed" num |
|
6822d0e5df57
cisco.grammar: fixed timeslot range, e3 controller
"Tomas Zeman <tzeman@volny.cz>"
parents:
15
diff
changeset
|
192 |
{ $arg{ctx}->{speed} = $item{num} }
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
193 |
| "ip" "vrf" "forwarding" word |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
194 |
{ $arg{ctx}->{"ip-vrf-fwd"} = $item{word} }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
195 |
| "switchport" "mode" /access|trunk/ |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
196 |
{ $arg{ctx}->{"switchport-mode"} = $item[3] }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
197 |
| "switchport" "access" "vlan" num |
|
19
0f5d67d6ed04
cisco.grammar: unify vlans for access/trunk switch port
"Tomas Zeman <tzeman@volny.cz>"
parents:
16
diff
changeset
|
198 |
{ $arg{ctx}->{vlan}->{$item{num}} = 1 }
|
|
11
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
199 |
| "switchport" "trunk" "encapsulation" keyword |
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
200 |
{ $arg{ctx}->{"trunk-encap"} = $item{keyword} }
|
|
c170b1da9b6e
cisco.grammar: refactored to use indentation markers fro proper in-section parsing; more controller, interface properties
"Tomas Zeman <tzeman@volny.cz>"
parents:
10
diff
changeset
|
201 |
| "switchport" "trunk" "allowed" "vlan" vlan_range[ctx => $arg{ctx}, key => "vlan"]
|
| 12 | 202 |
| "channel-group" num "mode" keyword |
203 |
{ $arg{ctx}->{"channel-group"}->{$item{num}}->{mode} = $item{keyword} }
|
|
204 |
| "ip" "vrf" "forwarding" word |
|
205 |
{ $arg{ctx}->{"ip-vrf-fwd"} = $item{word} }
|
|
206 |
||
207 |
# vrf section |
|
208 |
s_vrf: "0" "ip" "vrf" keyword eol s_vrf_l[ctx => ctx("vrf", $item{keyword}) ](s) "0" "!" eol
|
|
209 |
||
210 |
s_vrf_l: "1" s_vrf_content[ctx => $arg{ctx}] eol
|
|
211 |
| l_section |
|
212 |
||
213 |
rd_val: /\d+:\d+/ |
|
214 |
{ $item[1] }
|
|
215 |
||
216 |
s_vrf_content: l_description[ctx => $arg{ctx}]
|
|
217 |
| "rd" rd_val |
|
218 |
{ $arg{ctx}->{rd} = $item{rd_val} }
|
|
219 |
| "export" "map" keyword |
|
220 |
{ $arg{ctx}->{"export-map"} = $item{keyword} }
|
|
221 |
| "route-target" /export|import/ rd_val |
|
222 |
{
|
|
223 |
$arg{ctx}->{"route-target"}->{$item[2]} = []
|
|
224 |
unless exists $arg{ctx}->{"route-target"}->{$item[2]};
|
|
225 |
push @{$arg{ctx}->{"route-target"}->{$item[2]}}, $item{rd_val};
|
|
| 13 | 226 |
} |
| 12 | 227 |
|
| 14 | 228 |
# vtp |
229 |
vtp_line: "0" "vtp" /mode|domain/ identifier eol |
|
230 |
{ $::res->{vtp}->{$item[3]} = $item{identifier} }
|