2 * Copyright (c) 2014, 2015 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 package org.opendaylight.openflowplugin.test;
10 import com.google.common.base.Preconditions;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import java.math.BigInteger;
16 import java.util.ArrayList;
17 import java.util.Arrays;
18 import java.util.List;
19 import org.eclipse.osgi.framework.console.CommandInterpreter;
20 import org.eclipse.osgi.framework.console.CommandProvider;
21 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
22 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
23 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
24 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
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;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
72 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
73 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
74 import org.osgi.framework.BundleContext;
76 @SuppressWarnings("checkstyle:MethodName")
77 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
79 private final DataBroker dataBroker;
80 private final BundleContext ctx;
81 private Node testNode;
83 public OpenflowpluginTableFeaturesTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
84 this.dataBroker = dataBroker;
89 ctx.registerService(CommandProvider.class.getName(), this, null);
91 // createTestTableFeatures();
94 private void createUserNode(String nodeRef) {
95 NodeBuilder builder = new NodeBuilder();
96 builder.setId(new NodeId(nodeRef));
97 builder.withKey(new NodeKey(builder.getId()));
98 testNode = builder.build();
101 private void createTestNode() {
102 NodeBuilder builder = new NodeBuilder();
103 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
104 builder.withKey(new NodeKey(builder.getId()));
105 testNode = builder.build();
108 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
109 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
112 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
114 String tableFeatureType = tableFeatureTypeArg;
115 if (tableFeatureType == null) {
116 tableFeatureType = "t1";
119 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
120 // Sample data , committing to DataStore
121 if (!tableFeatureType.equals("t1")) {
124 tableFeature.setTableId((short) 0);
125 tableFeature.setName("Table 0");
128 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
129 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
130 tableFeature.setMaxEntries(10000L);
132 tableFeature.setConfig(new TableConfig(false));
134 List<TableFeatureProperties> properties = new ArrayList<>();
137 switch (tableFeatureType) {
139 //To set the ApplyActionsMiss
140 properties.add(createApplyActionsMissTblFeatureProp().build());
143 // To set the Next Table
144 properties.add(createNextTblFeatureProp().build());
147 // To set the Next Table Miss
148 properties.add(createNextTableMissTblFeatureProp().build());
151 //To set the ApplyActions
152 properties.add(createApplyActionsTblFeatureProp().build());
155 // To set the instructions
156 properties.add(createInstructionsTblFeatureProp().build());
159 // To set the instructions miss
160 properties.add(createInstructionsMissTblFeatureProp().build());
163 // To set the write actions
164 properties.add(createWriteActionsTblFeatureProp().build());
167 // To set the write actions miss
168 properties.add(createWriteActionsMissTblFeatureProp().build());
171 // To set the match field
172 properties.add(createMatchFieldTblFeatureProp().build());
175 // To set the write set-field
176 properties.add(createWriteSetFieldTblFeatureProp().build());
179 // To set the write set-field miss
180 properties.add(createWriteSetFieldMissTblFeatureProp().build());
183 // To set the apply set field
184 properties.add(createApplySetFieldTblFeatureProp().build());
187 // To set the apply set field miss
188 properties.add(createApplySetFieldMissTblFeatureProp().build());
191 // To set the wildcards set field match
192 properties.add(createWildCardsTblFeatureProp().build());
199 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
200 propertyBld.setTableFeatureProperties(properties);
201 tableFeature.setTableProperties(propertyBld.build());
206 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
207 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
209 //To set the ApplyActionsMiss
210 List<Action> actionList = new ArrayList<>();
211 ActionBuilder ab = new ActionBuilder();
213 ab.setAction(new PopMplsActionCaseBuilder().build());
214 actionList.add(ab.build());
216 tableFeatureProperty.setTableFeaturePropType(
217 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
218 .feature.prop.type.ApplyActionsMissBuilder()
219 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
221 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
222 tableFeatureProperty.withKey(keyValue);
223 tableFeatureProperty.setOrder(1);
225 return tableFeatureProperty;
229 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
230 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
231 List<Action> actionListt5 = new ArrayList<>();
232 ActionBuilder abt5 = new ActionBuilder();
234 abt5.setAction(new PopMplsActionCaseBuilder().build());
235 actionListt5.add(abt5.build());
237 tableFeatureProperty.setTableFeaturePropType(
238 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
239 .feature.prop.type.ApplyActionsBuilder()
240 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
242 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
243 tableFeatureProperty.withKey(keyValue);
244 tableFeatureProperty.setOrder(1);
246 return tableFeatureProperty;
249 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
250 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
251 List<Short> nextTblIds = Arrays.asList(new Short[]{2, 3});
252 NextTableBuilder nextTblBld = new NextTableBuilder();
254 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
255 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
257 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
258 tableFeatureProperty.withKey(keyValue);
259 tableFeatureProperty.setOrder(1);
261 return tableFeatureProperty;
264 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
265 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
266 List<Short> nextTblMissIds = Arrays.asList(new Short[]{23, 24, 25, 27, 28, 29, 30});
267 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder();
269 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build());
270 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build());
272 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
273 tableFeatureProperty.withKey(keyValue);
274 tableFeatureProperty.setOrder(1);
276 return tableFeatureProperty;
280 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
281 InstructionBuilder ib = new InstructionBuilder();
283 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
284 .instruction.ApplyActionsCaseBuilder().build());
285 ib.withKey(new InstructionKey(1));
287 List<Instruction> instLst = new ArrayList<>();
288 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
289 tableFeatureProperty.setTableFeaturePropType(
290 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
291 .feature.prop.type.InstructionsBuilder().setInstructions(
292 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
293 .table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build())
297 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
298 tableFeatureProperty.withKey(keyValue);
299 tableFeatureProperty.setOrder(1);
301 return tableFeatureProperty;
304 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
305 // To set the instructions miss -- "t7"
307 InstructionBuilder ib1 = new InstructionBuilder();
309 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
310 .instruction.WriteMetadataCaseBuilder().build());
311 ib1.withKey(new InstructionKey(1));
313 InstructionBuilder ib2 = new InstructionBuilder();
315 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
316 .instruction.MeterCaseBuilder().build());
317 ib2.withKey(new InstructionKey(2));
319 List<Instruction> instLst = new ArrayList<>();
320 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
321 tableFeatureProperty.setTableFeaturePropType(
322 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
323 .feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
324 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
325 .table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst)
329 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
330 tableFeatureProperty.withKey(keyValue);
331 tableFeatureProperty.setOrder(1);
333 return tableFeatureProperty;
336 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
339 List<Action> actionList = new ArrayList<>();
341 ActionBuilder abt1 = new ActionBuilder();
342 abt1.setAction(new CopyTtlOutCaseBuilder().build());
343 actionList.add(abt1.build());
345 ActionBuilder abt2 = new ActionBuilder();
346 abt2.setAction(new PopVlanActionCaseBuilder().build());
347 actionList.add(abt2.build());
349 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
350 tableFeatureProperty.setTableFeaturePropType(
351 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
352 .feature.prop.type.WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn
353 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
354 .WriteActionsBuilder().setAction(actionList).build()).build());
356 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
357 tableFeatureProperty.withKey(keyValue);
358 tableFeatureProperty.setOrder(1);
360 return tableFeatureProperty;
363 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
365 List<Action> actionList = new ArrayList<>();
367 ActionBuilder abt1 = new ActionBuilder();
368 abt1.setAction(new CopyTtlInCaseBuilder().build());
369 actionList.add(abt1.build());
371 ActionBuilder abt2 = new ActionBuilder();
372 abt2.setAction(new PushPbbActionCaseBuilder().build());
373 actionList.add(abt2.build());
375 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
376 tableFeatureProperty.setTableFeaturePropType(
377 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
378 .feature.prop.type.WriteActionsMissBuilder().setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn
379 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
380 .miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
382 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
383 tableFeatureProperty.withKey(keyValue);
384 tableFeatureProperty.setOrder(1);
386 return tableFeatureProperty;
389 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
392 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
393 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
394 setFieldMatchBld.setHasMask(false);
395 setFieldMatchBld.setMatchType(MplsLabel.class);
398 setFieldMatch.add(setFieldMatchBld.build());
399 MatchBuilder matchBld = new MatchBuilder();
400 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
401 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
402 matchBld.setMatchSetfield(matchSetfieldBld.build());
404 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
405 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
406 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
407 tableFeatureProperty.withKey(keyValue);
408 tableFeatureProperty.setOrder(1);
410 return tableFeatureProperty;
414 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
417 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
418 setFieldMatchBld1.setHasMask(false);
419 setFieldMatchBld1.setMatchType(MplsLabel.class);
421 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
422 setFieldMatchBld2.setHasMask(true);
423 setFieldMatchBld2.setMatchType(MplsBos.class);
425 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
426 setFieldMatchBld3.setHasMask(true);
427 setFieldMatchBld3.setMatchType(EthDst.class);
429 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
430 setFieldMatch.add(setFieldMatchBld1.build());
431 setFieldMatch.add(setFieldMatchBld2.build());
432 setFieldMatch.add(setFieldMatchBld3.build());
434 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
435 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
436 .type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
437 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
438 .feature.prop.type.write.setfield.WriteSetfieldBuilder();
439 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
440 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
442 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
443 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
444 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
445 tableFeatureProperty.withKey(keyValue);
446 tableFeatureProperty.setOrder(1);
448 return tableFeatureProperty;
451 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
454 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
455 setFieldMatchBld1.setHasMask(false);
456 setFieldMatchBld1.setMatchType(EthSrc.class);
458 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
459 setFieldMatchBld2.setHasMask(true);
460 setFieldMatchBld2.setMatchType(InPort.class);
462 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
463 setFieldMatchBld3.setHasMask(true);
464 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
466 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
467 setFieldMatch.add(setFieldMatchBld1.build());
468 setFieldMatch.add(setFieldMatchBld2.build());
469 setFieldMatch.add(setFieldMatchBld3.build());
471 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
472 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
473 .type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
474 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
475 .feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
476 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
477 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
479 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
480 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
481 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
482 tableFeatureProperty.withKey(keyValue);
483 tableFeatureProperty.setOrder(1);
485 return tableFeatureProperty;
488 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
491 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
492 setFieldMatchBld1.setHasMask(false);
493 setFieldMatchBld1.setMatchType(ArpOp.class);
495 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
496 setFieldMatchBld2.setHasMask(true);
497 setFieldMatchBld2.setMatchType(InPort.class);
499 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
500 setFieldMatchBld3.setHasMask(true);
501 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
503 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
504 setFieldMatch.add(setFieldMatchBld1.build());
505 setFieldMatch.add(setFieldMatchBld2.build());
506 setFieldMatch.add(setFieldMatchBld3.build());
508 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
509 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
510 .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
511 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
512 .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
513 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
514 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
516 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
517 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
518 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
519 tableFeatureProperty.withKey(keyValue);
520 tableFeatureProperty.setOrder(1);
522 return tableFeatureProperty;
525 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
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 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
541 setFieldMatch.add(setFieldMatchBld1.build());
542 setFieldMatch.add(setFieldMatchBld2.build());
543 setFieldMatch.add(setFieldMatchBld3.build());
545 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
546 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
547 .type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
548 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
549 .feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
550 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
551 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
553 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
554 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
555 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
556 tableFeatureProperty.withKey(keyValue);
557 tableFeatureProperty.setOrder(1);
559 return tableFeatureProperty;
562 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
565 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
566 setFieldMatchBld1.setHasMask(false);
567 setFieldMatchBld1.setMatchType(ArpOp.class);
569 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
570 setFieldMatchBld2.setHasMask(true);
571 setFieldMatchBld2.setMatchType(InPort.class);
573 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
574 setFieldMatch.add(setFieldMatchBld1.build());
575 setFieldMatch.add(setFieldMatchBld2.build());
577 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
578 WildcardSetfieldBuilder wildcardsBuilder =
579 new WildcardSetfieldBuilder();
580 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
581 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
583 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
584 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
585 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
586 tableFeatureProperty.withKey(keyValue);
587 tableFeatureProperty.setOrder(1);
589 return tableFeatureProperty;
592 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
593 ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
595 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
596 .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
597 .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
599 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
600 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
601 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
602 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
603 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
604 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
606 public void onSuccess(Void notUsed) {
607 ci.println("Status of Group Data Loaded Transaction: success.");
611 public void onFailure(Throwable throwable) {
612 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
614 }, MoreExecutors.directExecutor());
617 public void _modifyTable(CommandInterpreter ci) {
618 String nref = ci.nextArgument();
619 ci.println(" Table Command Provider modify");
622 ci.println("test node added");
625 ci.println("User node added" + nref);
626 createUserNode(nref);
628 String tableFeatureType = ci.nextArgument();
629 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
631 writeTableFeatures(ci, tableFeaturesBld.build());
635 public String getHelp() {
636 StringBuilder help = new StringBuilder();
637 help.append("---FRM MD-SAL Table test module---\n");
638 help.append("\t modifyTable <node id> - node ref\n");
640 return help.toString();