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.util.concurrent.CheckedFuture;
11 import com.google.common.util.concurrent.FutureCallback;
12 import com.google.common.util.concurrent.Futures;
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.controller.md.sal.binding.api.DataBroker;
20 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
21 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
22 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
23 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
71 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
72 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
73 import org.osgi.framework.BundleContext;
76 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
78 private DataBroker dataBroker;
79 private ProviderContext pc;
80 private final BundleContext ctx;
81 private TableFeatures testTable;
82 private Node testNode;
83 private final String originalTableName = "Foo";
84 private final String updatedTableName = "Bar";
86 public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
90 public void onSessionInitiated(ProviderContext session) {
92 dataBroker = session.getSALService(DataBroker.class);
93 ctx.registerService(CommandProvider.class.getName(), this, null);
95 // createTestTableFeatures();
98 private void createUserNode(String nodeRef) {
99 NodeBuilder builder = new NodeBuilder();
100 builder.setId(new NodeId(nodeRef));
101 builder.setKey(new NodeKey(builder.getId()));
102 testNode = builder.build();
105 private void createTestNode() {
106 NodeBuilder builder = new NodeBuilder();
107 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
108 builder.setKey(new NodeKey(builder.getId()));
109 testNode = builder.build();
112 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
113 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
116 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
118 String tableFeatureType = tableFeatureTypeArg;
119 if (tableFeatureType == null) {
120 tableFeatureType = "t1";
123 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
124 // Sample data , committing to DataStore
125 if (!tableFeatureType.equals("t1")) {
128 tableFeature.setTableId((short) 0);
129 tableFeature.setName("Table 0");
132 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
133 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
134 tableFeature.setMaxEntries(10000L);
136 tableFeature.setConfig(new TableConfig(false));
138 List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>();
141 switch (tableFeatureType) {
143 //To set the ApplyActionsMiss
144 properties.add(createApplyActionsMissTblFeatureProp().build());
147 // To set the Next Table
148 properties.add(createNextTblFeatureProp().build());
151 // To set the Next Table Miss
152 properties.add(createNextTableMissTblFeatureProp().build());
155 //To set the ApplyActions
156 properties.add(createApplyActionsTblFeatureProp().build());
159 // To set the instructions
160 properties.add(createInstructionsTblFeatureProp().build());
163 // To set the instructions miss
164 properties.add(createInstructionsMissTblFeatureProp().build());
167 // To set the write actions
168 properties.add(createWriteActionsTblFeatureProp().build());
171 // To set the write actions miss
172 properties.add(createWriteActionsMissTblFeatureProp().build());
175 // To set the match field
176 properties.add(createMatchFieldTblFeatureProp().build());
179 // To set the write set-field
180 properties.add(createWriteSetFieldTblFeatureProp().build());
183 // To set the write set-field miss
184 properties.add(createWriteSetFieldMissTblFeatureProp().build());
187 // To set the apply set field
188 properties.add(createApplySetFieldTblFeatureProp().build());
191 // To set the apply set field miss
192 properties.add(createApplySetFieldMissTblFeatureProp().build());
195 // To set the wildcards set field match
196 properties.add(createWildCardsTblFeatureProp().build());
201 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
202 propertyBld.setTableFeatureProperties(properties);
203 tableFeature.setTableProperties(propertyBld.build());
205 testTable = tableFeature.build();
209 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
210 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
212 //To set the ApplyActionsMiss
213 List<Action> actionList = new ArrayList<Action>();
214 ActionBuilder ab = new ActionBuilder();
216 ab.setAction(new PopMplsActionCaseBuilder().build());
217 actionList.add(ab.build());
219 tableFeatureProperty.setTableFeaturePropType(
220 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder()
221 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
223 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
224 tableFeatureProperty.setKey(keyValue);
225 tableFeatureProperty.setOrder(1);
227 return tableFeatureProperty;
231 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
232 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
233 List<Action> actionListt5 = new ArrayList<Action>();
234 ActionBuilder abt5 = new ActionBuilder();
236 abt5.setAction(new PopMplsActionCaseBuilder().build());
237 actionListt5.add(abt5.build());
239 tableFeatureProperty.setTableFeaturePropType(
240 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder()
241 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
243 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
244 tableFeatureProperty.setKey(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.setKey(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.setKey(keyValue);
275 tableFeatureProperty.setOrder(1);
277 return tableFeatureProperty;
281 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
282 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
284 List<Instruction> instLst = new ArrayList<Instruction>();
285 InstructionBuilder ib = new InstructionBuilder();
287 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder().build());
288 ib.setKey(new InstructionKey(1));
290 tableFeatureProperty.setTableFeaturePropType(
291 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder().setInstructions(
292 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(instLst).build()).build());
295 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
296 tableFeatureProperty.setKey(keyValue);
297 tableFeatureProperty.setOrder(1);
299 return tableFeatureProperty;
302 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
303 // To set the instructions miss -- "t7"
304 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
306 List<Instruction> instLst = new ArrayList<Instruction>();
307 InstructionBuilder ib1 = new InstructionBuilder();
309 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder().build());
310 ib1.setKey(new InstructionKey(1));
312 InstructionBuilder ib2 = new InstructionBuilder();
314 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder().build());
315 ib2.setKey(new InstructionKey(2));
317 tableFeatureProperty.setTableFeaturePropType(
318 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
319 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder().setInstruction(instLst).build()).build());
322 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
323 tableFeatureProperty.setKey(keyValue);
324 tableFeatureProperty.setOrder(1);
326 return tableFeatureProperty;
329 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
331 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
333 List<Action> actionList = new ArrayList<Action>();
335 ActionBuilder abt1 = new ActionBuilder();
336 abt1.setAction(new CopyTtlOutCaseBuilder().build());
337 actionList.add(abt1.build());
339 ActionBuilder abt2 = new ActionBuilder();
340 abt2.setAction(new PopVlanActionCaseBuilder().build());
341 actionList.add(abt2.build());
343 tableFeatureProperty.setTableFeaturePropType(
344 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder()
345 .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder().setAction(actionList).build()).build());
347 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
348 tableFeatureProperty.setKey(keyValue);
349 tableFeatureProperty.setOrder(1);
351 return tableFeatureProperty;
354 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
356 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
358 List<Action> actionList = new ArrayList<Action>();
360 ActionBuilder abt1 = new ActionBuilder();
361 abt1.setAction(new CopyTtlInCaseBuilder().build());
362 actionList.add(abt1.build());
364 ActionBuilder abt2 = new ActionBuilder();
365 abt2.setAction(new PushPbbActionCaseBuilder().build());
366 actionList.add(abt2.build());
368 tableFeatureProperty.setTableFeaturePropType(
369 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder()
370 .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder().setAction(actionList).build()).build());
372 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
373 tableFeatureProperty.setKey(keyValue);
374 tableFeatureProperty.setOrder(1);
376 return tableFeatureProperty;
379 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
381 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
384 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
385 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
386 setFieldMatchBld.setHasMask(false);
387 setFieldMatchBld.setMatchType(MplsLabel.class);
390 setFieldMatch.add(setFieldMatchBld.build());
391 MatchBuilder matchBld = new MatchBuilder();
392 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
393 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
394 matchBld.setMatchSetfield(matchSetfieldBld.build());
396 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
397 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
398 tableFeatureProperty.setKey(keyValue);
399 tableFeatureProperty.setOrder(1);
401 return tableFeatureProperty;
405 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
407 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
409 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
410 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
411 setFieldMatchBld1.setHasMask(false);
412 setFieldMatchBld1.setMatchType(MplsLabel.class);
414 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
415 setFieldMatchBld2.setHasMask(true);
416 setFieldMatchBld2.setMatchType(MplsBos.class);
418 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
419 setFieldMatchBld3.setHasMask(true);
420 setFieldMatchBld3.setMatchType(EthDst.class);
422 setFieldMatch.add(setFieldMatchBld1.build());
423 setFieldMatch.add(setFieldMatchBld2.build());
424 setFieldMatch.add(setFieldMatchBld3.build());
426 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
427 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
428 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder();
429 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
430 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
433 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
434 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
435 tableFeatureProperty.setKey(keyValue);
436 tableFeatureProperty.setOrder(1);
438 return tableFeatureProperty;
441 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
443 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
445 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
446 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
447 setFieldMatchBld1.setHasMask(false);
448 setFieldMatchBld1.setMatchType(EthSrc.class);
450 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
451 setFieldMatchBld2.setHasMask(true);
452 setFieldMatchBld2.setMatchType(InPort.class);
454 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
455 setFieldMatchBld3.setHasMask(true);
456 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
458 setFieldMatch.add(setFieldMatchBld1.build());
459 setFieldMatch.add(setFieldMatchBld2.build());
460 setFieldMatch.add(setFieldMatchBld3.build());
462 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
463 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
464 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
465 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
466 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
468 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
469 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
470 tableFeatureProperty.setKey(keyValue);
471 tableFeatureProperty.setOrder(1);
473 return tableFeatureProperty;
476 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
478 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
480 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
481 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
482 setFieldMatchBld1.setHasMask(false);
483 setFieldMatchBld1.setMatchType(ArpOp.class);
485 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
486 setFieldMatchBld2.setHasMask(true);
487 setFieldMatchBld2.setMatchType(InPort.class);
489 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
490 setFieldMatchBld3.setHasMask(true);
491 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
493 setFieldMatch.add(setFieldMatchBld1.build());
494 setFieldMatch.add(setFieldMatchBld2.build());
495 setFieldMatch.add(setFieldMatchBld3.build());
497 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
498 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
499 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder();
500 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
501 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
503 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
504 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
505 tableFeatureProperty.setKey(keyValue);
506 tableFeatureProperty.setOrder(1);
508 return tableFeatureProperty;
511 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
513 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
515 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
516 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
517 setFieldMatchBld1.setHasMask(false);
518 setFieldMatchBld1.setMatchType(ArpOp.class);
520 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
521 setFieldMatchBld2.setHasMask(true);
522 setFieldMatchBld2.setMatchType(InPort.class);
524 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
525 setFieldMatchBld3.setHasMask(true);
526 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
528 setFieldMatch.add(setFieldMatchBld1.build());
529 setFieldMatch.add(setFieldMatchBld2.build());
530 setFieldMatch.add(setFieldMatchBld3.build());
532 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
533 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
534 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
535 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
536 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
538 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
539 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
540 tableFeatureProperty.setKey(keyValue);
541 tableFeatureProperty.setOrder(1);
543 return tableFeatureProperty;
546 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
548 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
550 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
551 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
552 setFieldMatchBld1.setHasMask(false);
553 setFieldMatchBld1.setMatchType(ArpOp.class);
555 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
556 setFieldMatchBld2.setHasMask(true);
557 setFieldMatchBld2.setMatchType(InPort.class);
560 setFieldMatch.add(setFieldMatchBld1.build());
561 setFieldMatch.add(setFieldMatchBld2.build());
563 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
564 WildcardSetfieldBuilder wildcardsBuilder =
565 new WildcardSetfieldBuilder();
566 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
567 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
569 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
570 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
571 tableFeatureProperty.setKey(keyValue);
572 tableFeatureProperty.setOrder(1);
574 return tableFeatureProperty;
578 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
579 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
581 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
582 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
583 child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
586 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
587 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
588 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
589 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
590 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
591 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
593 public void onSuccess(Void aVoid) {
594 ci.println("Status of Group Data Loaded Transaction: success.");
598 public void onFailure(Throwable throwable) {
599 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
604 public void _modifyTable(CommandInterpreter ci) {
605 String nref = ci.nextArgument();
606 ci.println(" Table Command Provider modify");
609 ci.println("test node added");
612 ci.println("User node added" + nref);
613 createUserNode(nref);
615 String tableFeatureType = ci.nextArgument();
616 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
618 writeTableFeatures(ci, tableFeaturesBld.build());
622 public String getHelp() {
623 StringBuilder help = new StringBuilder();
624 help.append("---FRM MD-SAL Table test module---\n");
625 help.append("\t modifyTable <node id> - node ref\n");
627 return help.toString();