Remove unused imports
[openflowplugin.git] / samples / sample-consumer / src / main / java / org / opendaylight / openflowplugin / openflow / samples / consumer / SimpleDropFirewallCli.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.samples.consumer;
9
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
28
29 public class SimpleDropFirewallCli {
30
31     private SimpleDropFirewall service;
32
33     public void setService(final SimpleDropFirewall service) {
34         this.service = service;
35     }
36
37     /**
38      * Form of input is:
39      *
40      * node name node-connector number source ip-address destinatinon ip-address
41      *
42      * @param cliInput
43      *            Parsed input from CLI
44      * @return
45      */
46     public AddFlowInput createTcpFlow(final List<String> cliInput) {
47         AddFlowInputBuilder ret = new AddFlowInputBuilder();
48         ret.setNode(nodeFromString(cliInput.get(0)));
49
50         // We construct a match
51         MatchBuilder match = new MatchBuilder();
52
53         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
54
55         ipv4Match.setIpv4Source(new Ipv4Prefix(cliInput.get(3)));
56         ipv4Match.setIpv4Destination(new Ipv4Prefix(cliInput.get(4)));
57
58         match.setLayer3Match(ipv4Match.build());
59
60         match.setLayer4Match(new TcpMatchBuilder().build());
61
62         ret.setMatch(match.build());
63
64         DropActionCase dropAction = new DropActionCaseBuilder().build();
65
66         ActionBuilder action = new ActionBuilder();
67         action.setAction(dropAction);
68
69         List<Action> actions = Collections.singletonList(action.build());
70         //
71         ApplyActionsCaseBuilder aaBldr = new ApplyActionsCaseBuilder();
72         aaBldr.setApplyActions(new ApplyActionsBuilder().setAction(actions).build());
73
74         InstructionBuilder instructionBldr = new InstructionBuilder();
75         instructionBldr.setInstruction(aaBldr.build());
76
77         List<Instruction> isntructions = Collections.singletonList(instructionBldr.build());
78         InstructionsBuilder instructionsBldr = new InstructionsBuilder();
79                 instructionsBldr.setInstruction(isntructions);
80
81         ret.setInstructions(instructionsBldr.build());
82
83         return ret.build();
84     }
85
86     private NodeRef nodeFromString(final String string) {
87         // TODO Auto-generated method stub
88         return null;
89     }
90
91 }