Add additional fields to Neutron Router
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronRouter.java
1 /*
2  * Copyright IBM Corporation, 2013.  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
9 package org.opendaylight.controller.networkconfig.neutron;
10
11 import java.io.Serializable;
12 import java.util.HashMap;
13 import java.util.Iterator;
14 import java.util.List;
15
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlRootElement;
20
21 import org.opendaylight.controller.configuration.ConfigurationObject;
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.NONE)
25
26 public class NeutronRouter extends ConfigurationObject implements Serializable, INeutronObject {
27     private static final long serialVersionUID = 1L;
28
29     // See OpenStack Network API v2.0 Reference for description of
30     // annotated attributes
31     @XmlElement (name="id")
32     String routerUUID;
33
34     @XmlElement (name="name")
35     String name;
36
37     @XmlElement (defaultValue="true", name="admin_state_up")
38     Boolean adminStateUp;
39
40     @XmlElement (name="status")
41     String status;
42
43     @XmlElement (name="tenant_id")
44     String tenantID;
45
46     @XmlElement (name="external_gateway_info", nillable=true)
47     NeutronRouter_NetworkReference externalGatewayInfo;
48
49     @XmlElement (name="distributed")
50     Boolean distributed;
51
52     @XmlElement (name="gw_port_id", nillable=true)
53     String gatewayPortId;
54
55     @XmlElement (name="routes")
56     List<String> routes;
57
58     /* Holds a map of OpenStackRouterInterfaces by subnet UUID
59      * used for internal mapping to DOVE
60      */
61     HashMap<String, NeutronRouter_Interface> interfaces;
62
63     public NeutronRouter() {
64         interfaces = new HashMap<String, NeutronRouter_Interface>();
65     }
66
67     public String getID() { return routerUUID; }
68
69     public void setID(String id) { this.routerUUID = id; }
70
71     public String getRouterUUID() {
72         return routerUUID;
73     }
74
75     public void setRouterUUID(String routerUUID) {
76         this.routerUUID = routerUUID;
77     }
78
79     public String getName() {
80         return name;
81     }
82
83     public void setName(String name) {
84         this.name = name;
85     }
86
87     public boolean isAdminStateUp() {
88         if (adminStateUp == null) {
89             return true;
90         }
91         return adminStateUp;
92     }
93
94     public Boolean getAdminStateUp() { return adminStateUp; }
95
96     public void setAdminStateUp(Boolean newValue) {
97         adminStateUp = newValue;
98     }
99
100     public String getStatus() {
101         return status;
102     }
103
104     public void setStatus(String status) {
105         this.status = status;
106     }
107
108     public String getTenantID() {
109         return tenantID;
110     }
111
112     public void setTenantID(String tenantID) {
113         this.tenantID = tenantID;
114     }
115
116     public NeutronRouter_NetworkReference getExternalGatewayInfo() {
117         return externalGatewayInfo;
118     }
119
120     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
121         this.externalGatewayInfo = externalGatewayInfo;
122     }
123
124     public Boolean getDistributed() {
125         return distributed;
126     }
127
128     public void setDistributed(Boolean distributed) {
129         this.distributed = distributed;
130     }
131
132     public String getGatewayPortId() {
133         return gatewayPortId;
134     }
135
136     public void setGatewayPortId(String gatewayPortId) {
137         this.gatewayPortId = gatewayPortId;
138     }
139
140     public List<String> getRoutes() {
141         return routes;
142     }
143
144     public void setRoutes(List<String> routes) {
145         this.routes = routes;
146     }
147
148     /**
149      * This method copies selected fields from the object and returns them
150      * as a new object, suitable for marshaling.
151      *
152      * @param fields
153      *            List of attributes to be extracted
154      * @return an OpenStackRouters object with only the selected fields
155      * populated
156      */
157     public NeutronRouter extractFields(List<String> fields) {
158         NeutronRouter ans = new NeutronRouter();
159         Iterator<String> i = fields.iterator();
160         while (i.hasNext()) {
161             String s = i.next();
162             if (s.equals("id")) {
163                 ans.setRouterUUID(this.getRouterUUID());
164             }
165             if (s.equals("name")) {
166                 ans.setName(this.getName());
167             }
168             if (s.equals("admin_state_up")) {
169                 ans.setAdminStateUp(this.getAdminStateUp());
170             }
171             if (s.equals("status")) {
172                 ans.setStatus(this.getStatus());
173             }
174             if (s.equals("tenant_id")) {
175                 ans.setTenantID(this.getTenantID());
176             }
177             if (s.equals("external_gateway_info")) {
178                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
179             }
180             if (s.equals("distributed")) {
181                 ans.setDistributed(this.getDistributed());
182             }
183             if (s.equals("gw_port_id")) {
184                 ans.setGatewayPortId(this.getGatewayPortId());
185             }
186             if (s.equals("routes")){
187                 ans.setRoutes(this.getRoutes());
188             }
189         }
190         return ans;
191     }
192
193     public HashMap<String, NeutronRouter_Interface> getInterfaces() {
194         return interfaces;
195     }
196
197     public void addInterface(String s, NeutronRouter_Interface i) {
198         interfaces.put(s, i);
199     }
200
201     public void removeInterface(String s) {
202         interfaces.remove(s);
203     }
204
205     public void initDefaults() {
206         adminStateUp = true;
207     }
208 }