Imported vpnservice as a subtree
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / netvirt / 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.netvirt.openstack.netvirt.translator;
10
11 import java.io.Serializable;
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.Map;
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.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.NONE)
25
26 public class NeutronRouter 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<Routes> routes;
57
58     /* Holds a map of OpenStackRouterInterfaces by subnet UUID
59      * used for internal mapping to DOVE
60      */
61     Map<String, NeutronRouter_Interface> interfaces;
62
63     public NeutronRouter() {
64         interfaces = new HashMap<>();
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<Routes> getRoutes() {
141         return routes;
142     }
143
144     public void setRoutes(List<Routes> 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         for (String s : fields) {
160             switch (s) {
161                 case "id":
162                     ans.setRouterUUID(this.getRouterUUID());
163                     break;
164                 case "name":
165                     ans.setName(this.getName());
166                     break;
167                 case "admin_state_up":
168                     ans.setAdminStateUp(this.getAdminStateUp());
169                     break;
170                 case "status":
171                     ans.setStatus(this.getStatus());
172                     break;
173                 case "tenant_id":
174                     ans.setTenantID(this.getTenantID());
175                     break;
176                 case "external_gateway_info":
177                     ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
178                     break;
179                 case "distributed":
180                     ans.setDistributed(this.getDistributed());
181                     break;
182                 case "gw_port_id":
183                     ans.setGatewayPortId(this.getGatewayPortId());
184                     break;
185                 case "routes":
186                     ans.setRoutes(this.getRoutes());
187                     break;
188             }
189         }
190         return ans;
191     }
192
193     public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
194         interfaces = input;
195     }
196
197     public Map<String, NeutronRouter_Interface> getInterfaces() {
198         return interfaces;
199     }
200
201     public void addInterface(String s, NeutronRouter_Interface i) {
202         interfaces.put(s, i);
203     }
204
205     public void removeInterface(String s) {
206         interfaces.remove(s);
207     }
208
209     public void initDefaults() {
210         adminStateUp = true;
211     }
212
213     @Override
214     public String toString() {
215         return "NeutronRouter [" +
216             "id=" + routerUUID +
217             ", name=" + name +
218             ", adminStateUp=" + adminStateUp +
219             ", status=" + status +
220             ", tenantID=" + tenantID +
221             ", external_gateway_info=" + externalGatewayInfo +
222             ", distributed=" + distributed +
223             ", gw_port_id=" + gatewayPortId +
224             ", routes=" + routes +
225             ", interfaces=" + interfaces +
226             "]";
227     }
228
229 }