Table Features Requests Fix and TestCases
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTableFeaturesTestCommandProvider.java
1 package org.opendaylight.openflowplugin.test;
2
3 import java.math.BigInteger;
4 import java.util.ArrayList;
5 import java.util.Arrays;
6 import java.util.List;
7 import java.util.concurrent.ExecutionException;
8 import java.util.concurrent.Future;
9
10 import org.eclipse.osgi.framework.console.CommandInterpreter;
11 import org.eclipse.osgi.framework.console.CommandProvider;
12 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
13 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
25
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
28
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
39
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder;
52
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder ;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder ;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField; 
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc;
86 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
87 import org.opendaylight.yangtools.yang.common.RpcResult;
88 import org.osgi.framework.BundleContext;
89
90
91 public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
92
93     private DataBrokerService dataBrokerService;
94     private ProviderContext pc;
95     private final BundleContext ctx;
96     private Table testTable;
97     private Node testNode;
98     private final String originalTableName = "Foo";
99     private final String updatedTableName = "Bar";
100
101     public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
102         this.ctx = ctx;
103     }
104
105     public void onSessionInitiated(ProviderContext session) {
106         pc = session;
107         dataBrokerService = session.getSALService(DataBrokerService.class);
108         ctx.registerService(CommandProvider.class.getName(), this, null);
109        // createTestNode();
110        // createTestTable();
111     }
112
113     private void createUserNode(String nodeRef) {        
114         NodeBuilder builder = new NodeBuilder();
115         builder.setId(new NodeId(nodeRef));
116         builder.setKey(new NodeKey(builder.getId()));
117         testNode = builder.build();
118     }
119     
120     private void createTestNode() {       
121         NodeBuilder builder = new NodeBuilder();
122         builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
123         builder.setKey(new NodeKey(builder.getId()));
124         testNode = builder.build();
125     }
126
127     private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
128         return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
129     }
130
131     private TableBuilder createTestTable(String tableFeatureTypeArg) {
132         
133          String tableFeatureType = tableFeatureTypeArg;
134          if (tableFeatureType == null) {
135              tableFeatureType = "t1";
136          }
137         // Sample data , committing to DataStore
138         DataModification modification = dataBrokerService.beginTransaction();
139         short id = 12;
140         TableKey key = new TableKey(id) ;
141         
142         TableBuilder table = new TableBuilder();
143         table.setId((short)12) ;
144         table.setId(id) ;
145         table.setKey(key) ;
146         
147         
148         List<TableFeatures> ofTablefeatures = new ArrayList<TableFeatures>() ;
149         
150      // Skip this to send empty table features
151         if( ! tableFeatureType.equals( "t1")) {
152                 
153        
154         TableFeaturesBuilder tableFeature1 = new TableFeaturesBuilder() ;
155         tableFeature1.setTableId(new Short((short)0));
156         tableFeature1.setName("Table 0");
157         
158                 
159         tableFeature1.setMetadataMatch((new BigInteger("10", 10)));
160         tableFeature1.setMetadataWrite((new BigInteger("10", 10)));
161         tableFeature1.setMaxEntries(new Long(10000)) ;
162    
163         tableFeature1.setConfig(new TableConfig(false));
164         
165         List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>() ;
166         
167              
168        switch( tableFeatureType) {
169         case "t2" :
170                 //To set the ApplyActionsMiss
171                 properties.add(createApplyActionsMissTblFeatureProp().build()) ;
172                 break; 
173         case "t3" :  
174                 // To set the Next Table 
175                 properties.add(createNextTblFeatureProp().build()) ;
176             break ;
177         case "t4" :
178                 // To set the Next Table Miss
179                 properties.add(createNextTableMissTblFeatureProp().build()) ;
180                 break ;
181         case "t5" :
182                 //To set the ApplyActions
183                 properties.add(createApplyActionsTblFeatureProp().build()) ;
184                 break; 
185         case "t6" :
186                 // To set the instructions
187                 properties.add(createInstructionsTblFeatureProp().build());
188                 break ;
189         case "t7" :
190                 // To set the instructions miss
191                 properties.add(createInstructionsMissTblFeatureProp().build());
192                 break ;
193         case "t8" :
194                 // To set the write actions
195                 properties.add(createWriteActionsTblFeatureProp().build()) ;
196                 break ;
197         case "t9" :
198                 // To set the write actions miss 
199                 properties.add(createWriteActionsMissTblFeatureProp().build()) ;
200                 break ;
201         case "t10" :
202                 // To set the match field
203                 properties.add(createMatchFieldTblFeatureProp().build()) ;
204                 break ;
205         case "t11" :
206                 // To set the write set-field
207                 properties.add( createWriteSetFieldTblFeatureProp().build()) ;
208                 break ;
209         case "t12" :
210                 // To set the write set-field miss
211                 properties.add( createWriteSetFieldMissTblFeatureProp().build()) ;
212                 break ;
213         case "t13" :
214                 // To set the apply set field
215                 properties.add( createApplySetFieldTblFeatureProp().build()) ;
216                 break ;
217         case "t14" :
218                 // To set the apply set field miss
219                 properties.add( createApplySetFieldMissTblFeatureProp().build()) ;
220                 break ;
221         case "t15" :
222                 // To set the wildcards set field match 
223                 properties.add( createWildCardsTblFeatureProp().build()) ;
224                 break ;
225        }
226                   
227        
228         TablePropertiesBuilder propertyBld = new TablePropertiesBuilder() ;
229         propertyBld.setTableFeatureProperties(properties) ;
230         tableFeature1.setTableProperties(propertyBld.build()); 
231        
232                 
233         ofTablefeatures.add(tableFeature1.build()) ;
234      
235         } 
236         table.setTableFeatures(ofTablefeatures) ;
237                      
238         testTable = table.build();
239         return table;
240     }
241
242     private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
243          TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
244         
245         //To set the ApplyActionsMiss
246                 List<Action> actionList = new ArrayList<Action>();
247          ActionBuilder ab = new ActionBuilder();
248
249          ab.setAction(new PopMplsActionCaseBuilder().build());
250          actionList.add(ab.build());
251                         
252          tableFeatureProperty.setTableFeaturePropType(
253                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder()
254                   .setApplyActionsMiss(new ApplyActionsMissBuilder().setAction(actionList).build()).build()) ;
255          
256          TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
257          tableFeatureProperty.setKey(keyValue) ;
258          tableFeatureProperty.setOrder(1) ;
259          
260          return tableFeatureProperty ;
261          
262     }
263     
264     private TableFeaturePropertiesBuilder createApplyActionsTblFeatureProp() {
265         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
266         List<Action> actionListt5 = new ArrayList<Action>();
267         ActionBuilder abt5 = new ActionBuilder();
268
269         abt5.setAction(new PopMplsActionCaseBuilder().build());
270         actionListt5.add(abt5.build());
271                        
272         tableFeatureProperty.setTableFeaturePropType(
273                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder()
274                   .setApplyActions(new ApplyActionsBuilder().setAction(actionListt5).build()).build()) ;
275         
276         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
277         tableFeatureProperty.setKey(keyValue) ;
278         tableFeatureProperty.setOrder(1) ;
279         
280         return tableFeatureProperty ;
281     }
282     
283     private TableFeaturePropertiesBuilder createNextTblFeatureProp() {
284         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
285         List<Short> nextTblIds = Arrays.asList(new Short[] { 2, 3} );
286         NextTableBuilder nextTblBld = new NextTableBuilder() ; 
287                           
288         nextTblBld.setTables( new TablesBuilder().setTableIds(nextTblIds).build()) ;
289         tableFeatureProperty.setTableFeaturePropType(nextTblBld.build() ) ;
290         
291         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
292         tableFeatureProperty.setKey(keyValue) ;
293         tableFeatureProperty.setOrder(1) ;
294         
295         return tableFeatureProperty ;
296     }
297     
298     private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() {
299         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
300         List<Short> nextTblMissIds = Arrays.asList( new Short[] { 23, 24, 25, 27, 28, 29 , 30 } );
301                 NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder() ;
302                 
303                 nextTblMissBld.setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesBuilder().setTableIds(nextTblMissIds).build()) ;
304                 tableFeatureProperty.setTableFeaturePropType(nextTblMissBld.build() ) ;
305         
306         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
307         tableFeatureProperty.setKey(keyValue) ;
308         tableFeatureProperty.setOrder(1) ;
309         
310         return tableFeatureProperty ;
311     }
312     
313    
314     
315     private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
316         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
317         
318         List<Instruction> instLst = new ArrayList<Instruction>() ;
319         InstructionBuilder ib = new InstructionBuilder() ;
320         ib.setOrder(1) ;
321         ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder().build());
322         ib.setKey(new InstructionKey(1)) ;
323      
324         tableFeatureProperty.setTableFeaturePropType(
325                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder().setInstructions(
326                                  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() ) ;
327                   
328                   
329                              
330         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
331         tableFeatureProperty.setKey(keyValue) ;
332         tableFeatureProperty.setOrder(1) ;
333         
334         return tableFeatureProperty ;
335     }
336     
337     private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
338         // To set the instructions miss -- "t7"
339         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
340         
341         List<Instruction> instLst = new ArrayList<Instruction>() ;
342         InstructionBuilder ib1 = new InstructionBuilder() ;
343         ib1.setOrder(1) ;
344         ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder().build());
345         ib1.setKey(new InstructionKey(1)) ;
346         
347         InstructionBuilder ib2 = new InstructionBuilder() ;
348         ib2.setOrder(2) ;
349         ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder().build());
350         ib2.setKey(new InstructionKey(2)) ;
351      
352         tableFeatureProperty.setTableFeaturePropType(
353                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder().setInstructionsMiss(
354                                  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() ) ;
355                   
356                   
357                              
358         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
359         tableFeatureProperty.setKey(keyValue) ;
360         tableFeatureProperty.setOrder(1) ;
361         
362         return tableFeatureProperty ;
363     }
364     
365     private TableFeaturePropertiesBuilder createWriteActionsTblFeatureProp() {
366         // t8
367         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
368         
369         List<Action> actionList = new ArrayList<Action>();
370        
371         ActionBuilder abt1 = new ActionBuilder();
372         abt1.setAction(new CopyTtlOutCaseBuilder().build());
373         actionList.add(abt1.build());
374         
375         ActionBuilder abt2 = new ActionBuilder();
376         abt2.setAction(new PopVlanActionCaseBuilder().build());
377         actionList.add(abt2.build());
378                      
379         tableFeatureProperty.setTableFeaturePropType(
380                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder()
381                   .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()) ;
382         
383         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
384         tableFeatureProperty.setKey(keyValue) ;
385         tableFeatureProperty.setOrder(1) ;
386         
387         return tableFeatureProperty ;
388     }
389     
390     private TableFeaturePropertiesBuilder createWriteActionsMissTblFeatureProp() {
391         // t9
392         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
393         
394         List<Action> actionList = new ArrayList<Action>();
395        
396         ActionBuilder abt1 = new ActionBuilder();
397         abt1.setAction(new CopyTtlInCaseBuilder().build());
398         actionList.add(abt1.build());
399         
400         ActionBuilder abt2 = new ActionBuilder();
401         abt2.setAction(new PushPbbActionCaseBuilder().build());
402         actionList.add(abt2.build());
403                      
404         tableFeatureProperty.setTableFeaturePropType(
405                   new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder()
406                   .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()) ;
407         
408         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
409         tableFeatureProperty.setKey(keyValue) ;
410         tableFeatureProperty.setOrder(1) ;
411         
412         return tableFeatureProperty ;
413     }
414     private TableFeaturePropertiesBuilder createMatchFieldTblFeatureProp() {
415         //t10
416         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
417         
418         
419         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
420         SetFieldMatchBuilder setFieldMatchBld = new SetFieldMatchBuilder() ;
421         setFieldMatchBld.setHasMask(false) ;
422         setFieldMatchBld.setMatchType(MplsLabel.class) ;
423     
424         
425         setFieldMatch.add(setFieldMatchBld.build()) ;
426         MatchBuilder matchBld = new MatchBuilder() ;
427         matchBld.setSetFieldMatch(setFieldMatch) ;
428         
429         tableFeatureProperty.setTableFeaturePropType(matchBld.build()) ;
430         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
431         tableFeatureProperty.setKey(keyValue) ;
432         tableFeatureProperty.setOrder(1) ;
433         
434         return tableFeatureProperty ;
435     }
436     
437     
438     private TableFeaturePropertiesBuilder createWriteSetFieldTblFeatureProp() {
439         //t11
440         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
441         
442         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
443         SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
444         setFieldMatchBld1.setHasMask(false) ;
445         setFieldMatchBld1.setMatchType(MplsLabel.class) ;
446     
447         SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
448         setFieldMatchBld2.setHasMask(true) ;
449         setFieldMatchBld2.setMatchType(MplsBos.class) ;
450         
451         SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
452         setFieldMatchBld3.setHasMask(true) ;
453         setFieldMatchBld3.setMatchType(EthDst.class) ;
454         
455         setFieldMatch.add(setFieldMatchBld1.build()) ;
456         setFieldMatch.add(setFieldMatchBld2.build()) ;
457         setFieldMatch.add(setFieldMatchBld3.build()) ;
458         
459         WriteSetfieldBuilder writeSetfieldBld = new WriteSetfieldBuilder() ;
460         writeSetfieldBld.setSetFieldMatch(setFieldMatch) ;
461         
462         tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
463         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
464         tableFeatureProperty.setKey(keyValue) ;
465         tableFeatureProperty.setOrder(1) ;
466         
467         return tableFeatureProperty ;
468     }
469      
470     private TableFeaturePropertiesBuilder createWriteSetFieldMissTblFeatureProp() {
471         // t12
472         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
473         
474         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
475         SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
476         setFieldMatchBld1.setHasMask(false) ;
477         setFieldMatchBld1.setMatchType(EthSrc.class) ;
478     
479         SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
480         setFieldMatchBld2.setHasMask(true) ;
481         setFieldMatchBld2.setMatchType(InPort.class) ;
482         
483         SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
484         setFieldMatchBld3.setHasMask(true) ;
485         setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
486         
487         setFieldMatch.add(setFieldMatchBld1.build()) ;
488         setFieldMatch.add(setFieldMatchBld2.build()) ;
489         setFieldMatch.add(setFieldMatchBld3.build()) ;
490         
491         WriteSetfieldMissBuilder writeSetfieldBld = new WriteSetfieldMissBuilder() ;
492         writeSetfieldBld.setSetFieldMatch(setFieldMatch) ;
493         
494         tableFeatureProperty.setTableFeaturePropType(writeSetfieldBld.build()) ;
495         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
496         tableFeatureProperty.setKey(keyValue) ;
497         tableFeatureProperty.setOrder(1) ;
498         
499         return tableFeatureProperty ;
500     }
501     
502     private TableFeaturePropertiesBuilder createApplySetFieldTblFeatureProp() {
503         //t13
504         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
505         
506         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
507         SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
508         setFieldMatchBld1.setHasMask(false) ;
509         setFieldMatchBld1.setMatchType(ArpOp.class) ;
510     
511         SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
512         setFieldMatchBld2.setHasMask(true) ;
513         setFieldMatchBld2.setMatchType(InPort.class) ;
514         
515         SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
516         setFieldMatchBld3.setHasMask(true) ;
517         setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
518         
519         setFieldMatch.add(setFieldMatchBld1.build()) ;
520         setFieldMatch.add(setFieldMatchBld2.build()) ;
521         setFieldMatch.add(setFieldMatchBld3.build()) ;
522         
523         ApplySetfieldBuilder applySetfieldBld = new ApplySetfieldBuilder() ;
524         applySetfieldBld.setSetFieldMatch(setFieldMatch) ;
525         
526         tableFeatureProperty.setTableFeaturePropType(applySetfieldBld.build()) ;
527         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
528         tableFeatureProperty.setKey(keyValue) ;
529         tableFeatureProperty.setOrder(1) ;
530         
531         return tableFeatureProperty ;
532     }
533     
534     private TableFeaturePropertiesBuilder createApplySetFieldMissTblFeatureProp() {
535         //t14
536         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
537         
538         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
539         SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
540         setFieldMatchBld1.setHasMask(false) ;
541         setFieldMatchBld1.setMatchType(ArpOp.class) ;
542     
543         SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
544         setFieldMatchBld2.setHasMask(true) ;
545         setFieldMatchBld2.setMatchType(InPort.class) ;
546         
547         SetFieldMatchBuilder setFieldMatchBld3 = new SetFieldMatchBuilder() ;
548         setFieldMatchBld3.setHasMask(true) ;
549         setFieldMatchBld3.setMatchType(Ipv4Dst.class) ;
550         
551         setFieldMatch.add(setFieldMatchBld1.build()) ;
552         setFieldMatch.add(setFieldMatchBld2.build()) ;
553         setFieldMatch.add(setFieldMatchBld3.build()) ;
554         
555         ApplySetfieldMissBuilder applySetfieldMissBld = new ApplySetfieldMissBuilder() ;
556         applySetfieldMissBld.setSetFieldMatch(setFieldMatch) ;
557         
558         tableFeatureProperty.setTableFeaturePropType(applySetfieldMissBld.build()) ;
559         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
560         tableFeatureProperty.setKey(keyValue) ;
561         tableFeatureProperty.setOrder(1) ;
562         
563         return tableFeatureProperty ;
564     }
565     
566     private TableFeaturePropertiesBuilder createWildCardsTblFeatureProp() {
567         //t15
568         TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder() ;
569         
570         List<SetFieldMatch> setFieldMatch = new ArrayList<SetFieldMatch>() ;
571         SetFieldMatchBuilder setFieldMatchBld1 = new SetFieldMatchBuilder() ;
572         setFieldMatchBld1.setHasMask(false) ;
573         setFieldMatchBld1.setMatchType(ArpOp.class) ;
574     
575         SetFieldMatchBuilder setFieldMatchBld2 = new SetFieldMatchBuilder() ;
576         setFieldMatchBld2.setHasMask(true) ;
577         setFieldMatchBld2.setMatchType(InPort.class) ;
578         
579                 
580         setFieldMatch.add(setFieldMatchBld1.build()) ;
581         setFieldMatch.add(setFieldMatchBld2.build()) ;
582         
583         WildcardsBuilder wildCardsBld = new WildcardsBuilder() ;
584         wildCardsBld.setSetFieldMatch(setFieldMatch) ;
585         
586         tableFeatureProperty.setTableFeaturePropType(wildCardsBld.build()) ;
587         TableFeaturePropertiesKey keyValue = new TableFeaturePropertiesKey(0) ;
588         tableFeatureProperty.setKey(keyValue) ;
589         tableFeatureProperty.setOrder(1) ;
590         
591         return tableFeatureProperty ;
592     }
593        
594     
595     private void writeTable(CommandInterpreter ci, Table table) {
596         DataModification modification = dataBrokerService.beginTransaction();
597                
598         InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
599                 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
600                 child(Table.class, new TableKey(table.getId())).build() ;
601                 
602                         
603         modification.putOperationalData(nodeToInstanceId(testNode), testNode);
604         modification.putOperationalData(path1, table);
605         modification.putConfigurationData(nodeToInstanceId(testNode), testNode);
606         modification.putConfigurationData(path1, table);
607         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
608         try {
609             RpcResult<TransactionStatus> result = commitFuture.get();
610             TransactionStatus status = result.getResult();
611             ci.println("Status of Table Data Loaded Transaction: " + status);
612
613         } catch (InterruptedException e) {
614             // TODO Auto-generated catch block
615             e.printStackTrace();
616         } catch (ExecutionException e) {
617             // TODO Auto-generated catch block
618             e.printStackTrace();
619         }
620     }
621
622     public void _modifyTable(CommandInterpreter ci) {
623         String nref = ci.nextArgument();
624         ci.println( " Table Command Provider modify" ) ;
625         
626         if (nref == null) {
627             ci.println("test node added");
628             createTestNode();
629         } else {
630             ci.println("User node added" + nref);
631             createUserNode(nref);
632         }
633         String tableFeatureType = ci.nextArgument() ;
634         TableBuilder table = createTestTable(tableFeatureType); 
635            
636         writeTable(ci, table.build());
637     }
638     
639     @Override
640     public String getHelp() {
641         StringBuffer help = new StringBuffer();
642         help.append("---FRM MD-SAL Table test module---\n");
643         help.append("\t modifyTable <node id>        - node ref\n");
644                
645         return help.toString();
646     }    
647    
648 }
649