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.netvirt.openstack.netvirt.translator;
11 import java.io.Serializable;
12 import java.util.HashMap;
13 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.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
24 @XmlAccessorType(XmlAccessType.NONE)
26 public class NeutronRouter 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 Map<String, NeutronRouter_Interface> interfaces;
63 public NeutronRouter() {
64 interfaces = new HashMap<>();
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<Routes> getRoutes() {
144 public void setRoutes(List<Routes> 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 for (String s : fields) {
162 ans.setRouterUUID(this.getRouterUUID());
165 ans.setName(this.getName());
167 case "admin_state_up":
168 ans.setAdminStateUp(this.getAdminStateUp());
171 ans.setStatus(this.getStatus());
174 ans.setTenantID(this.getTenantID());
176 case "external_gateway_info":
177 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
180 ans.setDistributed(this.getDistributed());
183 ans.setGatewayPortId(this.getGatewayPortId());
186 ans.setRoutes(this.getRoutes());
193 public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
197 public Map<String, NeutronRouter_Interface> getInterfaces() {
201 public void addInterface(String s, NeutronRouter_Interface i) {
202 interfaces.put(s, i);
205 public void removeInterface(String s) {
206 interfaces.remove(s);
209 public void initDefaults() {
214 public String toString() {
215 return "NeutronRouter [" +
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 +