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;
22 @XmlAccessorType(XmlAccessType.NONE)
24 public class NeutronRouter implements Serializable, INeutronObject {
25 private static final long serialVersionUID = 1L;
27 // See OpenStack Network API v2.0 Reference for description of
28 // annotated attributes
29 @XmlElement (name="id")
32 @XmlElement (name="name")
35 @XmlElement (defaultValue="true", name="admin_state_up")
38 @XmlElement (name="status")
41 @XmlElement (name="tenant_id")
44 @XmlElement (name="external_gateway_info", nillable=true)
45 NeutronRouter_NetworkReference externalGatewayInfo;
47 @XmlElement (name="distributed")
50 @XmlElement (name="gw_port_id", nillable=true)
53 @XmlElement (name="routes")
56 /* Holds a map of OpenStackRouterInterfaces by subnet UUID
57 * used for internal mapping to DOVE
59 HashMap<String, NeutronRouter_Interface> interfaces;
61 public NeutronRouter() {
62 interfaces = new HashMap<String, NeutronRouter_Interface>();
65 public String getID() { return routerUUID; }
67 public void setID(String id) { this.routerUUID = id; }
69 public String getRouterUUID() {
73 public void setRouterUUID(String routerUUID) {
74 this.routerUUID = routerUUID;
77 public String getName() {
81 public void setName(String name) {
85 public boolean isAdminStateUp() {
86 if (adminStateUp == null) {
92 public Boolean getAdminStateUp() { return adminStateUp; }
94 public void setAdminStateUp(Boolean newValue) {
95 adminStateUp = newValue;
98 public String getStatus() {
102 public void setStatus(String status) {
103 this.status = status;
106 public String getTenantID() {
110 public void setTenantID(String tenantID) {
111 this.tenantID = tenantID;
114 public NeutronRouter_NetworkReference getExternalGatewayInfo() {
115 return externalGatewayInfo;
118 public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
119 this.externalGatewayInfo = externalGatewayInfo;
122 public Boolean getDistributed() {
126 public void setDistributed(Boolean distributed) {
127 this.distributed = distributed;
130 public String getGatewayPortId() {
131 return gatewayPortId;
134 public void setGatewayPortId(String gatewayPortId) {
135 this.gatewayPortId = gatewayPortId;
138 public List<String> getRoutes() {
142 public void setRoutes(List<String> routes) {
143 this.routes = routes;
147 * This method copies selected fields from the object and returns them
148 * as a new object, suitable for marshaling.
151 * List of attributes to be extracted
152 * @return an OpenStackRouters object with only the selected fields
155 public NeutronRouter extractFields(List<String> fields) {
156 NeutronRouter ans = new NeutronRouter();
157 Iterator<String> i = fields.iterator();
158 while (i.hasNext()) {
160 if (s.equals("id")) {
161 ans.setRouterUUID(this.getRouterUUID());
163 if (s.equals("name")) {
164 ans.setName(this.getName());
166 if (s.equals("admin_state_up")) {
167 ans.setAdminStateUp(this.getAdminStateUp());
169 if (s.equals("status")) {
170 ans.setStatus(this.getStatus());
172 if (s.equals("tenant_id")) {
173 ans.setTenantID(this.getTenantID());
175 if (s.equals("external_gateway_info")) {
176 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
178 if (s.equals("distributed")) {
179 ans.setDistributed(this.getDistributed());
181 if (s.equals("gw_port_id")) {
182 ans.setGatewayPortId(this.getGatewayPortId());
184 if (s.equals("routes")){
185 ans.setRoutes(this.getRoutes());
191 public HashMap<String, NeutronRouter_Interface> getInterfaces() {
195 public void addInterface(String s, NeutronRouter_Interface i) {
196 interfaces.put(s, i);
199 public void removeInterface(String s) {
200 interfaces.remove(s);
203 public void initDefaults() {