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