2 * Copyright (c) 2013, 2015 IBM Corporation and others. 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.neutron.spi;
11 import java.io.Serializable;
12 import java.util.HashMap;
13 import java.util.Iterator;
14 import java.util.List;
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;
23 @XmlAccessorType(XmlAccessType.NONE)
25 public class NeutronRouter extends NeutronObject implements Serializable, INeutronObject {
26 private static final long serialVersionUID = 1L;
28 // See OpenStack Network API v2.0 Reference for description of
29 // annotated attributes
30 @XmlElement (name = "name")
33 @XmlElement (defaultValue = "true", name = "admin_state_up")
36 @XmlElement (name = "status")
39 @XmlElement (name = "external_gateway_info", nillable = true)
40 NeutronRouter_NetworkReference externalGatewayInfo;
42 @XmlElement (name = "distributed")
45 @XmlElement (name = "gw_port_id", nillable = true)
48 @XmlElement (name = "routes")
51 /* Holds a map of OpenStackRouterInterfaces by subnet UUID
52 * used for internal mapping to DOVE
54 Map<String, NeutronRouter_Interface> interfaces;
56 public NeutronRouter() {
57 interfaces = new HashMap<String, NeutronRouter_Interface>();
61 public String getRouterUUID() {
66 public void setRouterUUID(String uuid) {
70 public String getName() {
74 public void setName(String name) {
78 public boolean isAdminStateUp() {
79 if (adminStateUp == null) {
85 public Boolean getAdminStateUp() { return adminStateUp; }
87 public void setAdminStateUp(Boolean newValue) {
88 adminStateUp = newValue;
91 public String getStatus() {
95 public void setStatus(String status) {
99 public NeutronRouter_NetworkReference getExternalGatewayInfo() {
100 return externalGatewayInfo;
103 public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
104 this.externalGatewayInfo = externalGatewayInfo;
107 public Boolean getDistributed() {
111 public void setDistributed(Boolean distributed) {
112 this.distributed = distributed;
115 public String getGatewayPortId() {
116 return gatewayPortId;
119 public void setGatewayPortId(String gatewayPortId) {
120 this.gatewayPortId = gatewayPortId;
123 public List<String> getRoutes() {
127 public void setRoutes(List<String> routes) {
128 this.routes = routes;
132 * This method copies selected fields from the object and returns them
133 * as a new object, suitable for marshaling.
136 * List of attributes to be extracted
137 * @return an OpenStackRouters object with only the selected fields
140 public NeutronRouter extractFields(List<String> fields) {
141 NeutronRouter ans = new NeutronRouter();
142 Iterator<String> i = fields.iterator();
143 while (i.hasNext()) {
145 if (s.equals("id")) {
146 ans.setID(this.getID());
148 if (s.equals("name")) {
149 ans.setName(this.getName());
151 if (s.equals("admin_state_up")) {
152 ans.setAdminStateUp(this.getAdminStateUp());
154 if (s.equals("status")) {
155 ans.setStatus(this.getStatus());
157 if (s.equals("tenant_id")) {
158 ans.setTenantID(this.getTenantID());
160 if (s.equals("external_gateway_info")) {
161 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
163 if (s.equals("distributed")) {
164 ans.setDistributed(this.getDistributed());
166 if (s.equals("gw_port_id")) {
167 ans.setGatewayPortId(this.getGatewayPortId());
169 if (s.equals("routes")){
170 ans.setRoutes(this.getRoutes());
176 public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
180 public Map<String, NeutronRouter_Interface> getInterfaces() {
184 public void addInterface(String s, NeutronRouter_Interface i) {
185 interfaces.put(s, i);
188 public void removeInterface(String s) {
189 interfaces.remove(s);
193 public void initDefaults() {
198 public String toString() {
199 return "NeutronRouter [" +
202 ", adminStateUp=" + adminStateUp +
203 ", status=" + status +
204 ", tenantID=" + tenantID +
205 ", external_gateway_info=" + externalGatewayInfo +
206 ", distributed=" + distributed +
207 ", gw_port_id=" + gatewayPortId +
208 ", routes=" + routes +
209 ", interfaces=" + interfaces +