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.flow.types.rev131026.instruction.list.InstructionBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
69 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
70 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
71 import org.opendaylight.yangtools.yang.common.Uint8;
72 import org.osgi.framework.BundleContext;
74 @SuppressWarnings("checkstyle:MethodName")
75 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
77 private final DataBroker dataBroker;
78 private final BundleContext ctx;
79 private Node testNode;
81 public OpenflowpluginTableFeaturesTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
82 this.dataBroker = dataBroker;
87 ctx.registerService(CommandProvider.class.getName(), this, null);
89 // createTestTableFeatures();
92 private void createUserNode(String nodeRef) {
93 NodeBuilder builder = new NodeBuilder();
94 builder.setId(new NodeId(nodeRef));
95 builder.withKey(new NodeKey(builder.getId()));
96 testNode = builder.build();
99 private void createTestNode() {
100 NodeBuilder builder = new NodeBuilder();
101 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
102 builder.withKey(new NodeKey(builder.getId()));
103 testNode = builder.build();
106 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
107 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
110 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
112 String tableFeatureType = tableFeatureTypeArg;
113 if (tableFeatureType == null) {
114 tableFeatureType = "t1";
117 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
118 // Sample data , committing to DataStore
119 if (!tableFeatureType.equals("t1")) {
122 tableFeature.setTableId((short) 0);
123 tableFeature.setName("Table 0");
126 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
127 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
128 tableFeature.setMaxEntries(10000L);
130 tableFeature.setConfig(new TableConfig(false));
132 List<TableFeatureProperties> properties = new ArrayList<>();
135 switch (tableFeatureType) {
137 //To set the ApplyActionsMiss
138 properties.add(createApplyActionsMissTblFeatureProp().build());
141 // To set the Next Table
142 properties.add(createNextTblFeatureProp().build());
145 // To set the Next Table Miss
146 properties.add(createNextTableMissTblFeatureProp().build());
149 //To set the ApplyActions
150 properties.add(createApplyActionsTblFeatureProp().build());
153 // To set the instructions
154 properties.add(createInstructionsTblFeatureProp().build());
157 // To set the instructions miss
158 properties.add(createInstructionsMissTblFeatureProp().build());
161 // To set the write actions
162 properties.add(createWriteActionsTblFeatureProp().build());
165 // To set the write actions miss
166 properties.add(createWriteActionsMissTblFeatureProp().build());
169 // To set the match field
170 properties.add(createMatchFieldTblFeatureProp().build());
173 // To set the write set-field
174 properties.add(createWriteSetFieldTblFeatureProp().build());
177 // To set the write set-field miss
178 properties.add(createWriteSetFieldMissTblFeatureProp().build());
181 // To set the apply set field
182 properties.add(createApplySetFieldTblFeatureProp().build());
185 // To set the apply set field miss
186 properties.add(createApplySetFieldMissTblFeatureProp().build());
189 // To set the wildcards set field match
190 properties.add(createWildCardsTblFeatureProp().build());
197 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
198 propertyBld.setTableFeatureProperties(properties);
199 tableFeature.setTableProperties(propertyBld.build());
204 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
205 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
207 //To set the ApplyActionsMiss
208 List<Action> actionList = new ArrayList<>();
209 ActionBuilder ab = new ActionBuilder();
211 ab.setAction(new PopMplsActionCaseBuilder().build());
212 actionList.add(ab.build());
214 tableFeatureProperty.setTableFeaturePropType(
215 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
216 .feature.prop.type.ApplyActionsMissBuilder()
217 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
219 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
220 tableFeatureProperty.withKey(keyValue);
221 tableFeatureProperty.setOrder(1);
223 return tableFeatureProperty;
227 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
228 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
229 List<Action> actionListt5 = new ArrayList<>();
230 ActionBuilder abt5 = new ActionBuilder();
232 abt5.setAction(new PopMplsActionCaseBuilder().build());
233 actionListt5.add(abt5.build());
235 tableFeatureProperty.setTableFeaturePropType(
236 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
237 .feature.prop.type.ApplyActionsBuilder()
238 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
240 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
241 tableFeatureProperty.withKey(keyValue);
242 tableFeatureProperty.setOrder(1);
244 return tableFeatureProperty;
247 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
248 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
249 List<Uint8> nextTblIds = Arrays.asList(Uint8.valueOf(2), Uint8.valueOf(3));
250 NextTableBuilder nextTblBld = new NextTableBuilder();
252 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
253 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
255 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
256 tableFeatureProperty.withKey(keyValue);
257 tableFeatureProperty.setOrder(1);
259 return tableFeatureProperty;
262 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
263 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
264 List<Uint8> nextTblMissIds = Arrays.asList(Uint8.valueOf(23), Uint8.valueOf(24), Uint8.valueOf(25),
265 Uint8.valueOf(27), Uint8.valueOf(28), Uint8.valueOf(29), Uint8.valueOf(30));
266 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder();
268 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build());
269 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build());
271 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
272 tableFeatureProperty.withKey(keyValue);
273 tableFeatureProperty.setOrder(1);
275 return tableFeatureProperty;
279 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
280 InstructionBuilder ib = new InstructionBuilder();
282 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
283 .instruction.ApplyActionsCaseBuilder().build());
284 ib.withKey(new InstructionKey(1));
286 List<Instruction> instLst = new ArrayList<>();
287 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
288 tableFeatureProperty.setTableFeaturePropType(
289 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
290 .feature.prop.type.InstructionsBuilder().setInstructions(
291 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
292 .table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build())
296 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
297 tableFeatureProperty.withKey(keyValue);
298 tableFeatureProperty.setOrder(1);
300 return tableFeatureProperty;
303 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
304 // To set the instructions miss -- "t7"
306 InstructionBuilder ib1 = new InstructionBuilder();
308 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
309 .instruction.WriteMetadataCaseBuilder().build());
310 ib1.withKey(new InstructionKey(1));
312 InstructionBuilder ib2 = new InstructionBuilder();
314 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
315 .instruction.MeterCaseBuilder().build());
316 ib2.withKey(new InstructionKey(2));
318 List<Instruction> instLst = new ArrayList<>();
319 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
320 tableFeatureProperty.setTableFeaturePropType(
321 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
322 .feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
323 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
324 .table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst)
328 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
329 tableFeatureProperty.withKey(keyValue);
330 tableFeatureProperty.setOrder(1);
332 return tableFeatureProperty;
335 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
338 List<Action> actionList = new ArrayList<>();
340 ActionBuilder abt1 = new ActionBuilder();
341 abt1.setAction(new CopyTtlOutCaseBuilder().build());
342 actionList.add(abt1.build());
344 ActionBuilder abt2 = new ActionBuilder();
345 abt2.setAction(new PopVlanActionCaseBuilder().build());
346 actionList.add(abt2.build());
348 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
349 tableFeatureProperty.setTableFeaturePropType(
350 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
351 .feature.prop.type.WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn
352 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
353 .WriteActionsBuilder().setAction(actionList).build()).build());
355 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
356 tableFeatureProperty.withKey(keyValue);
357 tableFeatureProperty.setOrder(1);
359 return tableFeatureProperty;
362 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
364 List<Action> actionList = new ArrayList<>();
366 ActionBuilder abt1 = new ActionBuilder();
367 abt1.setAction(new CopyTtlInCaseBuilder().build());
368 actionList.add(abt1.build());
370 ActionBuilder abt2 = new ActionBuilder();
371 abt2.setAction(new PushPbbActionCaseBuilder().build());
372 actionList.add(abt2.build());
374 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
375 tableFeatureProperty.setTableFeaturePropType(
376 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
377 .feature.prop.type.WriteActionsMissBuilder().setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn
378 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
379 .miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
381 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
382 tableFeatureProperty.withKey(keyValue);
383 tableFeatureProperty.setOrder(1);
385 return tableFeatureProperty;
388 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
391 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
392 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
393 setFieldMatchBld.setHasMask(false);
394 setFieldMatchBld.setMatchType(MplsLabel.class);
397 setFieldMatch.add(setFieldMatchBld.build());
398 MatchBuilder matchBld = new MatchBuilder();
399 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
400 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
401 matchBld.setMatchSetfield(matchSetfieldBld.build());
403 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
404 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
405 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
406 tableFeatureProperty.withKey(keyValue);
407 tableFeatureProperty.setOrder(1);
409 return tableFeatureProperty;
413 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
416 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
417 setFieldMatchBld1.setHasMask(false);
418 setFieldMatchBld1.setMatchType(MplsLabel.class);
420 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
421 setFieldMatchBld2.setHasMask(true);
422 setFieldMatchBld2.setMatchType(MplsBos.class);
424 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
425 setFieldMatchBld3.setHasMask(true);
426 setFieldMatchBld3.setMatchType(EthDst.class);
428 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
429 setFieldMatch.add(setFieldMatchBld1.build());
430 setFieldMatch.add(setFieldMatchBld2.build());
431 setFieldMatch.add(setFieldMatchBld3.build());
433 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
434 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
435 .type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
436 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
437 .feature.prop.type.write.setfield.WriteSetfieldBuilder();
438 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
439 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
441 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
442 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
443 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
444 tableFeatureProperty.withKey(keyValue);
445 tableFeatureProperty.setOrder(1);
447 return tableFeatureProperty;
450 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
453 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
454 setFieldMatchBld1.setHasMask(false);
455 setFieldMatchBld1.setMatchType(EthSrc.class);
457 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
458 setFieldMatchBld2.setHasMask(true);
459 setFieldMatchBld2.setMatchType(InPort.class);
461 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
462 setFieldMatchBld3.setHasMask(true);
463 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
465 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
466 setFieldMatch.add(setFieldMatchBld1.build());
467 setFieldMatch.add(setFieldMatchBld2.build());
468 setFieldMatch.add(setFieldMatchBld3.build());
470 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
471 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
472 .type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
473 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
474 .feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
475 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
476 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
478 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
479 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
480 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
481 tableFeatureProperty.withKey(keyValue);
482 tableFeatureProperty.setOrder(1);
484 return tableFeatureProperty;
487 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
490 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
491 setFieldMatchBld1.setHasMask(false);
492 setFieldMatchBld1.setMatchType(ArpOp.class);
494 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
495 setFieldMatchBld2.setHasMask(true);
496 setFieldMatchBld2.setMatchType(InPort.class);
498 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
499 setFieldMatchBld3.setHasMask(true);
500 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
502 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
503 setFieldMatch.add(setFieldMatchBld1.build());
504 setFieldMatch.add(setFieldMatchBld2.build());
505 setFieldMatch.add(setFieldMatchBld3.build());
507 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
508 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
509 .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
510 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
511 .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
512 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
513 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
515 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
516 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
517 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
518 tableFeatureProperty.withKey(keyValue);
519 tableFeatureProperty.setOrder(1);
521 return tableFeatureProperty;
524 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
527 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
528 setFieldMatchBld1.setHasMask(false);
529 setFieldMatchBld1.setMatchType(ArpOp.class);
531 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
532 setFieldMatchBld2.setHasMask(true);
533 setFieldMatchBld2.setMatchType(InPort.class);
535 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
536 setFieldMatchBld3.setHasMask(true);
537 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
539 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
540 setFieldMatch.add(setFieldMatchBld1.build());
541 setFieldMatch.add(setFieldMatchBld2.build());
542 setFieldMatch.add(setFieldMatchBld3.build());
544 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
545 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
546 .type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
547 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
548 .feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
549 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
550 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
552 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
553 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
554 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
555 tableFeatureProperty.withKey(keyValue);
556 tableFeatureProperty.setOrder(1);
558 return tableFeatureProperty;
561 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
564 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
565 setFieldMatchBld1.setHasMask(false);
566 setFieldMatchBld1.setMatchType(ArpOp.class);
568 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
569 setFieldMatchBld2.setHasMask(true);
570 setFieldMatchBld2.setMatchType(InPort.class);
572 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
573 setFieldMatch.add(setFieldMatchBld1.build());
574 setFieldMatch.add(setFieldMatchBld2.build());
576 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
577 WildcardSetfieldBuilder wildcardsBuilder =
578 new WildcardSetfieldBuilder();
579 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
580 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
582 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
583 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
584 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
585 tableFeatureProperty.withKey(keyValue);
586 tableFeatureProperty.setOrder(1);
588 return tableFeatureProperty;
591 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
592 ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
594 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
595 .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
596 .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
598 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
599 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
600 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
601 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
602 modification.commit().addCallback(new FutureCallback<Object>() {
604 public void onSuccess(Object notUsed) {
605 ci.println("Status of Group Data Loaded Transaction: success.");
609 public void onFailure(Throwable throwable) {
610 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
612 }, MoreExecutors.directExecutor());
615 public void _modifyTable(CommandInterpreter ci) {
616 String nref = ci.nextArgument();
617 ci.println(" Table Command Provider modify");
620 ci.println("test node added");
623 ci.println("User node added" + nref);
624 createUserNode(nref);
626 String tableFeatureType = ci.nextArgument();
627 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
629 writeTableFeatures(ci, tableFeaturesBld.build());
633 public String getHelp() {
634 StringBuilder help = new StringBuilder();
635 help.append("---FRM MD-SAL Table test module---\n");
636 help.append("\t modifyTable <node id> - node ref\n");
638 return help.toString();