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.FutureCallback;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import java.math.BigInteger;
14 import java.util.ArrayList;
15 import java.util.Arrays;
16 import java.util.List;
17 import org.eclipse.osgi.framework.console.CommandInterpreter;
18 import org.eclipse.osgi.framework.console.CommandProvider;
19 import org.opendaylight.mdsal.binding.api.DataBroker;
20 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
21 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
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.TableFeaturePropertiesKey;
67 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
68 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
69 import org.opendaylight.yangtools.yang.common.Uint8;
70 import org.osgi.framework.BundleContext;
72 @SuppressWarnings("checkstyle:MethodName")
73 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
75 private final DataBroker dataBroker;
76 private final BundleContext ctx;
77 private Node testNode;
79 public OpenflowpluginTableFeaturesTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
80 this.dataBroker = dataBroker;
85 ctx.registerService(CommandProvider.class.getName(), this, null);
87 // createTestTableFeatures();
90 private void createUserNode(String nodeRef) {
91 NodeBuilder builder = new NodeBuilder();
92 builder.setId(new NodeId(nodeRef));
93 builder.withKey(new NodeKey(builder.getId()));
94 testNode = builder.build();
97 private void createTestNode() {
98 NodeBuilder builder = new NodeBuilder();
99 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
100 builder.withKey(new NodeKey(builder.getId()));
101 testNode = builder.build();
104 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
105 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
108 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
110 String tableFeatureType = tableFeatureTypeArg;
111 if (tableFeatureType == null) {
112 tableFeatureType = "t1";
115 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
116 // Sample data , committing to DataStore
117 if (!tableFeatureType.equals("t1")) {
120 tableFeature.setTableId((short) 0);
121 tableFeature.setName("Table 0");
124 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
125 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
126 tableFeature.setMaxEntries(10000L);
128 tableFeature.setConfig(new TableConfig(false));
130 List<TableFeatureProperties> properties = new ArrayList<>();
133 switch (tableFeatureType) {
135 //To set the ApplyActionsMiss
136 properties.add(createApplyActionsMissTblFeatureProp().build());
139 // To set the Next Table
140 properties.add(createNextTblFeatureProp().build());
143 // To set the Next Table Miss
144 properties.add(createNextTableMissTblFeatureProp().build());
147 //To set the ApplyActions
148 properties.add(createApplyActionsTblFeatureProp().build());
151 // To set the instructions
152 properties.add(createInstructionsTblFeatureProp().build());
155 // To set the instructions miss
156 properties.add(createInstructionsMissTblFeatureProp().build());
159 // To set the write actions
160 properties.add(createWriteActionsTblFeatureProp().build());
163 // To set the write actions miss
164 properties.add(createWriteActionsMissTblFeatureProp().build());
167 // To set the match field
168 properties.add(createMatchFieldTblFeatureProp().build());
171 // To set the write set-field
172 properties.add(createWriteSetFieldTblFeatureProp().build());
175 // To set the write set-field miss
176 properties.add(createWriteSetFieldMissTblFeatureProp().build());
179 // To set the apply set field
180 properties.add(createApplySetFieldTblFeatureProp().build());
183 // To set the apply set field miss
184 properties.add(createApplySetFieldMissTblFeatureProp().build());
187 // To set the wildcards set field match
188 properties.add(createWildCardsTblFeatureProp().build());
195 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
196 propertyBld.setTableFeatureProperties(properties);
197 tableFeature.setTableProperties(propertyBld.build());
202 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
203 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
205 //To set the ApplyActionsMiss
206 List<Action> actionList = new ArrayList<>();
207 ActionBuilder ab = new ActionBuilder();
209 ab.setAction(new PopMplsActionCaseBuilder().build());
210 actionList.add(ab.build());
212 tableFeatureProperty.setTableFeaturePropType(
213 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
214 .feature.prop.type.ApplyActionsMissBuilder()
215 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
217 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
218 tableFeatureProperty.withKey(keyValue);
219 tableFeatureProperty.setOrder(1);
221 return tableFeatureProperty;
225 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
226 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
227 List<Action> actionListt5 = new ArrayList<>();
228 ActionBuilder abt5 = new ActionBuilder();
230 abt5.setAction(new PopMplsActionCaseBuilder().build());
231 actionListt5.add(abt5.build());
233 tableFeatureProperty.setTableFeaturePropType(
234 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
235 .feature.prop.type.ApplyActionsBuilder()
236 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
238 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
239 tableFeatureProperty.withKey(keyValue);
240 tableFeatureProperty.setOrder(1);
242 return tableFeatureProperty;
245 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
246 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
247 List<Uint8> nextTblIds = Arrays.asList(Uint8.valueOf(2), Uint8.valueOf(3));
248 NextTableBuilder nextTblBld = new NextTableBuilder();
250 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
251 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
253 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
254 tableFeatureProperty.withKey(keyValue);
255 tableFeatureProperty.setOrder(1);
257 return tableFeatureProperty;
260 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
261 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
262 List<Uint8> nextTblMissIds = Arrays.asList(Uint8.valueOf(23), Uint8.valueOf(24), Uint8.valueOf(25),
263 Uint8.valueOf(27), Uint8.valueOf(28), Uint8.valueOf(29), Uint8.valueOf(30));
264 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder();
266 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build());
267 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build());
269 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
270 tableFeatureProperty.withKey(keyValue);
271 tableFeatureProperty.setOrder(1);
273 return tableFeatureProperty;
277 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
278 List<Instruction> instLst = new ArrayList<>();
279 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
280 tableFeatureProperty.setTableFeaturePropType(
281 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
282 .feature.prop.type.InstructionsBuilder().setInstructions(
283 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
284 .table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build())
288 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
289 tableFeatureProperty.withKey(keyValue);
290 tableFeatureProperty.setOrder(1);
292 return tableFeatureProperty;
295 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
296 // To set the instructions miss -- "t7"
298 List<Instruction> instLst = new ArrayList<>();
299 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
300 tableFeatureProperty.setTableFeaturePropType(
301 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
302 .feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
303 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
304 .table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst)
308 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
309 tableFeatureProperty.withKey(keyValue);
310 tableFeatureProperty.setOrder(1);
312 return tableFeatureProperty;
315 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
318 List<Action> actionList = new ArrayList<>();
320 ActionBuilder abt1 = new ActionBuilder();
321 abt1.setAction(new CopyTtlOutCaseBuilder().build());
322 actionList.add(abt1.build());
324 ActionBuilder abt2 = new ActionBuilder();
325 abt2.setAction(new PopVlanActionCaseBuilder().build());
326 actionList.add(abt2.build());
328 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
329 tableFeatureProperty.setTableFeaturePropType(
330 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
331 .feature.prop.type.WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn
332 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
333 .WriteActionsBuilder().setAction(actionList).build()).build());
335 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
336 tableFeatureProperty.withKey(keyValue);
337 tableFeatureProperty.setOrder(1);
339 return tableFeatureProperty;
342 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
344 List<Action> actionList = new ArrayList<>();
346 ActionBuilder abt1 = new ActionBuilder();
347 abt1.setAction(new CopyTtlInCaseBuilder().build());
348 actionList.add(abt1.build());
350 ActionBuilder abt2 = new ActionBuilder();
351 abt2.setAction(new PushPbbActionCaseBuilder().build());
352 actionList.add(abt2.build());
354 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
355 tableFeatureProperty.setTableFeaturePropType(
356 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
357 .feature.prop.type.WriteActionsMissBuilder().setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn
358 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
359 .miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
361 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
362 tableFeatureProperty.withKey(keyValue);
363 tableFeatureProperty.setOrder(1);
365 return tableFeatureProperty;
368 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
371 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
372 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
373 setFieldMatchBld.setHasMask(false);
374 setFieldMatchBld.setMatchType(MplsLabel.class);
377 setFieldMatch.add(setFieldMatchBld.build());
378 MatchBuilder matchBld = new MatchBuilder();
379 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
380 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
381 matchBld.setMatchSetfield(matchSetfieldBld.build());
383 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
384 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
385 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
386 tableFeatureProperty.withKey(keyValue);
387 tableFeatureProperty.setOrder(1);
389 return tableFeatureProperty;
393 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
396 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
397 setFieldMatchBld1.setHasMask(false);
398 setFieldMatchBld1.setMatchType(MplsLabel.class);
400 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
401 setFieldMatchBld2.setHasMask(true);
402 setFieldMatchBld2.setMatchType(MplsBos.class);
404 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
405 setFieldMatchBld3.setHasMask(true);
406 setFieldMatchBld3.setMatchType(EthDst.class);
408 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
409 setFieldMatch.add(setFieldMatchBld1.build());
410 setFieldMatch.add(setFieldMatchBld2.build());
411 setFieldMatch.add(setFieldMatchBld3.build());
413 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
414 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
415 .type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
416 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
417 .feature.prop.type.write.setfield.WriteSetfieldBuilder();
418 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
419 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
421 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
422 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
423 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
424 tableFeatureProperty.withKey(keyValue);
425 tableFeatureProperty.setOrder(1);
427 return tableFeatureProperty;
430 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
433 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
434 setFieldMatchBld1.setHasMask(false);
435 setFieldMatchBld1.setMatchType(EthSrc.class);
437 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
438 setFieldMatchBld2.setHasMask(true);
439 setFieldMatchBld2.setMatchType(InPort.class);
441 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
442 setFieldMatchBld3.setHasMask(true);
443 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
445 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
446 setFieldMatch.add(setFieldMatchBld1.build());
447 setFieldMatch.add(setFieldMatchBld2.build());
448 setFieldMatch.add(setFieldMatchBld3.build());
450 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
451 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
452 .type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
453 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
454 .feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
455 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
456 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
458 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
459 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
460 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
461 tableFeatureProperty.withKey(keyValue);
462 tableFeatureProperty.setOrder(1);
464 return tableFeatureProperty;
467 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
470 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
471 setFieldMatchBld1.setHasMask(false);
472 setFieldMatchBld1.setMatchType(ArpOp.class);
474 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
475 setFieldMatchBld2.setHasMask(true);
476 setFieldMatchBld2.setMatchType(InPort.class);
478 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
479 setFieldMatchBld3.setHasMask(true);
480 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
482 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
483 setFieldMatch.add(setFieldMatchBld1.build());
484 setFieldMatch.add(setFieldMatchBld2.build());
485 setFieldMatch.add(setFieldMatchBld3.build());
487 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
488 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
489 .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
490 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
491 .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
492 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
493 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
495 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
496 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
497 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
498 tableFeatureProperty.withKey(keyValue);
499 tableFeatureProperty.setOrder(1);
501 return tableFeatureProperty;
504 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
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 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
520 setFieldMatch.add(setFieldMatchBld1.build());
521 setFieldMatch.add(setFieldMatchBld2.build());
522 setFieldMatch.add(setFieldMatchBld3.build());
524 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
525 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
526 .type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
527 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
528 .feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
529 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
530 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
532 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
533 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
534 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
535 tableFeatureProperty.withKey(keyValue);
536 tableFeatureProperty.setOrder(1);
538 return tableFeatureProperty;
541 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
544 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
545 setFieldMatchBld1.setHasMask(false);
546 setFieldMatchBld1.setMatchType(ArpOp.class);
548 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
549 setFieldMatchBld2.setHasMask(true);
550 setFieldMatchBld2.setMatchType(InPort.class);
552 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
553 setFieldMatch.add(setFieldMatchBld1.build());
554 setFieldMatch.add(setFieldMatchBld2.build());
556 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
557 WildcardSetfieldBuilder wildcardsBuilder =
558 new WildcardSetfieldBuilder();
559 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
560 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
562 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
563 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
564 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
565 tableFeatureProperty.withKey(keyValue);
566 tableFeatureProperty.setOrder(1);
568 return tableFeatureProperty;
571 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
572 ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
574 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
575 .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
576 .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
578 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode);
579 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures);
580 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
582 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures);
583 modification.commit().addCallback(new FutureCallback<Object>() {
585 public void onSuccess(Object notUsed) {
586 ci.println("Status of Group Data Loaded Transaction: success.");
590 public void onFailure(Throwable throwable) {
591 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
593 }, MoreExecutors.directExecutor());
596 public void _modifyTable(CommandInterpreter ci) {
597 String nref = ci.nextArgument();
598 ci.println(" Table Command Provider modify");
601 ci.println("test node added");
604 ci.println("User node added" + nref);
605 createUserNode(nref);
607 String tableFeatureType = ci.nextArgument();
608 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
610 writeTableFeatures(ci, tableFeaturesBld.build());
614 public String getHelp() {
615 StringBuilder help = new StringBuilder();
616 help.append("---FRM MD-SAL Table test module---\n");
617 help.append("\t modifyTable <node id> - node ref\n");
619 return help.toString();