Updated demo scripts: the demo now outputs per-protocol information.
[affinity.git] / nfchainagent / src / main / java / org / opendaylight / affinity / nfchainagent / NFchainconfig.java
1 package org.opendaylight.affinity.nfchainagent;
2
3 import org.opendaylight.controller.sal.utils.NetUtils;
4 import java.io.Serializable;
5 import java.net.InetAddress;
6 import java.net.UnknownHostException;
7 import java.util.List;
8 import java.util.ArrayList;
9
10 import org.opendaylight.controller.sal.utils.Status;
11 import org.opendaylight.controller.sal.utils.StatusCode;
12
13 import javax.ws.rs.Consumes;
14 import javax.ws.rs.DELETE;
15 import javax.ws.rs.GET;
16 import javax.ws.rs.POST;
17 import javax.ws.rs.PUT;
18 import javax.ws.rs.Path;
19 import javax.ws.rs.PathParam;
20 import javax.ws.rs.Produces;
21 import javax.ws.rs.core.Context;
22 import javax.ws.rs.core.MediaType;
23 import javax.ws.rs.core.Response;
24 import javax.ws.rs.core.SecurityContext;
25
26 import org.codehaus.enunciate.jaxrs.ResponseCode;
27 import org.codehaus.enunciate.jaxrs.StatusCodes;
28 import org.codehaus.enunciate.jaxrs.TypeHint;
29
30 import javax.xml.bind.annotation.XmlAccessType;
31 import javax.xml.bind.annotation.XmlAccessorType;
32 import javax.xml.bind.annotation.XmlAttribute;
33 import javax.xml.bind.annotation.XmlElement;
34 import javax.xml.bind.annotation.XmlRootElement;
35
36 import org.opendaylight.controller.sal.flowprogrammer.Flow;
37
38 /** 
39  * Configuration object representing a network function chain. 
40  * flowlist is the set of flows to be redirected. 
41  * dstIP is the singleton waypoint, representing the waypoint server. 
42  */
43
44 @XmlRootElement
45 @XmlAccessorType(XmlAccessType.NONE)
46 public class NFchainconfig implements Cloneable, Serializable {
47     private static final long serialVersionUID = 1L;
48
49     @XmlAttribute
50     private String name;
51     @XmlElement
52     private final List<Flow> flowlist;
53     private InetAddress dstIP;
54     
55     public NFchainconfig(String name) {
56         this.name = name;
57         flowlist = new ArrayList<Flow>();
58         dstIP = null;
59     }
60
61     // Set the flowlist and destination IP of the network function. 
62     public NFchainconfig(String name, List<Flow> flowlist, InetAddress dstIP) {
63         this.name = name;
64         this.flowlist = flowlist;
65         this.dstIP = dstIP;
66     }
67
68     // add a flow to the flowlist. 
69     public Status addFlow(Flow f) {
70         flowlist.add(f);
71         return new Status(StatusCode.SUCCESS);
72     }
73
74     public List<Flow> getFlowList() {
75         return this.flowlist;
76     }
77     public InetAddress getWaypointIP() {
78         return this.dstIP;
79     }
80     public void print() {
81         System.out.println("Printing NFchain config " + this.name);
82         for (Flow value : flowlist) {
83             System.out.println("flow is " + value);
84         }
85     }
86     public String getName() {
87         return name;
88     }
89 }
90
91