blob: 9bce826dca805f0acf924523f84481a32e6f4ac2 [file] [log] [blame]
Saurav Dasfb93c252014-08-18 20:40:13 -07001package net.onrc.onos.core.configmanager;
2
3import java.util.ArrayList;
4import java.util.List;
5import java.util.Map;
6
7import org.codehaus.jackson.JsonNode;
8import org.projectfloodlight.openflow.util.HexString;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
12/**
13 * Public class corresponding to JSON described data model. Defines the network
14 * configuration at startup.
15 */
16public class NetworkConfig {
17 protected static final Logger log = LoggerFactory.getLogger(NetworkConfig.class);
18
19 @SuppressWarnings("unused")
20 private String comment;
21
22 private Boolean restrictSwitches;
23 private Boolean restrictLinks;
24 private List<SwitchConfig> switches;
25 private List<LinkConfig> links;
26 private List<List<String>> opticalReachability;
27
28 public NetworkConfig() {
29 switches = new ArrayList<SwitchConfig>();
30 links = new ArrayList<LinkConfig>();
31 opticalReachability = new ArrayList<List<String>>();
32 }
33
34 public void setComment(String c) {
35 comment = c;
36 }
37
38 public void setRestrictSwitches(boolean rs) {
39 restrictSwitches = rs;
40 }
41
42 public Boolean getRestrictSwitches() {
43 return restrictSwitches;
44 }
45
46 public void setRestrictLinks(boolean rl) {
47 restrictLinks = rl;
48 }
49
50 public Boolean getRestrictLinks() {
51 return restrictLinks;
52 }
53
54 // *********************
55 // switches
56 // *********************/
57
58 public List<SwitchConfig> getSwitchConfig() {
59 return switches;
60 }
61
62 public void setSwitchConfig(List<SwitchConfig> switches2) {
63 this.switches = switches2;
64 }
65
66 public static class SwitchConfig {
67 protected String name;
68 protected long dpid;
69 protected String nodeDpid;
70 protected String type;
71 protected double latitude;
72 protected double longitude;
73 protected boolean allowed;
74 protected Map<String, JsonNode> params;
75 protected Map<String, String> publishAttributes;
76
77 public String getName() {
78 return name;
79 }
80
81 public void setName(String name) {
82 this.name = name;
83 }
84
85 public long getDpid() {
86 return dpid;
87 }
88
89 public void setDpid(long dpid) {
90 this.dpid = dpid;
91 this.nodeDpid = HexString.toHexString(dpid);
92 }
93
94 public String getNodeDpid() {
95 return nodeDpid;
96 }
97
98 public String getHexDpid() {
99 return nodeDpid;
100 }
101
102 // mapper sets both long and string fields for dpid
103 public void setNodeDpid(String nodeDpid) {
104 this.nodeDpid = nodeDpid;
105 this.dpid = HexString.toLong(nodeDpid);
106 }
107
108 public String getType() {
109 return type;
110 }
111
112 public void setType(String type) {
113 this.type = type;
114 }
115
116 public double getLatitude() {
117 return latitude;
118 }
119
120 public void setLatitude(double latitude) {
121 this.latitude = latitude;
122 }
123
124 public double getLongitude() {
125 return longitude;
126 }
127
128 public void setLongitude(double longitude) {
129 this.longitude = longitude;
130 }
131
132 public boolean isAllowed() {
133 return allowed;
134 }
135
136 public void setAllowed(boolean allowed) {
137 this.allowed = allowed;
138 }
139
140 public Map<String, JsonNode> getParams() {
141 return params;
142 }
143
144 public void setParams(Map<String, JsonNode> params) {
145 this.params = params;
146 }
147
148 public Map<String, String> getPublishAttributes() {
149 return publishAttributes;
150 }
151
152 public void setPublishAttributes(Map<String, String> publishAttributes) {
153 this.publishAttributes = publishAttributes;
154 }
155
156 }
157
158 // *********************
159 // links
160 // *********************/
161
162 public void setLinkConfig(List<LinkConfig> links2) {
163 this.links = links2;
164 }
165
166 public List<LinkConfig> getLinkConfig() {
167 return links;
168 }
169
170 public static class LinkConfig {
171 protected String type;
172 protected Boolean allowed;
173 protected long dpid1;
174 protected long dpid2;
175 protected String nodeDpid1;
176 protected String nodeDpid2;
177 protected Map<String, JsonNode> params;
178 protected Map<String, String> publishAttributes;
179
180 public String getType() {
181 return type;
182 }
183
184 public void setType(String type) {
185 this.type = type;
186 }
187
188 public Boolean isAllowed() {
189 return allowed;
190 }
191
192 public void setAllowed(Boolean allowed) {
193 this.allowed = allowed;
194 }
195
196 public String getNodeDpid1() {
197 return nodeDpid1;
198 }
199
200 // mapper sets both long and string fields for dpid
201 public void setNodeDpid1(String nodeDpid1) {
202 this.nodeDpid1 = nodeDpid1;
203 this.dpid1 = HexString.toLong(nodeDpid1);
204 }
205
206 public String getNodeDpid2() {
207 return nodeDpid2;
208 }
209
210 // mapper sets both long and string fields for dpid
211 public void setNodeDpid2(String nodeDpid2) {
212 this.nodeDpid2 = nodeDpid2;
213 this.dpid2 = HexString.toLong(nodeDpid2);
214 }
215
216 public long getDpid1() {
217 return dpid1;
218 }
219
220 public void setDpid1(long dpid1) {
221 this.dpid1 = dpid1;
222 this.nodeDpid1 = HexString.toHexString(dpid1);
223 }
224
225 public long getDpid2() {
226 return dpid2;
227 }
228
229 public void setDpid2(long dpid2) {
230 this.dpid2 = dpid2;
231 this.nodeDpid2 = HexString.toHexString(dpid2);
232 }
233
234 public Map<String, JsonNode> getParams() {
235 return params;
236 }
237
238 public void setParams(Map<String, JsonNode> params) {
239 this.params = params;
240 }
241
242 public Map<String, String> getPublishAttributes() {
243 return publishAttributes;
244 }
245
246 public void setPublishAttributes(Map<String, String> publishAttributes) {
247 this.publishAttributes = publishAttributes;
248 }
249 }
250
251 // *********************
252 // optical reach matrix
253 // *********************/
254
255 public void setOpticalReachabilty(List<List<String>> opticalReach) {
256 this.opticalReachability = opticalReach;
257 }
258 public List<List<String>> getOpticalReachability() {
259 return opticalReachability;
260 }
261
262}
263