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