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 com.google.common.util.concurrent.MoreExecutors;
14 import java.math.BigInteger;
15 import java.util.ArrayList;
16 import java.util.Arrays;
17 import java.util.List;
18 import org.eclipse.osgi.framework.console.CommandInterpreter;
19 import org.eclipse.osgi.framework.console.CommandProvider;
20 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
21 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
22 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
23 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
24 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
72 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
73 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
74 import org.osgi.framework.BundleContext;
77 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
79 private DataBroker dataBroker;
80 private ProviderContext pc;
81 private final BundleContext ctx;
82 private TableFeatures testTable;
83 private Node testNode;
84 private final String originalTableName = "Foo";
85 private final String updatedTableName = "Bar";
87 public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
91 public void onSessionInitiated(ProviderContext session) {
93 dataBroker = session.getSALService(DataBroker.class);
94 ctx.registerService(CommandProvider.class.getName(), this, null);
96 // createTestTableFeatures();
99 private void createUserNode(String nodeRef) {
100 NodeBuilder builder = new NodeBuilder();
101 builder.setId(new NodeId(nodeRef));
102 builder.setKey(new NodeKey(builder.getId()));
103 testNode = builder.build();
106 private void createTestNode() {
107 NodeBuilder builder = new NodeBuilder();
108 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
109 builder.setKey(new NodeKey(builder.getId()));
110 testNode = builder.build();
113 private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
114 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
117 private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
119 String tableFeatureType = tableFeatureTypeArg;
120 if (tableFeatureType == null) {
121 tableFeatureType = "t1";
124 final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
125 // Sample data , committing to DataStore
126 if (!tableFeatureType.equals("t1")) {
129 tableFeature.setTableId((short) 0);
130 tableFeature.setName("Table 0");
133 tableFeature.setMetadataMatch(BigInteger.valueOf(10));
134 tableFeature.setMetadataWrite(BigInteger.valueOf(10));
135 tableFeature.setMaxEntries(10000L);
137 tableFeature.setConfig(new TableConfig(false));
139 List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>();
142 switch (tableFeatureType) {
144 //To set the ApplyActionsMiss
145 properties.add(createApplyActionsMissTblFeatureProp().build());
148 // To set the Next Table
149 properties.add(createNextTblFeatureProp().build());
152 // To set the Next Table Miss
153 properties.add(createNextTableMissTblFeatureProp().build());
156 //To set the ApplyActions
157 properties.add(createApplyActionsTblFeatureProp().build());
160 // To set the instructions
161 properties.add(createInstructionsTblFeatureProp().build());
164 // To set the instructions miss
165 properties.add(createInstructionsMissTblFeatureProp().build());
168 // To set the write actions
169 properties.add(createWriteActionsTblFeatureProp().build());
172 // To set the write actions miss
173 properties.add(createWriteActionsMissTblFeatureProp().build());
176 // To set the match field
177 properties.add(createMatchFieldTblFeatureProp().build());
180 // To set the write set-field
181 properties.add(createWriteSetFieldTblFeatureProp().build());
184 // To set the write set-field miss
185 properties.add(createWriteSetFieldMissTblFeatureProp().build());
188 // To set the apply set field
189 properties.add(createApplySetFieldTblFeatureProp().build());
192 // To set the apply set field miss
193 properties.add(createApplySetFieldMissTblFeatureProp().build());
196 // To set the wildcards set field match
197 properties.add(createWildCardsTblFeatureProp().build());
202 TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
203 propertyBld.setTableFeatureProperties(properties);
204 tableFeature.setTableProperties(propertyBld.build());
206 testTable = tableFeature.build();
210 private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
211 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
213 //To set the ApplyActionsMiss
214 List<Action> actionList = new ArrayList<Action>();
215 ActionBuilder ab = new ActionBuilder();
217 ab.setAction(new PopMplsActionCaseBuilder().build());
218 actionList.add(ab.build());
220 tableFeatureProperty.setTableFeaturePropType(
221 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder()
222 .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build());
224 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
225 tableFeatureProperty.setKey(keyValue);
226 tableFeatureProperty.setOrder(1);
228 return tableFeatureProperty;
232 private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
233 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
234 List<Action> actionListt5 = new ArrayList<Action>();
235 ActionBuilder abt5 = new ActionBuilder();
237 abt5.setAction(new PopMplsActionCaseBuilder().build());
238 actionListt5.add(abt5.build());
240 tableFeatureProperty.setTableFeaturePropType(
241 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder()
242 .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build());
244 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
245 tableFeatureProperty.setKey(keyValue);
246 tableFeatureProperty.setOrder(1);
248 return tableFeatureProperty;
251 private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
252 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
253 List<Short> nextTblIds = Arrays.asList(new Short[]{2, 3});
254 NextTableBuilder nextTblBld = new NextTableBuilder();
256 nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build());
257 tableFeatureProperty.setTableFeaturePropType(nextTblBld.build());
259 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
260 tableFeatureProperty.setKey(keyValue);
261 tableFeatureProperty.setOrder(1);
263 return tableFeatureProperty;
266 private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
267 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
268 List<Short> nextTblMissIds = Arrays.asList(new Short[]{23, 24, 25, 27, 28, 29, 30});
269 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder();
271 nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build());
272 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build());
274 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
275 tableFeatureProperty.setKey(keyValue);
276 tableFeatureProperty.setOrder(1);
278 return tableFeatureProperty;
282 private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
283 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
285 List<Instruction> instLst = new ArrayList<Instruction>();
286 InstructionBuilder ib = new InstructionBuilder();
288 ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder().build());
289 ib.setKey(new InstructionKey(1));
291 tableFeatureProperty.setTableFeaturePropType(
292 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder().setInstructions(
293 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());
296 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
297 tableFeatureProperty.setKey(keyValue);
298 tableFeatureProperty.setOrder(1);
300 return tableFeatureProperty;
303 private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
304 // To set the instructions miss -- "t7"
305 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
307 List<Instruction> instLst = new ArrayList<Instruction>();
308 InstructionBuilder ib1 = new InstructionBuilder();
310 ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder().build());
311 ib1.setKey(new InstructionKey(1));
313 InstructionBuilder ib2 = new InstructionBuilder();
315 ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder().build());
316 ib2.setKey(new InstructionKey(2));
318 tableFeatureProperty.setTableFeaturePropType(
319 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
320 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());
323 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
324 tableFeatureProperty.setKey(keyValue);
325 tableFeatureProperty.setOrder(1);
327 return tableFeatureProperty;
330 private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
332 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
334 List<Action> actionList = new ArrayList<Action>();
336 ActionBuilder abt1 = new ActionBuilder();
337 abt1.setAction(new CopyTtlOutCaseBuilder().build());
338 actionList.add(abt1.build());
340 ActionBuilder abt2 = new ActionBuilder();
341 abt2.setAction(new PopVlanActionCaseBuilder().build());
342 actionList.add(abt2.build());
344 tableFeatureProperty.setTableFeaturePropType(
345 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder()
346 .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());
348 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
349 tableFeatureProperty.setKey(keyValue);
350 tableFeatureProperty.setOrder(1);
352 return tableFeatureProperty;
355 private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
357 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
359 List<Action> actionList = new ArrayList<Action>();
361 ActionBuilder abt1 = new ActionBuilder();
362 abt1.setAction(new CopyTtlInCaseBuilder().build());
363 actionList.add(abt1.build());
365 ActionBuilder abt2 = new ActionBuilder();
366 abt2.setAction(new PushPbbActionCaseBuilder().build());
367 actionList.add(abt2.build());
369 tableFeatureProperty.setTableFeaturePropType(
370 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder()
371 .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());
373 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
374 tableFeatureProperty.setKey(keyValue);
375 tableFeatureProperty.setOrder(1);
377 return tableFeatureProperty;
380 private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
382 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
385 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
386 SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder();
387 setFieldMatchBld.setHasMask(false);
388 setFieldMatchBld.setMatchType(MplsLabel.class);
391 setFieldMatch.add(setFieldMatchBld.build());
392 MatchBuilder matchBld = new MatchBuilder();
393 MatchSetfieldBuilder matchSetfieldBld = new MatchSetfieldBuilder();
394 matchSetfieldBld.setSetFieldMatch(setFieldMatch);
395 matchBld.setMatchSetfield(matchSetfieldBld.build());
397 tableFeatureProperty.setTableFeaturePropType(matchBld.build());
398 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
399 tableFeatureProperty.setKey(keyValue);
400 tableFeatureProperty.setOrder(1);
402 return tableFeatureProperty;
406 private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
408 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
410 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
411 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
412 setFieldMatchBld1.setHasMask(false);
413 setFieldMatchBld1.setMatchType(MplsLabel.class);
415 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
416 setFieldMatchBld2.setHasMask(true);
417 setFieldMatchBld2.setMatchType(MplsBos.class);
419 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
420 setFieldMatchBld3.setHasMask(true);
421 setFieldMatchBld3.setMatchType(EthDst.class);
423 setFieldMatch.add(setFieldMatchBld1.build());
424 setFieldMatch.add(setFieldMatchBld2.build());
425 setFieldMatch.add(setFieldMatchBld3.build());
427 WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder();
428 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder writeSetfieldBuilder =
429 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder();
430 writeSetfieldBuilder.setSetFieldMatch(setFieldMatch);
431 writeSetfieldBld.setWriteSetfield(writeSetfieldBuilder.build());
434 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
435 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
436 tableFeatureProperty.setKey(keyValue);
437 tableFeatureProperty.setOrder(1);
439 return tableFeatureProperty;
442 private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
444 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
446 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
447 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
448 setFieldMatchBld1.setHasMask(false);
449 setFieldMatchBld1.setMatchType(EthSrc.class);
451 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
452 setFieldMatchBld2.setHasMask(true);
453 setFieldMatchBld2.setMatchType(InPort.class);
455 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
456 setFieldMatchBld3.setHasMask(true);
457 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
459 setFieldMatch.add(setFieldMatchBld1.build());
460 setFieldMatch.add(setFieldMatchBld2.build());
461 setFieldMatch.add(setFieldMatchBld3.build());
463 WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder();
464 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder writeSetfieldMissBuilder =
465 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder();
466 writeSetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
467 writeSetfieldBld.setWriteSetfieldMiss(writeSetfieldMissBuilder.build());
469 tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build());
470 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
471 tableFeatureProperty.setKey(keyValue);
472 tableFeatureProperty.setOrder(1);
474 return tableFeatureProperty;
477 private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
479 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
481 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
482 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
483 setFieldMatchBld1.setHasMask(false);
484 setFieldMatchBld1.setMatchType(ArpOp.class);
486 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
487 setFieldMatchBld2.setHasMask(true);
488 setFieldMatchBld2.setMatchType(InPort.class);
490 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
491 setFieldMatchBld3.setHasMask(true);
492 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
494 setFieldMatch.add(setFieldMatchBld1.build());
495 setFieldMatch.add(setFieldMatchBld2.build());
496 setFieldMatch.add(setFieldMatchBld3.build());
498 ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder();
499 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder =
500 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder();
501 applySetfieldBuilder.setSetFieldMatch(setFieldMatch);
502 applySetfieldBld.setApplySetfield(applySetfieldBuilder.build());
504 tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build());
505 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
506 tableFeatureProperty.setKey(keyValue);
507 tableFeatureProperty.setOrder(1);
509 return tableFeatureProperty;
512 private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
514 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
516 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
517 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
518 setFieldMatchBld1.setHasMask(false);
519 setFieldMatchBld1.setMatchType(ArpOp.class);
521 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
522 setFieldMatchBld2.setHasMask(true);
523 setFieldMatchBld2.setMatchType(InPort.class);
525 SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder();
526 setFieldMatchBld3.setHasMask(true);
527 setFieldMatchBld3.setMatchType(Ipv4Dst.class);
529 setFieldMatch.add(setFieldMatchBld1.build());
530 setFieldMatch.add(setFieldMatchBld2.build());
531 setFieldMatch.add(setFieldMatchBld3.build());
533 ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder();
534 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder applySetfieldMissBuilder =
535 new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder();
536 applySetfieldMissBuilder.setSetFieldMatch(setFieldMatch);
537 applySetfieldMissBld.setApplySetfieldMiss(applySetfieldMissBuilder.build());
539 tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build());
540 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
541 tableFeatureProperty.setKey(keyValue);
542 tableFeatureProperty.setOrder(1);
544 return tableFeatureProperty;
547 private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
549 TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
551 List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>();
552 SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder();
553 setFieldMatchBld1.setHasMask(false);
554 setFieldMatchBld1.setMatchType(ArpOp.class);
556 SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder();
557 setFieldMatchBld2.setHasMask(true);
558 setFieldMatchBld2.setMatchType(InPort.class);
561 setFieldMatch.add(setFieldMatchBld1.build());
562 setFieldMatch.add(setFieldMatchBld2.build());
564 WildcardsBuilder wildCardsBld = new WildcardsBuilder();
565 WildcardSetfieldBuilder wildcardsBuilder =
566 new WildcardSetfieldBuilder();
567 wildcardsBuilder.setSetFieldMatch(setFieldMatch);
568 wildCardsBld.setWildcardSetfield(wildcardsBuilder.build());
570 tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build());
571 TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0);
572 tableFeatureProperty.setKey(keyValue);
573 tableFeatureProperty.setOrder(1);
575 return tableFeatureProperty;
579 private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
580 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
582 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
583 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
584 child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
587 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
588 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
589 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
590 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
591 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
592 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
594 public void onSuccess(Void aVoid) {
595 ci.println("Status of Group Data Loaded Transaction: success.");
599 public void onFailure(Throwable throwable) {
600 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
602 }, MoreExecutors.directExecutor());
605 public void _modifyTable(CommandInterpreter ci) {
606 String nref = ci.nextArgument();
607 ci.println(" Table Command Provider modify");
610 ci.println("test node added");
613 ci.println("User node added" + nref);
614 createUserNode(nref);
616 String tableFeatureType = ci.nextArgument();
617 TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
619 writeTableFeatures(ci, tableFeaturesBld.build());
623 public String getHelp() {
624 StringBuilder help = new StringBuilder();
625 help.append("---FRM MD-SAL Table test module---\n");
626 help.append("\t modifyTable <node id> - node ref\n");
628 return help.toString();