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.ovsdb.openstack.netvirt.translator;
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 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 = "id")
33 @XmlElement (name = "name")
36 @XmlElement (defaultValue = "true", name = "admin_state_up")
39 @XmlElement (name = "status")
42 @XmlElement (name = "tenant_id")
45 @XmlElement (name = "external_gateway_info", nillable = true)
46 NeutronRouter_NetworkReference externalGatewayInfo;
48 @XmlElement (name = "distributed")
51 @XmlElement (name = "gw_port_id", nillable = true)
54 @XmlElement (name = "routes")
57 /* Holds a map of OpenStackRouterInterfaces by subnet UUID
58 * used for internal mapping to DOVE
60 Map<String, NeutronRouter_Interface> interfaces;
62 public NeutronRouter() {
63 interfaces = new HashMap<>();
66 public String getID() { return routerUUID; }
68 public void setID(String id) { this.routerUUID = id; }
70 public String getRouterUUID() {
74 public void setRouterUUID(String routerUUID) {
75 this.routerUUID = routerUUID;
78 public String getName() {
82 public void setName(String name) {
86 public boolean isAdminStateUp() {
87 if (adminStateUp == null) {
93 public Boolean getAdminStateUp() { return adminStateUp; }
95 public void setAdminStateUp(Boolean newValue) {
96 adminStateUp = newValue;
99 public String getStatus() {
103 public void setStatus(String status) {
104 this.status = status;
107 public String getTenantID() {
111 public void setTenantID(String tenantID) {
112 this.tenantID = tenantID;
115 public NeutronRouter_NetworkReference getExternalGatewayInfo() {
116 return externalGatewayInfo;
119 public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
120 this.externalGatewayInfo = externalGatewayInfo;
123 public Boolean getDistributed() {
127 public void setDistributed(Boolean distributed) {
128 this.distributed = distributed;
131 public String getGatewayPortId() {
132 return gatewayPortId;
135 public void setGatewayPortId(String gatewayPortId) {
136 this.gatewayPortId = gatewayPortId;
139 public List<String> getRoutes() {
143 public void setRoutes(List<String> routes) {
144 this.routes = routes;
148 * This method copies selected fields from the object and returns them
149 * as a new object, suitable for marshaling.
152 * List of attributes to be extracted
153 * @return an OpenStackRouters object with only the selected fields
156 public NeutronRouter extractFields(List<String> fields) {
157 NeutronRouter ans = new NeutronRouter();
158 Iterator<String> i = fields.iterator();
159 while (i.hasNext()) {
161 if (s.equals("id")) {
162 ans.setRouterUUID(this.getRouterUUID());
164 if (s.equals("name")) {
165 ans.setName(this.getName());
167 if (s.equals("admin_state_up")) {
168 ans.setAdminStateUp(this.getAdminStateUp());
170 if (s.equals("status")) {
171 ans.setStatus(this.getStatus());
173 if (s.equals("tenant_id")) {
174 ans.setTenantID(this.getTenantID());
176 if (s.equals("external_gateway_info")) {
177 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
179 if (s.equals("distributed")) {
180 ans.setDistributed(this.getDistributed());
182 if (s.equals("gw_port_id")) {
183 ans.setGatewayPortId(this.getGatewayPortId());
185 if (s.equals("routes")){
186 ans.setRoutes(this.getRoutes());
192 public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
196 public Map<String, NeutronRouter_Interface> getInterfaces() {
200 public void addInterface(String s, NeutronRouter_Interface i) {
201 interfaces.put(s, i);
204 public void removeInterface(String s) {
205 interfaces.remove(s);
208 public void initDefaults() {
213 public String toString() {
214 return "NeutronRouter [" +
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 +