2 * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Contributor: hema.gopalkrishnan@ericsson.com
10 package org.opendaylight.openflowplugin.test;
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.Arrays;
15 import java.util.List;
16 import java.util.concurrent.ExecutionException;
17 import java.util.concurrent.Future;
19 import org.eclipse.osgi.framework.console.CommandInterpreter;
20 import org.eclipse.osgi.framework.console.CommandProvider;
21 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
22 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
23 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
24 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder ;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder ;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc;
98 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
99 import org.opendaylight.yangtools.yang.common.RpcResult;
100 import org.osgi.framework.BundleContext;
103 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
105 private DataBrokerService dataBrokerService;
106 private ProviderContext pc;
107 private final BundleContext ctx;
108 private Table testTable;
109 private Node testNode;
110 private final String originalTableName = "Foo";
111 private final String updatedTableName = "Bar";
113 public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
117 public void onSessionInitiated(ProviderContext session) {
119 dataBrokerService = session.getSALService(DataBrokerService.class);
120 ctx.registerService(CommandProvider.class.getName(), this, null);
122 // createTestTable();
125 private void createUserNode(String nodeRef) {
126 NodeBuilder builder = new NodeBuilder();
127 builder.setId(new NodeId(nodeRef));
128 builder.setKey(new NodeKey(builder.getId()));
129 testNode = builder.build();
132 private void createTestNode() {
133 NodeBuilder builder = new NodeBuilder();
134 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
135 builder.setKey(new NodeKey(builder.getId()));
136 testNode = builder.build();
139 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
140 return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
143 private TableBuilder createTestTable(String tableFeatureTypeArg) {
145 String tableFeatureType = tableFeatureTypeArg;
146 if (tableFeatureType == null) {
147 tableFeatureType = "t1";
149 // Sample data , committing to DataStore
150 DataModification modification = dataBrokerService.beginTransaction();
152 TableKey key = new TableKey(id) ;
154 TableBuilder table = new TableBuilder();
155 table.setId((short)12) ;
160 List<TableFeatures> ofTablefeatures = new ArrayList<TableFeatures>() ;
162 // Skip this to send empty table features
163 if( ! tableFeatureType.equals( "t1")) {
166 TableFeaturesBuilder tableFeature1 = new TableFeaturesBuilder() ;
167 tableFeature1.setTableId(new Short((short)0));
168 tableFeature1.setName("Table 0");
171 tableFeature1.setMetadataMatch((new BigInteger("10", 10)));
172 tableFeature1.setMetadataWrite((new BigInteger("10", 10)));
173 tableFeature1.setMaxEntries(new Long(10000)) ;
175 tableFeature1.setConfig(new TableConfig(false));
177 List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>() ;
180 switch( tableFeatureType) {
182 //To set the ApplyActionsMiss
183 properties.add(createApplyActionsMissTblFeatureProp().build()) ;
186 // To set the Next Table
187 properties.add(createNextTblFeatureProp().build()) ;
190 // To set the Next Table Miss
191 properties.add(createNextTableMissTblFeatureProp().build()) ;
194 //To set the ApplyActions
195 properties.add(createApplyActionsTblFeatureProp().build()) ;
198 // To set the instructions
199 properties.add(createInstructionsTblFeatureProp().build());
202 // To set the instructions miss
203 properties.add(createInstructionsMissTblFeatureProp().build());
206 // To set the write actions
207 properties.add(createWriteActionsTblFeatureProp().build()) ;
210 // To set the write actions miss
211 properties.add(createWriteActionsMissTblFeatureProp().build()) ;
214 // To set the match field
215 properties.add(createMatchFieldTblFeatureProp().build()) ;
218 // To set the write set-field
219 properties.add( createWriteSetFieldTblFeatureProp().build()) ;
222 // To set the write set-field miss
223 properties.add( createWriteSetFieldMissTblFeatureProp().build()) ;
226 // To set the apply set field
227 properties.add( createApplySetFieldTblFeatureProp().build()) ;
230 // To set the apply set field miss
231 properties.add( createApplySetFieldMissTblFeatureProp().build()) ;
234 // To set the wildcards set field match
235 properties.add( createWildCardsTblFeatureProp().build()) ;
240 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder() ;
241 propertyBld.setTableFeatureProperties(properties) ;
242 tableFeature1.setTableProperties(propertyBld.build());
245 ofTablefeatures.add(tableFeature1.build()) ;
248 table.setTableFeatures(ofTablefeatures) ;
250 testTable = table.build();
254 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
255 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
257 //To set the ApplyActionsMiss
258 List<Action> actionList = new ArrayList<Action>();
259 ActionBuilder ab = new ActionBuilder();
261 ab.setAction(new PopMplsActionCaseBuilder().build());
262 actionList.add(ab.build());
264 tableFeatureProperty.setTableFeaturePropType(
265 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder()
266 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build()) ;
268 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
269 tableFeatureProperty.setKey(keyValue) ;
270 tableFeatureProperty.setOrder(1) ;
272 return tableFeatureProperty ;
276 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
277 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
278 List<Action> actionListt5 = new ArrayList<Action>();
279 ActionBuilder abt5 = new ActionBuilder();
281 abt5.setAction(new PopMplsActionCaseBuilder().build());
282 actionListt5.add(abt5.build());
284 tableFeatureProperty.setTableFeaturePropType(
285 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder()
286 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build()) ;
288 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
289 tableFeatureProperty.setKey(keyValue) ;
290 tableFeatureProperty.setOrder(1) ;
292 return tableFeatureProperty ;
295 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
296 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
297 List<Short> nextTblIds = Arrays.asList(new Short[] { 2, 3} );
298 NextTableBuilder nextTblBld = new NextTableBuilder() ;
300 nextTblBld.setTables( new TablesBuilder().setTableIds(nextTblIds).build()) ;
301 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build() ) ;
303 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
304 tableFeatureProperty.setKey(keyValue) ;
305 tableFeatureProperty.setOrder(1) ;
307 return tableFeatureProperty ;
310 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
311 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
312 List<Short> nextTblMissIds = Arrays.asList( new Short[] { 23, 24, 25, 27, 28, 29 , 30 } );
313 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder() ;
315 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build()) ;
316 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build() ) ;
318 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
319 tableFeatureProperty.setKey(keyValue) ;
320 tableFeatureProperty.setOrder(1) ;
322 return tableFeatureProperty ;
327 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
328 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
330 List<Instruction> instLst = new ArrayList<Instruction>() ;
331 InstructionBuilder ib = new InstructionBuilder() ;
333 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder().build());
334 ib.setKey(new InstructionKey(1)) ;
336 tableFeatureProperty.setTableFeaturePropType(
337 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder().setInstructions(
338 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build()).build() ) ;
342 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
343 tableFeatureProperty.setKey(keyValue) ;
344 tableFeatureProperty.setOrder(1) ;
346 return tableFeatureProperty ;
349 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
350 // To set the instructions miss -- "t7"
351 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
353 List<Instruction> instLst = new ArrayList<Instruction>() ;
354 InstructionBuilder ib1 = new InstructionBuilder() ;
356 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder().build());
357 ib1.setKey(new InstructionKey(1)) ;
359 InstructionBuilder ib2 = new InstructionBuilder() ;
361 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder().build());
362 ib2.setKey(new InstructionKey(2)) ;
364 tableFeatureProperty.setTableFeaturePropType(
365 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
366 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst).build()).build() ) ;
370 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
371 tableFeatureProperty.setKey(keyValue) ;
372 tableFeatureProperty.setOrder(1) ;
374 return tableFeatureProperty ;
377 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
379 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
381 List<Action> actionList = new ArrayList<Action>();
383 ActionBuilder abt1 = new ActionBuilder();
384 abt1.setAction(new CopyTtlOutCaseBuilder().build());
385 actionList.add(abt1.build());
387 ActionBuilder abt2 = new ActionBuilder();
388 abt2.setAction(new PopVlanActionCaseBuilder().build());
389 actionList.add(abt2.build());
391 tableFeatureProperty.setTableFeaturePropType(
392 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder()
393 .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder().setAction(actionList).build()).build()) ;
395 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
396 tableFeatureProperty.setKey(keyValue) ;
397 tableFeatureProperty.setOrder(1) ;
399 return tableFeatureProperty ;
402 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
404 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
406 List<Action> actionList = new ArrayList<Action>();
408 ActionBuilder abt1 = new ActionBuilder();
409 abt1.setAction(new CopyTtlInCaseBuilder().build());
410 actionList.add(abt1.build());
412 ActionBuilder abt2 = new ActionBuilder();
413 abt2.setAction(new PushPbbActionCaseBuilder().build());
414 actionList.add(abt2.build());
416 tableFeatureProperty.setTableFeaturePropType(
417 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder()
418 .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder().setAction(actionList).build()).build()) ;
420 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
421 tableFeatureProperty.setKey(keyValue) ;
422 tableFeatureProperty.setOrder(1) ;
424 return tableFeatureProperty ;
426 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
428 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
431 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
432 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder() ;
433 setFieldMatchBld.setHasMask(false) ;
434 setFieldMatchBld.setMatchType(MplsLabel.class) ;
437 setFieldMatch.add(setFieldMatchBld.build()) ;
438 MatchBuilder matchBld = new MatchBuilder() ;
439 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
440 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
441 matchBld.setMatchSetfield(matchSetfieldBld.build()) ;
443 tableFeatureProperty.setTableFeaturePropType(matchBld.build()) ;
444 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
445 tableFeatureProperty.setKey(keyValue) ;
446 tableFeatureProperty.setOrder(1) ;
448 return tableFeatureProperty ;
452 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
454 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
456 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
457 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
458 setFieldMatchBld1.setHasMask(false) ;
459 setFieldMatchBld1.setMatchType(MplsLabel.class) ;
461 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
462 setFieldMatchBld2.setHasMask(true) ;
463 setFieldMatchBld2.setMatchType(MplsBos.class) ;
465 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
466 setFieldMatchBld3.setHasMask(true) ;
467 setFieldMatchBld3.setMatchType(EthDst.class) ;
469 setFieldMatch.add(setFieldMatchBld1.build()) ;
470 setFieldMatch.add(setFieldMatchBld2.build()) ;
471 setFieldMatch.add(setFieldMatchBld3.build()) ;
473 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder() ;
474 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
475 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder();
476 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
477 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
480 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
481 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
482 tableFeatureProperty.setKey(keyValue) ;
483 tableFeatureProperty.setOrder(1) ;
485 return tableFeatureProperty ;
488 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
490 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
492 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
493 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
494 setFieldMatchBld1.setHasMask(false) ;
495 setFieldMatchBld1.setMatchType(EthSrc.class) ;
497 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
498 setFieldMatchBld2.setHasMask(true) ;
499 setFieldMatchBld2.setMatchType(InPort.class) ;
501 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
502 setFieldMatchBld3.setHasMask(true) ;
503 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
505 setFieldMatch.add(setFieldMatchBld1.build()) ;
506 setFieldMatch.add(setFieldMatchBld2.build()) ;
507 setFieldMatch.add(setFieldMatchBld3.build()) ;
509 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder() ;
510 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
511 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
512 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
513 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build()) ;
515 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
516 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
517 tableFeatureProperty.setKey(keyValue) ;
518 tableFeatureProperty.setOrder(1) ;
520 return tableFeatureProperty ;
523 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
525 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
527 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
528 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
529 setFieldMatchBld1.setHasMask(false) ;
530 setFieldMatchBld1.setMatchType(ArpOp.class) ;
532 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
533 setFieldMatchBld2.setHasMask(true) ;
534 setFieldMatchBld2.setMatchType(InPort.class) ;
536 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
537 setFieldMatchBld3.setHasMask(true) ;
538 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
540 setFieldMatch.add(setFieldMatchBld1.build()) ;
541 setFieldMatch.add(setFieldMatchBld2.build()) ;
542 setFieldMatch.add(setFieldMatchBld3.build()) ;
544 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
545 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
546 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder();
547 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
548 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build()) ;
550 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build()) ;
551 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
552 tableFeatureProperty.setKey(keyValue) ;
553 tableFeatureProperty.setOrder(1) ;
555 return tableFeatureProperty ;
558 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
560 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
562 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
563 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
564 setFieldMatchBld1.setHasMask(false) ;
565 setFieldMatchBld1.setMatchType(ArpOp.class) ;
567 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
568 setFieldMatchBld2.setHasMask(true) ;
569 setFieldMatchBld2.setMatchType(InPort.class) ;
571 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
572 setFieldMatchBld3.setHasMask(true) ;
573 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
575 setFieldMatch.add(setFieldMatchBld1.build()) ;
576 setFieldMatch.add(setFieldMatchBld2.build()) ;
577 setFieldMatch.add(setFieldMatchBld3.build()) ;
579 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder() ;
580 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
581 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
582 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
583 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build()) ;
585 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build()) ;
586 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
587 tableFeatureProperty.setKey(keyValue) ;
588 tableFeatureProperty.setOrder(1) ;
590 return tableFeatureProperty ;
593 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
595 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
597 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
598 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
599 setFieldMatchBld1.setHasMask(false) ;
600 setFieldMatchBld1.setMatchType(ArpOp.class) ;
602 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
603 setFieldMatchBld2.setHasMask(true) ;
604 setFieldMatchBld2.setMatchType(InPort.class) ;
607 setFieldMatch.add(setFieldMatchBld1.build()) ;
608 setFieldMatch.add(setFieldMatchBld2.build()) ;
610 WildcardsBuilder wildCardsBld = new WildcardsBuilder() ;
611 WildcardSetfieldBuilder wildcardsBuilder =
612 new WildcardSetfieldBuilder();
613 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
614 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build()) ;
616 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build()) ;
617 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
618 tableFeatureProperty.setKey(keyValue) ;
619 tableFeatureProperty.setOrder(1) ;
621 return tableFeatureProperty ;
625 private void writeTable(CommandInterpreter ci, Table table) {
626 DataModification modification = dataBrokerService.beginTransaction();
628 InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
629 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
630 child(Table.class, new TableKey(table.getId())).build() ;
633 modification.putOperationalData(nodeToInstanceId(testNode), testNode);
634 modification.putOperationalData(path1, table);
635 modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
636 modification.putConfigurationData(path1, table);
637 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
639 RpcResult<TransactionStatus> result = commitFuture.get();
640 TransactionStatus status = result.getResult();
641 ci.println("Status of Table Data Loaded Transaction: " + status);
643 } catch (InterruptedException e) {
644 // TODO Auto-generated catch block
646 } catch (ExecutionException e) {
647 // TODO Auto-generated catch block
652 public void _modifyTable(CommandInterpreter ci) {
653 String nref = ci.nextArgument();
654 ci.println( " Table Command Provider modify" ) ;
657 ci.println("test node added");
660 ci.println("User node added" + nref);
661 createUserNode(nref);
663 String tableFeatureType = ci.nextArgument() ;
664 TableBuilder table = createTestTable(tableFeatureType);
666 writeTable(ci, table.build());
670 public String getHelp() {
671 StringBuffer help = new StringBuffer();
672 help.append("---FRM MD-SAL Table test module---\n");
673 help.append("\t modifyTable <node id> - node ref\n");
675 return help.toString();