1 package org.opendaylight.openflowplugin.test;
3 import java.math.BigInteger;
4 import java.util.ArrayList;
5 import java.util.Arrays;
7 import java.util.concurrent.ExecutionException;
8 import java.util.concurrent.Future;
10 import org.eclipse.osgi.framework.console.CommandInterpreter;
11 import org.eclipse.osgi.framework.console.CommandProvider;
12 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
13 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder ;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder ;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc;
86 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
87 import org.opendaylight.yangtools.yang.common.RpcResult;
88 import org.osgi.framework.BundleContext;
91 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
93 private DataBrokerService dataBrokerService;
94 private ProviderContext pc;
95 private final BundleContext ctx;
96 private Table testTable;
97 private Node testNode;
98 private final String originalTableName = "Foo";
99 private final String updatedTableName = "Bar";
101 public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
105 public void onSessionInitiated(ProviderContext session) {
107 dataBrokerService = session.getSALService(DataBrokerService.class);
108 ctx.registerService(CommandProvider.class.getName(), this, null);
110 // createTestTable();
113 private void createUserNode(String nodeRef) {
114 NodeBuilder builder = new NodeBuilder();
115 builder.setId(new NodeId(nodeRef));
116 builder.setKey(new NodeKey(builder.getId()));
117 testNode = builder.build();
120 private void createTestNode() {
121 NodeBuilder builder = new NodeBuilder();
122 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
123 builder.setKey(new NodeKey(builder.getId()));
124 testNode = builder.build();
127 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
128 return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
131 private TableBuilder createTestTable(String tableFeatureTypeArg) {
133 String tableFeatureType = tableFeatureTypeArg;
134 if (tableFeatureType == null) {
135 tableFeatureType = "t1";
137 // Sample data , committing to DataStore
138 DataModification modification = dataBrokerService.beginTransaction();
140 TableKey key = new TableKey(id) ;
142 TableBuilder table = new TableBuilder();
143 table.setId((short)12) ;
148 List<TableFeatures> ofTablefeatures = new ArrayList<TableFeatures>() ;
150 // Skip this to send empty table features
151 if( ! tableFeatureType.equals( "t1")) {
154 TableFeaturesBuilder tableFeature1 = new TableFeaturesBuilder() ;
155 tableFeature1.setTableId(new Short((short)0));
156 tableFeature1.setName("Table 0");
159 tableFeature1.setMetadataMatch((new BigInteger("10", 10)));
160 tableFeature1.setMetadataWrite((new BigInteger("10", 10)));
161 tableFeature1.setMaxEntries(new Long(10000)) ;
163 tableFeature1.setConfig(new TableConfig(false));
165 List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>() ;
168 switch( tableFeatureType) {
170 //To set the ApplyActionsMiss
171 properties.add(createApplyActionsMissTblFeatureProp().build()) ;
174 // To set the Next Table
175 properties.add(createNextTblFeatureProp().build()) ;
178 // To set the Next Table Miss
179 properties.add(createNextTableMissTblFeatureProp().build()) ;
182 //To set the ApplyActions
183 properties.add(createApplyActionsTblFeatureProp().build()) ;
186 // To set the instructions
187 properties.add(createInstructionsTblFeatureProp().build());
190 // To set the instructions miss
191 properties.add(createInstructionsMissTblFeatureProp().build());
194 // To set the write actions
195 properties.add(createWriteActionsTblFeatureProp().build()) ;
198 // To set the write actions miss
199 properties.add(createWriteActionsMissTblFeatureProp().build()) ;
202 // To set the match field
203 properties.add(createMatchFieldTblFeatureProp().build()) ;
206 // To set the write set-field
207 properties.add( createWriteSetFieldTblFeatureProp().build()) ;
210 // To set the write set-field miss
211 properties.add( createWriteSetFieldMissTblFeatureProp().build()) ;
214 // To set the apply set field
215 properties.add( createApplySetFieldTblFeatureProp().build()) ;
218 // To set the apply set field miss
219 properties.add( createApplySetFieldMissTblFeatureProp().build()) ;
222 // To set the wildcards set field match
223 properties.add( createWildCardsTblFeatureProp().build()) ;
228 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder() ;
229 propertyBld.setTableFeatureProperties(properties) ;
230 tableFeature1.setTableProperties(propertyBld.build());
233 ofTablefeatures.add(tableFeature1.build()) ;
236 table.setTableFeatures(ofTablefeatures) ;
238 testTable = table.build();
242 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
243 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
245 //To set the ApplyActionsMiss
246 List<Action> actionList = new ArrayList<Action>();
247 ActionBuilder ab = new ActionBuilder();
249 ab.setAction(new PopMplsActionCaseBuilder().build());
250 actionList.add(ab.build());
252 tableFeatureProperty.setTableFeaturePropType(
253 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder()
254 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build()) ;
256 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
257 tableFeatureProperty.setKey(keyValue) ;
258 tableFeatureProperty.setOrder(1) ;
260 return tableFeatureProperty ;
264 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
265 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
266 List<Action> actionListt5 = new ArrayList<Action>();
267 ActionBuilder abt5 = new ActionBuilder();
269 abt5.setAction(new PopMplsActionCaseBuilder().build());
270 actionListt5.add(abt5.build());
272 tableFeatureProperty.setTableFeaturePropType(
273 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder()
274 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build()) ;
276 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
277 tableFeatureProperty.setKey(keyValue) ;
278 tableFeatureProperty.setOrder(1) ;
280 return tableFeatureProperty ;
283 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
284 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
285 List<Short> nextTblIds = Arrays.asList(new Short[] { 2, 3} );
286 NextTableBuilder nextTblBld = new NextTableBuilder() ;
288 nextTblBld.setTables( new TablesBuilder().setTableIds(nextTblIds).build()) ;
289 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build() ) ;
291 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
292 tableFeatureProperty.setKey(keyValue) ;
293 tableFeatureProperty.setOrder(1) ;
295 return tableFeatureProperty ;
298 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
299 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
300 List<Short> nextTblMissIds = Arrays.asList( new Short[] { 23, 24, 25, 27, 28, 29 , 30 } );
301 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder() ;
303 nextTblMissBld.setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesBuilder().setTableIds(nextTblMissIds).build()) ;
304 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build() ) ;
306 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
307 tableFeatureProperty.setKey(keyValue) ;
308 tableFeatureProperty.setOrder(1) ;
310 return tableFeatureProperty ;
315 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
316 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
318 List<Instruction> instLst = new ArrayList<Instruction>() ;
319 InstructionBuilder ib = new InstructionBuilder() ;
321 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder().build());
322 ib.setKey(new InstructionKey(1)) ;
324 tableFeatureProperty.setTableFeaturePropType(
325 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder().setInstructions(
326 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() ) ;
330 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
331 tableFeatureProperty.setKey(keyValue) ;
332 tableFeatureProperty.setOrder(1) ;
334 return tableFeatureProperty ;
337 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
338 // To set the instructions miss -- "t7"
339 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
341 List<Instruction> instLst = new ArrayList<Instruction>() ;
342 InstructionBuilder ib1 = new InstructionBuilder() ;
344 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder().build());
345 ib1.setKey(new InstructionKey(1)) ;
347 InstructionBuilder ib2 = new InstructionBuilder() ;
349 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder().build());
350 ib2.setKey(new InstructionKey(2)) ;
352 tableFeatureProperty.setTableFeaturePropType(
353 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
354 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() ) ;
358 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
359 tableFeatureProperty.setKey(keyValue) ;
360 tableFeatureProperty.setOrder(1) ;
362 return tableFeatureProperty ;
365 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
367 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
369 List<Action> actionList = new ArrayList<Action>();
371 ActionBuilder abt1 = new ActionBuilder();
372 abt1.setAction(new CopyTtlOutCaseBuilder().build());
373 actionList.add(abt1.build());
375 ActionBuilder abt2 = new ActionBuilder();
376 abt2.setAction(new PopVlanActionCaseBuilder().build());
377 actionList.add(abt2.build());
379 tableFeatureProperty.setTableFeaturePropType(
380 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder()
381 .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()) ;
383 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
384 tableFeatureProperty.setKey(keyValue) ;
385 tableFeatureProperty.setOrder(1) ;
387 return tableFeatureProperty ;
390 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
392 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
394 List<Action> actionList = new ArrayList<Action>();
396 ActionBuilder abt1 = new ActionBuilder();
397 abt1.setAction(new CopyTtlInCaseBuilder().build());
398 actionList.add(abt1.build());
400 ActionBuilder abt2 = new ActionBuilder();
401 abt2.setAction(new PushPbbActionCaseBuilder().build());
402 actionList.add(abt2.build());
404 tableFeatureProperty.setTableFeaturePropType(
405 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder()
406 .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()) ;
408 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
409 tableFeatureProperty.setKey(keyValue) ;
410 tableFeatureProperty.setOrder(1) ;
412 return tableFeatureProperty ;
414 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
416 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
419 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
420 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder() ;
421 setFieldMatchBld.setHasMask(false) ;
422 setFieldMatchBld.setMatchType(MplsLabel.class) ;
425 setFieldMatch.add(setFieldMatchBld.build()) ;
426 MatchBuilder matchBld = new MatchBuilder() ;
427 matchBld.setSetFieldMatch(setFieldMatch) ;
429 tableFeatureProperty.setTableFeaturePropType(matchBld.build()) ;
430 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
431 tableFeatureProperty.setKey(keyValue) ;
432 tableFeatureProperty.setOrder(1) ;
434 return tableFeatureProperty ;
438 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
440 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
442 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
443 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
444 setFieldMatchBld1.setHasMask(false) ;
445 setFieldMatchBld1.setMatchType(MplsLabel.class) ;
447 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
448 setFieldMatchBld2.setHasMask(true) ;
449 setFieldMatchBld2.setMatchType(MplsBos.class) ;
451 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
452 setFieldMatchBld3.setHasMask(true) ;
453 setFieldMatchBld3.setMatchType(EthDst.class) ;
455 setFieldMatch.add(setFieldMatchBld1.build()) ;
456 setFieldMatch.add(setFieldMatchBld2.build()) ;
457 setFieldMatch.add(setFieldMatchBld3.build()) ;
459 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder() ;
460 writeSetfieldBld.setSetFieldMatch(setFieldMatch) ;
462 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
463 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
464 tableFeatureProperty.setKey(keyValue) ;
465 tableFeatureProperty.setOrder(1) ;
467 return tableFeatureProperty ;
470 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
472 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
474 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
475 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
476 setFieldMatchBld1.setHasMask(false) ;
477 setFieldMatchBld1.setMatchType(EthSrc.class) ;
479 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
480 setFieldMatchBld2.setHasMask(true) ;
481 setFieldMatchBld2.setMatchType(InPort.class) ;
483 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
484 setFieldMatchBld3.setHasMask(true) ;
485 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
487 setFieldMatch.add(setFieldMatchBld1.build()) ;
488 setFieldMatch.add(setFieldMatchBld2.build()) ;
489 setFieldMatch.add(setFieldMatchBld3.build()) ;
491 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder() ;
492 writeSetfieldBld.setSetFieldMatch(setFieldMatch) ;
494 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
495 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
496 tableFeatureProperty.setKey(keyValue) ;
497 tableFeatureProperty.setOrder(1) ;
499 return tableFeatureProperty ;
502 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
504 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
506 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
507 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
508 setFieldMatchBld1.setHasMask(false) ;
509 setFieldMatchBld1.setMatchType(ArpOp.class) ;
511 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
512 setFieldMatchBld2.setHasMask(true) ;
513 setFieldMatchBld2.setMatchType(InPort.class) ;
515 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
516 setFieldMatchBld3.setHasMask(true) ;
517 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
519 setFieldMatch.add(setFieldMatchBld1.build()) ;
520 setFieldMatch.add(setFieldMatchBld2.build()) ;
521 setFieldMatch.add(setFieldMatchBld3.build()) ;
523 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder() ;
524 applySetfieldBld.setSetFieldMatch(setFieldMatch) ;
526 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build()) ;
527 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
528 tableFeatureProperty.setKey(keyValue) ;
529 tableFeatureProperty.setOrder(1) ;
531 return tableFeatureProperty ;
534 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
536 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
538 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
539 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
540 setFieldMatchBld1.setHasMask(false) ;
541 setFieldMatchBld1.setMatchType(ArpOp.class) ;
543 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
544 setFieldMatchBld2.setHasMask(true) ;
545 setFieldMatchBld2.setMatchType(InPort.class) ;
547 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
548 setFieldMatchBld3.setHasMask(true) ;
549 setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
551 setFieldMatch.add(setFieldMatchBld1.build()) ;
552 setFieldMatch.add(setFieldMatchBld2.build()) ;
553 setFieldMatch.add(setFieldMatchBld3.build()) ;
555 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder() ;
556 applySetfieldMissBld.setSetFieldMatch(setFieldMatch) ;
558 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build()) ;
559 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
560 tableFeatureProperty.setKey(keyValue) ;
561 tableFeatureProperty.setOrder(1) ;
563 return tableFeatureProperty ;
566 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
568 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
570 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
571 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
572 setFieldMatchBld1.setHasMask(false) ;
573 setFieldMatchBld1.setMatchType(ArpOp.class) ;
575 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
576 setFieldMatchBld2.setHasMask(true) ;
577 setFieldMatchBld2.setMatchType(InPort.class) ;
580 setFieldMatch.add(setFieldMatchBld1.build()) ;
581 setFieldMatch.add(setFieldMatchBld2.build()) ;
583 WildcardsBuilder wildCardsBld = new WildcardsBuilder() ;
584 wildCardsBld.setSetFieldMatch(setFieldMatch) ;
586 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build()) ;
587 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
588 tableFeatureProperty.setKey(keyValue) ;
589 tableFeatureProperty.setOrder(1) ;
591 return tableFeatureProperty ;
595 private void writeTable(CommandInterpreter ci, Table table) {
596 DataModification modification = dataBrokerService.beginTransaction();
598 InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
599 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
600 child(Table.class, new TableKey(table.getId())).build() ;
603 modification.putOperationalData(nodeToInstanceId(testNode), testNode);
604 modification.putOperationalData(path1, table);
605 modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
606 modification.putConfigurationData(path1, table);
607 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
609 RpcResult<TransactionStatus> result = commitFuture.get();
610 TransactionStatus status = result.getResult();
611 ci.println("Status of Table Data Loaded Transaction: " + status);
613 } catch (InterruptedException e) {
614 // TODO Auto-generated catch block
616 } catch (ExecutionException e) {
617 // TODO Auto-generated catch block
622 public void _modifyTable(CommandInterpreter ci) {
623 String nref = ci.nextArgument();
624 ci.println( " Table Command Provider modify" ) ;
627 ci.println("test node added");
630 ci.println("User node added" + nref);
631 createUserNode(nref);
633 String tableFeatureType = ci.nextArgument() ;
634 TableBuilder table = createTestTable(tableFeatureType);
636 writeTable(ci, table.build());
640 public String getHelp() {
641 StringBuffer help = new StringBuffer();
642 help.append("---FRM MD-SAL Table test module---\n");
643 help.append("\t modifyTable <node id> - node ref\n");
645 return help.toString();