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.osgi.framework.BundleContext;
73 @SuppressWarnings("checkstyle:MethodName")
74 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
76 private final DataBroker dataBroker;
77 private final BundleContext ctx;
78 private Node testNode;
80 public OpenflowpluginTableFeaturesTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
81 this.dataBroker = dataBroker;
86 ctx.registerService(CommandProvider.class.getName(), this, null);
88 // createTestTableFeatures();
91 private void createUserNode(String nodeRef) {
92 NodeBuilder builder = new NodeBuilder();
93 builder.setId(new NodeId(nodeRef));
94 builder.withKey(new NodeKey(builder.getId()));
95 testNode = builder.build();
98 private void createTestNode() {
99 NodeBuilder builder = new NodeBuilder();
100 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
101 builder.withKey(new NodeKey(builder.getId()));
102 testNode = builder.build();
105 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
106 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
109 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
111 String tableFeatureType = tableFeatureTypeArg;
112 if (tableFeatureType == null) {
113 tableFeatureType = "t1";
116 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
117 // Sample data , committing to DataStore
118 if (!tableFeatureType.equals("t1")) {
121 tableFeature.setTableId((short) 0);
122 tableFeature.setName("Table 0");
125 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
126 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
127 tableFeature.setMaxEntries(10000L);
129 tableFeature.setConfig(new TableConfig(false));
131 List<TableFeatureProperties> properties = new ArrayList<>();
134 switch (tableFeatureType) {
136 //To set the ApplyActionsMiss
137 properties.add(createApplyActionsMissTblFeatureProp().build());
140 // To set the Next Table
141 properties.add(createNextTblFeatureProp().build());
144 // To set the Next Table Miss
145 properties.add(createNextTableMissTblFeatureProp().build());
148 //To set the ApplyActions
149 properties.add(createApplyActionsTblFeatureProp().build());
152 // To set the instructions
153 properties.add(createInstructionsTblFeatureProp().build());
156 // To set the instructions miss
157 properties.add(createInstructionsMissTblFeatureProp().build());
160 // To set the write actions
161 properties.add(createWriteActionsTblFeatureProp().build());
164 // To set the write actions miss
165 properties.add(createWriteActionsMissTblFeatureProp().build());
168 // To set the match field
169 properties.add(createMatchFieldTblFeatureProp().build());
172 // To set the write set-field
173 properties.add(createWriteSetFieldTblFeatureProp().build());
176 // To set the write set-field miss
177 properties.add(createWriteSetFieldMissTblFeatureProp().build());
180 // To set the apply set field
181 properties.add(createApplySetFieldTblFeatureProp().build());
184 // To set the apply set field miss
185 properties.add(createApplySetFieldMissTblFeatureProp().build());
188 // To set the wildcards set field match
189 properties.add(createWildCardsTblFeatureProp().build());
196 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
197 propertyBld.setTableFeatureProperties(properties);
198 tableFeature.setTableProperties(propertyBld.build());
203 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
204 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
206 //To set the ApplyActionsMiss
207 List<Action> actionList = new ArrayList<>();
208 ActionBuilder ab = new ActionBuilder();
210 ab.setAction(new PopMplsActionCaseBuilder().build());
211 actionList.add(ab.build());
213 tableFeatureProperty.setTableFeaturePropType(
214 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
215 .feature.prop.type.ApplyActionsMissBuilder()
216 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
218 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
219 tableFeatureProperty.withKey(keyValue);
220 tableFeatureProperty.setOrder(1);
222 return tableFeatureProperty;
226 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
227 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
228 List<Action> actionListt5 = new ArrayList<>();
229 ActionBuilder abt5 = new ActionBuilder();
231 abt5.setAction(new PopMplsActionCaseBuilder().build());
232 actionListt5.add(abt5.build());
234 tableFeatureProperty.setTableFeaturePropType(
235 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
236 .feature.prop.type.ApplyActionsBuilder()
237 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
239 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
240 tableFeatureProperty.withKey(keyValue);
241 tableFeatureProperty.setOrder(1);
243 return tableFeatureProperty;
246 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
247 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
248 List<Short> nextTblIds = Arrays.asList(new Short[]{2, 3});
249 NextTableBuilder nextTblBld = new NextTableBuilder();
251 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
252 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
254 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
255 tableFeatureProperty.withKey(keyValue);
256 tableFeatureProperty.setOrder(1);
258 return tableFeatureProperty;
261 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
262 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
263 List<Short> nextTblMissIds = Arrays.asList(new Short[]{23, 24, 25, 27, 28, 29, 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 InstructionBuilder ib = new InstructionBuilder();
280 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
281 .instruction.ApplyActionsCaseBuilder().build());
282 ib.withKey(new InstructionKey(1));
284 List<Instruction> instLst = new ArrayList<>();
285 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
286 tableFeatureProperty.setTableFeaturePropType(
287 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
288 .feature.prop.type.InstructionsBuilder().setInstructions(
289 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
290 .table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build())
294 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
295 tableFeatureProperty.withKey(keyValue);
296 tableFeatureProperty.setOrder(1);
298 return tableFeatureProperty;
301 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
302 // To set the instructions miss -- "t7"
304 InstructionBuilder ib1 = new InstructionBuilder();
306 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
307 .instruction.WriteMetadataCaseBuilder().build());
308 ib1.withKey(new InstructionKey(1));
310 InstructionBuilder ib2 = new InstructionBuilder();
312 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
313 .instruction.MeterCaseBuilder().build());
314 ib2.withKey(new InstructionKey(2));
316 List<Instruction> instLst = new ArrayList<>();
317 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
318 tableFeatureProperty.setTableFeaturePropType(
319 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
320 .feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
321 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
322 .table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst)
326 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
327 tableFeatureProperty.withKey(keyValue);
328 tableFeatureProperty.setOrder(1);
330 return tableFeatureProperty;
333 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
336 List<Action> actionList = new ArrayList<>();
338 ActionBuilder abt1 = new ActionBuilder();
339 abt1.setAction(new CopyTtlOutCaseBuilder().build());
340 actionList.add(abt1.build());
342 ActionBuilder abt2 = new ActionBuilder();
343 abt2.setAction(new PopVlanActionCaseBuilder().build());
344 actionList.add(abt2.build());
346 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
347 tableFeatureProperty.setTableFeaturePropType(
348 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
349 .feature.prop.type.WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn
350 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
351 .WriteActionsBuilder().setAction(actionList).build()).build());
353 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
354 tableFeatureProperty.withKey(keyValue);
355 tableFeatureProperty.setOrder(1);
357 return tableFeatureProperty;
360 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
362 List<Action> actionList = new ArrayList<>();
364 ActionBuilder abt1 = new ActionBuilder();
365 abt1.setAction(new CopyTtlInCaseBuilder().build());
366 actionList.add(abt1.build());
368 ActionBuilder abt2 = new ActionBuilder();
369 abt2.setAction(new PushPbbActionCaseBuilder().build());
370 actionList.add(abt2.build());
372 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
373 tableFeatureProperty.setTableFeaturePropType(
374 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
375 .feature.prop.type.WriteActionsMissBuilder().setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn
376 .opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions
377 .miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
379 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
380 tableFeatureProperty.withKey(keyValue);
381 tableFeatureProperty.setOrder(1);
383 return tableFeatureProperty;
386 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
389 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
390 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
391 setFieldMatchBld.setHasMask(false);
392 setFieldMatchBld.setMatchType(MplsLabel.class);
395 setFieldMatch.add(setFieldMatchBld.build());
396 MatchBuilder matchBld = new MatchBuilder();
397 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
398 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
399 matchBld.setMatchSetfield(matchSetfieldBld.build());
401 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
402 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
403 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
404 tableFeatureProperty.withKey(keyValue);
405 tableFeatureProperty.setOrder(1);
407 return tableFeatureProperty;
411 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
414 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
415 setFieldMatchBld1.setHasMask(false);
416 setFieldMatchBld1.setMatchType(MplsLabel.class);
418 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
419 setFieldMatchBld2.setHasMask(true);
420 setFieldMatchBld2.setMatchType(MplsBos.class);
422 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
423 setFieldMatchBld3.setHasMask(true);
424 setFieldMatchBld3.setMatchType(EthDst.class);
426 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
427 setFieldMatch.add(setFieldMatchBld1.build());
428 setFieldMatch.add(setFieldMatchBld2.build());
429 setFieldMatch.add(setFieldMatchBld3.build());
431 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
432 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
433 .type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
434 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
435 .feature.prop.type.write.setfield.WriteSetfieldBuilder();
436 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
437 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
439 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
440 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
441 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
442 tableFeatureProperty.withKey(keyValue);
443 tableFeatureProperty.setOrder(1);
445 return tableFeatureProperty;
448 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
451 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
452 setFieldMatchBld1.setHasMask(false);
453 setFieldMatchBld1.setMatchType(EthSrc.class);
455 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
456 setFieldMatchBld2.setHasMask(true);
457 setFieldMatchBld2.setMatchType(InPort.class);
459 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
460 setFieldMatchBld3.setHasMask(true);
461 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
463 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
464 setFieldMatch.add(setFieldMatchBld1.build());
465 setFieldMatch.add(setFieldMatchBld2.build());
466 setFieldMatch.add(setFieldMatchBld3.build());
468 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
469 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
470 .type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
471 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
472 .feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
473 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
474 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
476 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
477 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
478 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
479 tableFeatureProperty.withKey(keyValue);
480 tableFeatureProperty.setOrder(1);
482 return tableFeatureProperty;
485 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
488 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
489 setFieldMatchBld1.setHasMask(false);
490 setFieldMatchBld1.setMatchType(ArpOp.class);
492 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
493 setFieldMatchBld2.setHasMask(true);
494 setFieldMatchBld2.setMatchType(InPort.class);
496 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
497 setFieldMatchBld3.setHasMask(true);
498 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
500 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
501 setFieldMatch.add(setFieldMatchBld1.build());
502 setFieldMatch.add(setFieldMatchBld2.build());
503 setFieldMatch.add(setFieldMatchBld3.build());
505 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
506 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
507 .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
508 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
509 .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
510 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
511 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
513 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
514 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
515 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
516 tableFeatureProperty.withKey(keyValue);
517 tableFeatureProperty.setOrder(1);
519 return tableFeatureProperty;
522 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
525 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
526 setFieldMatchBld1.setHasMask(false);
527 setFieldMatchBld1.setMatchType(ArpOp.class);
529 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
530 setFieldMatchBld2.setHasMask(true);
531 setFieldMatchBld2.setMatchType(InPort.class);
533 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
534 setFieldMatchBld3.setHasMask(true);
535 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
537 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
538 setFieldMatch.add(setFieldMatchBld1.build());
539 setFieldMatch.add(setFieldMatchBld2.build());
540 setFieldMatch.add(setFieldMatchBld3.build());
542 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
543 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
544 .type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
545 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
546 .feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
547 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
548 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
550 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
551 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
552 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
553 tableFeatureProperty.withKey(keyValue);
554 tableFeatureProperty.setOrder(1);
556 return tableFeatureProperty;
559 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
562 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
563 setFieldMatchBld1.setHasMask(false);
564 setFieldMatchBld1.setMatchType(ArpOp.class);
566 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
567 setFieldMatchBld2.setHasMask(true);
568 setFieldMatchBld2.setMatchType(InPort.class);
570 List<SetFieldMatch> setFieldMatch = new ArrayList<>();
571 setFieldMatch.add(setFieldMatchBld1.build());
572 setFieldMatch.add(setFieldMatchBld2.build());
574 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
575 WildcardSetfieldBuilder wildcardsBuilder =
576 new WildcardSetfieldBuilder();
577 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
578 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
580 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
581 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
582 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
583 tableFeatureProperty.withKey(keyValue);
584 tableFeatureProperty.setOrder(1);
586 return tableFeatureProperty;
589 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
590 ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
592 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
593 .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
594 .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
596 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
597 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
598 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
599 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
600 modification.commit().addCallback(new FutureCallback<Object>() {
602 public void onSuccess(Object notUsed) {
603 ci.println("Status of Group Data Loaded Transaction: success.");
607 public void onFailure(Throwable throwable) {
608 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
610 }, MoreExecutors.directExecutor());
613 public void _modifyTable(CommandInterpreter ci) {
614 String nref = ci.nextArgument();
615 ci.println(" Table Command Provider modify");
618 ci.println("test node added");
621 ci.println("User node added" + nref);
622 createUserNode(nref);
624 String tableFeatureType = ci.nextArgument();
625 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
627 writeTableFeatures(ci, tableFeaturesBld.build());
631 public String getHelp() {
632 StringBuilder help = new StringBuilder();
633 help.append("---FRM MD-SAL Table test module---\n");
634 help.append("\t modifyTable <node id> - node ref\n");
636 return help.toString();