blob: b83460322628731c097952c82ec4a657054d48f8 [file] [log] [blame]
Jonathan Hart8f6dc092014-04-18 15:56:43 -07001package net.onrc.onos.apps.sdnip;
Jonathan Hart1236a9b2013-06-18 22:10:05 +12002
Jonathan Hart4dfc3652013-08-02 20:22:36 +12003import java.util.Collections;
Jonathan Hart1236a9b2013-06-18 22:10:05 +12004import java.util.List;
Jonathan Hart1236a9b2013-06-18 22:10:05 +12005
Jonathan Hart2f790d22013-08-15 14:01:24 +12006import net.floodlightcontroller.util.MACAddress;
7
Jonathan Hart1236a9b2013-06-18 22:10:05 +12008import org.codehaus.jackson.annotate.JsonProperty;
Jonathan Hartc78b8f62014-08-07 22:31:09 -07009import org.projectfloodlight.openflow.util.HexString;
Jonathan Hart1236a9b2013-06-18 22:10:05 +120010
Jonathan Hart31e15f12014-04-10 10:33:00 -070011/**
12 * Contains the configuration data for SDN-IP that has been read from a
13 * JSON-formatted configuration file.
14 */
Jonathan Hart1236a9b2013-06-18 22:10:05 +120015public class Configuration {
Ray Milkey269ffb92014-04-03 14:43:30 -070016 private long bgpdAttachmentDpid;
17 private short bgpdAttachmentPort;
18 private MACAddress bgpdMacAddress;
19 private short vlan;
20 private List<String> switches;
21 private List<Interface> interfaces;
22 private List<BgpPeer> peers;
Jonathan Hart1236a9b2013-06-18 22:10:05 +120023
Jonathan Hart31e15f12014-04-10 10:33:00 -070024 /**
25 * Default constructor.
26 */
Ray Milkey269ffb92014-04-03 14:43:30 -070027 public Configuration() {
28 // TODO Auto-generated constructor stub
29 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120030
Jonathan Hart31e15f12014-04-10 10:33:00 -070031 /**
32 * Gets the switch that BGPd is attached to.
33 *
34 * @return the dpid of BGPd's attachment point
35 */
Ray Milkey269ffb92014-04-03 14:43:30 -070036 public long getBgpdAttachmentDpid() {
37 return bgpdAttachmentDpid;
38 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120039
Jonathan Hart31e15f12014-04-10 10:33:00 -070040 /**
41 * Sets the switch that BGPd is attached to.
42 *
43 * @param bgpdAttachmentDpid the dpid of BGPd's attachment point
44 */
Ray Milkey269ffb92014-04-03 14:43:30 -070045 @JsonProperty("bgpdAttachmentDpid")
46 public void setBgpdAttachmentDpid(String bgpdAttachmentDpid) {
47 this.bgpdAttachmentDpid = HexString.toLong(bgpdAttachmentDpid);
48 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120049
Jonathan Hart31e15f12014-04-10 10:33:00 -070050 /**
51 * Gets the port that BGPd is attached to.
52 *
53 * @return the port number on the switch where BGPd is attached
54 */
Ray Milkey269ffb92014-04-03 14:43:30 -070055 public short getBgpdAttachmentPort() {
56 return bgpdAttachmentPort;
57 }
Jonathan Hart2f790d22013-08-15 14:01:24 +120058
Jonathan Hart31e15f12014-04-10 10:33:00 -070059 /**
60 * Sets the port that BGPd is attached to.
61 *
62 * @param bgpdAttachmentPort the port number on the switch where BGPd is
63 * attached
64 */
Ray Milkey269ffb92014-04-03 14:43:30 -070065 @JsonProperty("bgpdAttachmentPort")
66 public void setBgpdAttachmentPort(short bgpdAttachmentPort) {
67 this.bgpdAttachmentPort = bgpdAttachmentPort;
68 }
Jonathan Hart1236a9b2013-06-18 22:10:05 +120069
Jonathan Hart31e15f12014-04-10 10:33:00 -070070 /**
71 * Gets the MAC address of the BGPd host interface.
72 *
73 * @return the MAC address
74 */
Ray Milkey269ffb92014-04-03 14:43:30 -070075 public MACAddress getBgpdMacAddress() {
76 return bgpdMacAddress;
77 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120078
Jonathan Hart31e15f12014-04-10 10:33:00 -070079 /**
80 * Sets the MAC address of the BGPd host interface.
81 *
82 * @param strMacAddress the MAC address
83 */
Ray Milkey269ffb92014-04-03 14:43:30 -070084 @JsonProperty("bgpdMacAddress")
85 public void setBgpdMacAddress(String strMacAddress) {
86 this.bgpdMacAddress = MACAddress.valueOf(strMacAddress);
87 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +120088
Jonathan Hart31e15f12014-04-10 10:33:00 -070089 /**
90 * Gets a list of the DPIDs of all switches in the system. The DPIDs are
91 * in String format represented in hexadecimal.
92 *
93 * @return the list of DPIDs
94 */
Ray Milkey269ffb92014-04-03 14:43:30 -070095 public List<String> getSwitches() {
96 return Collections.unmodifiableList(switches);
97 }
98
Jonathan Hart31e15f12014-04-10 10:33:00 -070099 /**
100 * Sets a list of DPIDs of all switches in the system.
101 *
102 * @param switches the list of DPIDs
103 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700104 @JsonProperty("switches")
105 public void setSwitches(List<String> switches) {
106 this.switches = switches;
107 }
108
Jonathan Hart31e15f12014-04-10 10:33:00 -0700109 /**
110 * Gets the VLAN number of the VLAN the system is running in, if any.
111 * 0 means we are not running in a VLAN.
112 *
113 * @return the VLAN number if we are running in a VLAN, otherwise 0
114 */
115 public short getVlan() {
116 return vlan;
117 }
118
119 /**
120 * Sets the VLAN number of the VLAN the system is running in.
121 *
122 * @param vlan the VLAN number
123 */
124 @JsonProperty("vlan")
125 public void setVlan(short vlan) {
126 this.vlan = vlan;
127 }
128
129 /**
130 * Gets a list of interfaces in the system, represented by
131 * {@link Interface} objects.
132 *
133 * @return the list of interfaces
134 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700135 public List<Interface> getInterfaces() {
136 return Collections.unmodifiableList(interfaces);
137 }
138
Jonathan Hart31e15f12014-04-10 10:33:00 -0700139 /**
140 * Sets a list of interfaces in the system.
141 *
142 * @param interfaces the list of interfaces
143 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700144 @JsonProperty("interfaces")
145 public void setInterfaces(List<Interface> interfaces) {
146 this.interfaces = interfaces;
147 }
148
Jonathan Hart31e15f12014-04-10 10:33:00 -0700149 /**
150 * Gets a list of BGP peers we are configured to peer with. Peers are
151 * represented by {@link BgpPeer} objects.
152 *
153 * @return the list of BGP peers
154 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700155 public List<BgpPeer> getPeers() {
156 return Collections.unmodifiableList(peers);
157 }
158
Jonathan Hart31e15f12014-04-10 10:33:00 -0700159 /**
160 * Sets a list of BGP peers we are configured to peer with.
161 *
162 * @param peers the list of BGP peers
163 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700164 @JsonProperty("bgpPeers")
165 public void setPeers(List<BgpPeer> peers) {
166 this.peers = peers;
167 }
Jonathan Hart832a7cb2013-06-24 11:25:35 +1200168
Jonathan Hart1236a9b2013-06-18 22:10:05 +1200169}