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.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
61 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.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
73 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
74 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
75 import org.osgi.framework.BundleContext;
77 @SuppressWarnings("checkstyle:MethodName")
78 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
80 private DataBroker dataBroker;
81 private final BundleContext ctx;
82 private Node testNode;
84 public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
88 public void onSessionInitiated(ProviderContext session) {
89 dataBroker = session.getSALService(DataBroker.class);
90 ctx.registerService(CommandProvider.class.getName(), this, null);
92 // createTestTableFeatures();
95 private void createUserNode(String nodeRef) {
96 NodeBuilder builder = new NodeBuilder();
97 builder.setId(new NodeId(nodeRef));
98 builder.withKey(new NodeKey(builder.getId()));
99 testNode = builder.build();
102 private void createTestNode() {
103 NodeBuilder builder = new NodeBuilder();
104 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
105 builder.withKey(new NodeKey(builder.getId()));
106 testNode = builder.build();
109 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
110 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
113 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
115 String tableFeatureType = tableFeatureTypeArg;
116 if (tableFeatureType == null) {
117 tableFeatureType = "t1";
120 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
121 // Sample data , committing to DataStore
122 if (!tableFeatureType.equals("t1")) {
125 tableFeature.setTableId((short) 0);
126 tableFeature.setName("Table 0");
129 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
130 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
131 tableFeature.setMaxEntries(10000L);
133 tableFeature.setConfig(new TableConfig(false));
135 List<TableFeatureProperties> properties = new ArrayList<>();
138 switch (tableFeatureType) {
140 //To set the ApplyActionsMiss
141 properties.add(createApplyActionsMissTblFeatureProp().build());
144 // To set the Next Table
145 properties.add(createNextTblFeatureProp().build());
148 // To set the Next Table Miss
149 properties.add(createNextTableMissTblFeatureProp().build());
152 //To set the ApplyActions
153 properties.add(createApplyActionsTblFeatureProp().build());
156 // To set the instructions
157 properties.add(createInstructionsTblFeatureProp().build());
160 // To set the instructions miss
161 properties.add(createInstructionsMissTblFeatureProp().build());
164 // To set the write actions
165 properties.add(createWriteActionsTblFeatureProp().build());
168 // To set the write actions miss
169 properties.add(createWriteActionsMissTblFeatureProp().build());
172 // To set the match field
173 properties.add(createMatchFieldTblFeatureProp().build());
176 // To set the write set-field
177 properties.add(createWriteSetFieldTblFeatureProp().build());
180 // To set the write set-field miss
181 properties.add(createWriteSetFieldMissTblFeatureProp().build());
184 // To set the apply set field
185 properties.add(createApplySetFieldTblFeatureProp().build());
188 // To set the apply set field miss
189 properties.add(createApplySetFieldMissTblFeatureProp().build());
192 // To set the wildcards set field match
193 properties.add(createWildCardsTblFeatureProp().build());
200 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
201 propertyBld.setTableFeatureProperties(properties);
202 tableFeature.setTableProperties(propertyBld.build());
207 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
208 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
210 //To set the ApplyActionsMiss
211 List<Action> actionList = new ArrayList<>();
212 ActionBuilder ab = new ActionBuilder();
214 ab.setAction(new PopMplsActionCaseBuilder().build());
215 actionList.add(ab.build());
217 tableFeatureProperty.setTableFeaturePropType(
218 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
219 .feature.prop.type.ApplyActionsMissBuilder()
220 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
222 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
223 tableFeatureProperty.withKey(keyValue);
224 tableFeatureProperty.setOrder(1);
226 return tableFeatureProperty;
230 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
231 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
232 List<Action> actionListt5 = new ArrayList<>();
233 ActionBuilder abt5 = new ActionBuilder();
235 abt5.setAction(new PopMplsActionCaseBuilder().build());
236 actionListt5.add(abt5.build());
238 tableFeatureProperty.setTableFeaturePropType(
239 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
240 .feature.prop.type.ApplyActionsBuilder()
241 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
243 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
244 tableFeatureProperty.withKey(keyValue);
245 tableFeatureProperty.setOrder(1);
247 return tableFeatureProperty;
250 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
251 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
252 List<Short> nextTblIds = Arrays.asList(new Short[]{2, 3});
253 NextTableBuilder nextTblBld = new NextTableBuilder();
255 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
256 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
258 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
259 tableFeatureProperty.withKey(keyValue);
260 tableFeatureProperty.setOrder(1);
262 return tableFeatureProperty;
265 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
266 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
267 List<Short> nextTblMissIds = Arrays.asList(new Short[]{23, 24, 25, 27, 28, 29, 30});
268 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder();
270 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build());
271 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build());
273 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
274 tableFeatureProperty.withKey(keyValue);
275 tableFeatureProperty.setOrder(1);
277 return tableFeatureProperty;
281 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
282 InstructionBuilder ib = new InstructionBuilder();
284 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
285 .instruction.ApplyActionsCaseBuilder().build());
286 ib.withKey(new InstructionKey(1));
288 List<Instruction> instLst = new ArrayList<>();
289 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
290 tableFeatureProperty.setTableFeaturePropType(
291 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
292 .feature.prop.type.InstructionsBuilder().setInstructions(
293 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
294 .table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build())
298 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
299 tableFeatureProperty.withKey(keyValue);
300 tableFeatureProperty.setOrder(1);
302 return tableFeatureProperty;
305 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
306 // To set the instructions miss -- "t7"
308 InstructionBuilder ib1 = new InstructionBuilder();
310 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
311 .instruction.WriteMetadataCaseBuilder().build());
312 ib1.withKey(new InstructionKey(1));
314 InstructionBuilder ib2 = new InstructionBuilder();
316 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
317 .instruction.MeterCaseBuilder().build());
318 ib2.withKey(new InstructionKey(2));
320 List<Instruction> instLst = new ArrayList<>();
321 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
322 tableFeatureProperty.setTableFeaturePropType(
323 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
324 .feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
325 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
326 .table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst)
330 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
331 tableFeatureProperty.withKey(keyValue);
332 tableFeatureProperty.setOrder(1);
334 return tableFeatureProperty;
337 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
340 List<Action> actionList = new ArrayList<>();
342 ActionBuilder abt1 = new ActionBuilder();
343 abt1.setAction(new CopyTtlOutCaseBuilder().build());
344 actionList.add(abt1.build());
346 ActionBuilder abt2 = new ActionBuilder();
347 abt2.setAction(new PopVlanActionCaseBuilder().build());
348 actionList.add(abt2.build());
350 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
351 tableFeatureProperty.setTableFeaturePropType(
352 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
353 .feature.prop.type.WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn
354 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
355 .WriteActionsBuilder().setAction(actionList).build()).build());
357 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
358 tableFeatureProperty.withKey(keyValue);
359 tableFeatureProperty.setOrder(1);
361 return tableFeatureProperty;
364 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
366 List<Action> actionList = new ArrayList<>();
368 ActionBuilder abt1 = new ActionBuilder();
369 abt1.setAction(new CopyTtlInCaseBuilder().build());
370 actionList.add(abt1.build());
372 ActionBuilder abt2 = new ActionBuilder();
373 abt2.setAction(new PushPbbActionCaseBuilder().build());
374 actionList.add(abt2.build());
376 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
377 tableFeatureProperty.setTableFeaturePropType(
378 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
379 .feature.prop.type.WriteActionsMissBuilder().setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn
380 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
381 .miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
383 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
384 tableFeatureProperty.withKey(keyValue);
385 tableFeatureProperty.setOrder(1);
387 return tableFeatureProperty;
390 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
393 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
394 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
395 setFieldMatchBld.setHasMask(false);
396 setFieldMatchBld.setMatchType(MplsLabel.class);
399 setFieldMatch.add(setFieldMatchBld.build());
400 MatchBuilder matchBld = new MatchBuilder();
401 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
402 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
403 matchBld.setMatchSetfield(matchSetfieldBld.build());
405 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
406 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
407 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
408 tableFeatureProperty.withKey(keyValue);
409 tableFeatureProperty.setOrder(1);
411 return tableFeatureProperty;
415 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
418 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
419 setFieldMatchBld1.setHasMask(false);
420 setFieldMatchBld1.setMatchType(MplsLabel.class);
422 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
423 setFieldMatchBld2.setHasMask(true);
424 setFieldMatchBld2.setMatchType(MplsBos.class);
426 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
427 setFieldMatchBld3.setHasMask(true);
428 setFieldMatchBld3.setMatchType(EthDst.class);
430 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
431 setFieldMatch.add(setFieldMatchBld1.build());
432 setFieldMatch.add(setFieldMatchBld2.build());
433 setFieldMatch.add(setFieldMatchBld3.build());
435 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
436 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
437 .type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
438 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
439 .feature.prop.type.write.setfield.WriteSetfieldBuilder();
440 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
441 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
443 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
444 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
445 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
446 tableFeatureProperty.withKey(keyValue);
447 tableFeatureProperty.setOrder(1);
449 return tableFeatureProperty;
452 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
455 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
456 setFieldMatchBld1.setHasMask(false);
457 setFieldMatchBld1.setMatchType(EthSrc.class);
459 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
460 setFieldMatchBld2.setHasMask(true);
461 setFieldMatchBld2.setMatchType(InPort.class);
463 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
464 setFieldMatchBld3.setHasMask(true);
465 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
467 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
468 setFieldMatch.add(setFieldMatchBld1.build());
469 setFieldMatch.add(setFieldMatchBld2.build());
470 setFieldMatch.add(setFieldMatchBld3.build());
472 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
473 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
474 .type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
475 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
476 .feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
477 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
478 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
480 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
481 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
482 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
483 tableFeatureProperty.withKey(keyValue);
484 tableFeatureProperty.setOrder(1);
486 return tableFeatureProperty;
489 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
492 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
493 setFieldMatchBld1.setHasMask(false);
494 setFieldMatchBld1.setMatchType(ArpOp.class);
496 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
497 setFieldMatchBld2.setHasMask(true);
498 setFieldMatchBld2.setMatchType(InPort.class);
500 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
501 setFieldMatchBld3.setHasMask(true);
502 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
504 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
505 setFieldMatch.add(setFieldMatchBld1.build());
506 setFieldMatch.add(setFieldMatchBld2.build());
507 setFieldMatch.add(setFieldMatchBld3.build());
509 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
510 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
511 .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
512 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
513 .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
514 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
515 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
517 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
518 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
519 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
520 tableFeatureProperty.withKey(keyValue);
521 tableFeatureProperty.setOrder(1);
523 return tableFeatureProperty;
526 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
529 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
530 setFieldMatchBld1.setHasMask(false);
531 setFieldMatchBld1.setMatchType(ArpOp.class);
533 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
534 setFieldMatchBld2.setHasMask(true);
535 setFieldMatchBld2.setMatchType(InPort.class);
537 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
538 setFieldMatchBld3.setHasMask(true);
539 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
541 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
542 setFieldMatch.add(setFieldMatchBld1.build());
543 setFieldMatch.add(setFieldMatchBld2.build());
544 setFieldMatch.add(setFieldMatchBld3.build());
546 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
547 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
548 .type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
549 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
550 .feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
551 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
552 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
554 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
555 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
556 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
557 tableFeatureProperty.withKey(keyValue);
558 tableFeatureProperty.setOrder(1);
560 return tableFeatureProperty;
563 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
566 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
567 setFieldMatchBld1.setHasMask(false);
568 setFieldMatchBld1.setMatchType(ArpOp.class);
570 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
571 setFieldMatchBld2.setHasMask(true);
572 setFieldMatchBld2.setMatchType(InPort.class);
574 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
575 setFieldMatch.add(setFieldMatchBld1.build());
576 setFieldMatch.add(setFieldMatchBld2.build());
578 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
579 WildcardSetfieldBuilder wildcardsBuilder =
580 new WildcardSetfieldBuilder();
581 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
582 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
584 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
585 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
586 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
587 tableFeatureProperty.withKey(keyValue);
588 tableFeatureProperty.setOrder(1);
590 return tableFeatureProperty;
593 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
594 ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
596 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
597 .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
598 .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
600 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
601 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
602 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
603 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
604 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
605 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
607 public void onSuccess(Void notUsed) {
608 ci.println("Status of Group Data Loaded Transaction: success.");
612 public void onFailure(Throwable throwable) {
613 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
615 }, MoreExecutors.directExecutor());
618 public void _modifyTable(CommandInterpreter ci) {
619 String nref = ci.nextArgument();
620 ci.println(" Table Command Provider modify");
623 ci.println("test node added");
626 ci.println("User node added" + nref);
627 createUserNode(nref);
629 String tableFeatureType = ci.nextArgument();
630 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
632 writeTableFeatures(ci, tableFeaturesBld.build());
636 public String getHelp() {
637 StringBuilder help = new StringBuilder();
638 help.append("---FRM MD-SAL Table test module---\n");
639 help.append("\t modifyTable <node id> - node ref\n");
641 return help.toString();