2 * Copyright IBM Corporation, 2013. All rights reserved.
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
9 package org.opendaylight.controller.networkconfig.neutron;
11 import java.io.Serializable;
12 import java.util.HashMap;
13 import java.util.Iterator;
14 import java.util.List;
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;
21 import org.opendaylight.controller.configuration.ConfigurationObject;
24 @XmlAccessorType(XmlAccessType.NONE)
26 public class NeutronRouter extends ConfigurationObject implements Serializable, INeutronObject {
27 private static final long serialVersionUID = 1L;
29 // See OpenStack Network API v2.0 Reference for description of
30 // annotated attributes
31 @XmlElement (name="id")
34 @XmlElement (name="name")
37 @XmlElement (defaultValue="true", name="admin_state_up")
40 @XmlElement (name="status")
43 @XmlElement (name="tenant_id")
46 @XmlElement (name="external_gateway_info", nillable=true)
47 NeutronRouter_NetworkReference externalGatewayInfo;
49 @XmlElement (name="distributed")
52 @XmlElement (name="gw_port_id", nillable=true)
55 @XmlElement (name="routes")
58 /* Holds a map of OpenStackRouterInterfaces by subnet UUID
59 * used for internal mapping to DOVE
61 HashMap<String, NeutronRouter_Interface> interfaces;
63 public NeutronRouter() {
64 interfaces = new HashMap<String, NeutronRouter_Interface>();
67 public String getID() { return routerUUID; }
69 public void setID(String id) { this.routerUUID = id; }
71 public String getRouterUUID() {
75 public void setRouterUUID(String routerUUID) {
76 this.routerUUID = routerUUID;
79 public String getName() {
83 public void setName(String name) {
87 public boolean isAdminStateUp() {
88 if (adminStateUp == null) {
94 public Boolean getAdminStateUp() { return adminStateUp; }
96 public void setAdminStateUp(Boolean newValue) {
97 adminStateUp = newValue;
100 public String getStatus() {
104 public void setStatus(String status) {
105 this.status = status;
108 public String getTenantID() {
112 public void setTenantID(String tenantID) {
113 this.tenantID = tenantID;
116 public NeutronRouter_NetworkReference getExternalGatewayInfo() {
117 return externalGatewayInfo;
120 public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
121 this.externalGatewayInfo = externalGatewayInfo;
124 public Boolean getDistributed() {
128 public void setDistributed(Boolean distributed) {
129 this.distributed = distributed;
132 public String getGatewayPortId() {
133 return gatewayPortId;
136 public void setGatewayPortId(String gatewayPortId) {
137 this.gatewayPortId = gatewayPortId;
140 public List<String> getRoutes() {
144 public void setRoutes(List<String> routes) {
145 this.routes = routes;
149 * This method copies selected fields from the object and returns them
150 * as a new object, suitable for marshaling.
153 * List of attributes to be extracted
154 * @return an OpenStackRouters object with only the selected fields
157 public NeutronRouter extractFields(List<String> fields) {
158 NeutronRouter ans = new NeutronRouter();
159 Iterator<String> i = fields.iterator();
160 while (i.hasNext()) {
162 if (s.equals("id")) {
163 ans.setRouterUUID(this.getRouterUUID());
165 if (s.equals("name")) {
166 ans.setName(this.getName());
168 if (s.equals("admin_state_up")) {
169 ans.setAdminStateUp(this.getAdminStateUp());
171 if (s.equals("status")) {
172 ans.setStatus(this.getStatus());
174 if (s.equals("tenant_id")) {
175 ans.setTenantID(this.getTenantID());
177 if (s.equals("external_gateway_info")) {
178 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
180 if (s.equals("distributed")) {
181 ans.setDistributed(this.getDistributed());
183 if (s.equals("gw_port_id")) {
184 ans.setGatewayPortId(this.getGatewayPortId());
186 if (s.equals("routes")){
187 ans.setRoutes(this.getRoutes());
193 public HashMap<String, NeutronRouter_Interface> getInterfaces() {
197 public void addInterface(String s, NeutronRouter_Interface i) {
198 interfaces.put(s, i);
201 public void removeInterface(String s) {
202 interfaces.remove(s);
205 public void initDefaults() {