ciena.grammar
changeset 2 7b9f165f3a45
parent 1 7e38ef20071f
child 3 23467e5d2602
equal deleted inserted replaced
1:7e38ef20071f 2:7b9f165f3a45
    14 $::res->{pbt} = {
    14 $::res->{pbt} = {
    15 	reserved => {},	# reserved bvids
    15 	reserved => {},	# reserved bvids
    16 	'bridge-mac' => {},
    16 	'bridge-mac' => {},
    17 };
    17 };
    18 $::res->{'pbt-service'} = {};
    18 $::res->{'pbt-service'} = {};
       
    19 $::res->{'pbt-transit'} = {};
    19 $::res->{'pbt-tunnel-group'} = {};
    20 $::res->{'pbt-tunnel-group'} = {};
       
    21 $::res->{'pbt-tunnel'} = {};
       
    22 $::res->{'tunnel'} = {};
       
    23 $::res->{'tunnel-pair'} = {};
       
    24 $::res->{'cfm-service'} = {};
       
    25 $::res->{vc} = {};
       
    26 $::res->{vs} = {};
       
    27 $::res->{"vs-vlans"} = {};
    20 
    28 
    21 
    29 
    22 # local (current line) attribute-value-list, ie. property value
    30 # local (current line) attribute-value-list, ie. property value
    23 my $avl = {};
    31 my $avl = {};
    24 
    32 
    63 cmdline:	l_hostname
    71 cmdline:	l_hostname
    64 		| l_port
    72 		| l_port
    65 		| l_sub_port
    73 		| l_sub_port
    66 		| l_pm
    74 		| l_pm
    67 		| l_pbt
    75 		| l_pbt
       
    76 		| l_tunnel_pair
       
    77 		| l_tunnel
       
    78 		| l_cfm_service
       
    79 		| l_vc
       
    80 		| l_vs
    68 		| word(s) eol
    81 		| word(s) eol
    69 
    82 
    70 word:		/[0-9a-zA-Z:\/_\#\"\.,-]+/
    83 word:		/[0-9a-zA-Z:\/_\#\"\.,-]+/
    71 		{ $item[1] }
    84 		{ $item[1] }
    72 
    85 
   141 		}
   154 		}
   142 		| "pbt" "service" "create" "service" identifier avls
   155 		| "pbt" "service" "create" "service" identifier avls
   143 		{ consume_avl("pbt-service", $item{identifier}) }
   156 		{ consume_avl("pbt-service", $item{identifier}) }
   144 		| "pbt" "tunnel-group" "create" "group" identifier avls
   157 		| "pbt" "tunnel-group" "create" "group" identifier avls
   145 		{ consume_avl("pbt-tunnel-group", $item{identifier}) }
   158 		{ consume_avl("pbt-tunnel-group", $item{identifier}) }
       
   159 		| "pbt" "transit" /\w+/ "pbt-transit" identifier avls
       
   160 		{ consume_avl("pbt-transit", $item{identifier}) }
       
   161 		| "pbt" /encap|decap/"-tunnel" /\w+/ /\S+/ identifier avls
       
   162 		{
       
   163 		$::res->{"pbt-tunnel"}->{$item{identifier}}->{type} = $item[2];
       
   164 		consume_avl("pbt-tunnel", $item{identifier})
       
   165 		}
       
   166 
       
   167 # Tunnel pair
       
   168 l_tunnel_pair:	"tunnel" "pair" "create" "tnl-pair" identifier avls
       
   169 		{ consume_avl("tunnel-pair", $item{identifier}) }
       
   170 
       
   171 # Tunnel
       
   172 l_tunnel:	"tunnel" /encap|decap/ "create" /\S+/ identifier avls
       
   173 		{
       
   174 		$::res->{tunnel}->{$item{identifier}} = {
       
   175 			"tunnel-type" => $item[2],
       
   176 			"pbt-type" => $item[4],
       
   177 		};
       
   178 		consume_avl("tunnel", $item{identifier})
       
   179 		}
       
   180 
       
   181 # CFM
       
   182 l_cfm_service:	"cfm" "service" "create" identifier identifier "name" identifier avls
       
   183 		{
       
   184 		my ($pbt_type, $pbt, $cfm) = ($item[4], $item[5], $item[7]);
       
   185 		$::res->{"cfm-service"}->{$cfm} = {
       
   186 			"pbt-type" => $pbt_type,
       
   187 			"pbt" => $pbt,
       
   188 		};
       
   189 		consume_avl("cfm-service", $cfm);
       
   190 		}
       
   191 		| "cfm" "service" "set" "service" identifier avls
       
   192 		{ consume_avl("cfm-service", $item{identifier}) }
       
   193 		| "cfm" "service" "enable" "service" identifier
       
   194 		{ $::res->{"cfm-service"}->{$item{identifier}}->{enabled} = 1; }
       
   195 
       
   196 # Virtual circuit
       
   197 l_vc:		"virtual-circuit" "pbt" "create" identifier identifier avls
       
   198 		{
       
   199 		my ($vc_type, $vc) = ($item[4], $item[5]);
       
   200 		$::res->{vc}->{$vc}->{type} = $vc_type;
       
   201 		consume_avl("vc", $vc);
       
   202 		}
       
   203 
       
   204 # Virtual switch
       
   205 l_vs:		"virtual-switch" "create" "vs" identifier
       
   206 		{ $::res->{vs}->{$item{identifier}} = {}; }
       
   207 		| "virtual-switch" "ethernet" "create" "vs" identifier "vc" identifier
       
   208 		{
       
   209 		my ($vs, $vc) = ($item[5], $item[7]);
       
   210 		$::res->{vs}->{$vs}->{ethernet}->{vc} = $vc;
       
   211 		}
       
   212 		| "virtual-switch" "ethernet" "add" "vs" identifier avls
       
   213 		{
       
   214 		my $vs = $item{identifier};
       
   215 		$::res->{vs}->{$vs}->{ethernet}->{members} = []
       
   216 			unless exists $::res->{vs}->{$vs}->{ethernet}->{members};
       
   217 		my %params = %$avl;
       
   218 		push @{$::res->{vs}->{$vs}->{ethernet}->{members}}, \%params;
       
   219 		$avl = {};
       
   220 		}
       
   221 		| "virtual-switch" "interface" "attach" /(\w|-)+/ identifier "vs" identifier
       
   222 		{
       
   223 		my ($entity_type, $entity, $vs) = ($item[4], $item[5], $item[7]);
       
   224 		$::res->{vs}->{$vs}->{interfaces} = []
       
   225 			unless exists $::res->{vs}->{$vs}->{interfaces};
       
   226 		push @{$::res->{vs}->{$vs}->{interfaces}}, {
       
   227 			entity => $entity,
       
   228 			type => $entity_type,
       
   229 		};
       
   230 		}
       
   231 		| "virtual-switch" "l2-cft" "protocol" "add" "vs" identifier avls
       
   232 		{
       
   233 		my $vs = $item{identifier};
       
   234 		$::res->{vs}->{$vs}->{"l2-cft"}->{protocols} = []
       
   235 			unless exists $::res->{vs}->{$vs}->{"l2-cft"}->{protocols};
       
   236 		my %params = %$avl;
       
   237 		push @{$::res->{vs}->{$vs}->{"l2-cft"}->{protocols}}, \%params;
       
   238 		$avl = {};
       
   239 		}
       
   240 		| "virtual-switch" "l2-cft" "enable" "vs" identifier
       
   241 		{ $::res->{vs}->{$item{identifier}}->{"l2-cft"}->{enabled} = 1 }
       
   242 		| "virtual-switch" "private-forwarding-groups" "enable" "vs" identifier
       
   243 		{ $::res->{vs}->{$item{identifier}}->{"priv-fwd-grp"}->{enabled} = 1 }
       
   244 		| "virtual-switch" "private-forwarding-groups" "set" "vs" identifier avls
       
   245 		{
       
   246 		my $vs = $item{identifier};
       
   247 		my %params = %$avl;
       
   248 		$::res->{vs}->{$vs}->{"priv-fwd-grp"} = \%params;
       
   249 		$avl = {};
       
   250 		}
       
   251 		| "virtual-switch" "add" "reserved-vlan" /\d+/"-"/\d+/
       
   252 		{
       
   253 		my ($from, $to) = ($item[4], $item[6]);
       
   254 		for (my $i = $from; $i <= $to; $i++) {
       
   255 			$::res->{"vs-vlans"}->{$i} = 1;
       
   256 		}
       
   257 		}
       
   258