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 {
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")
47 NeutronRouter_NetworkReference externalGatewayInfo;
49 /* Holds a map of OpenStackRouterInterfaces by subnet UUID
50 * used for internal mapping to DOVE
52 HashMap<String, NeutronRouter_Interface> interfaces;
54 public NeutronRouter() {
55 interfaces = new HashMap<String, NeutronRouter_Interface>();
58 public String getID() { return routerUUID; }
60 public String getRouterUUID() {
64 public void setRouterUUID(String routerUUID) {
65 this.routerUUID = routerUUID;
68 public String getName() {
72 public void setName(String name) {
76 public boolean isAdminStateUp() {
77 if (adminStateUp == null) {
83 public Boolean getAdminStateUp() { return adminStateUp; }
85 public void setAdminStateUp(Boolean newValue) {
86 adminStateUp = newValue;
89 public String getStatus() {
93 public void setStatus(String status) {
97 public String getTenantID() {
101 public void setTenantID(String tenantID) {
102 this.tenantID = tenantID;
105 public NeutronRouter_NetworkReference getExternalGatewayInfo() {
106 return externalGatewayInfo;
109 public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
110 this.externalGatewayInfo = externalGatewayInfo;
114 * This method copies selected fields from the object and returns them
115 * as a new object, suitable for marshaling.
118 * List of attributes to be extracted
119 * @return an OpenStackRouters object with only the selected fields
123 public NeutronRouter extractFields(List<String> fields) {
124 NeutronRouter ans = new NeutronRouter();
125 Iterator<String> i = fields.iterator();
126 while (i.hasNext()) {
128 if (s.equals("id")) {
129 ans.setRouterUUID(this.getRouterUUID());
131 if (s.equals("name")) {
132 ans.setName(this.getName());
134 if (s.equals("admin_state_up")) {
135 ans.setAdminStateUp(this.getAdminStateUp());
137 if (s.equals("status")) {
138 ans.setStatus(this.getStatus());
140 if (s.equals("tenant_id")) {
141 ans.setTenantID(this.getTenantID());
143 if (s.equals("external_gateway_info")) {
144 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
150 public HashMap<String, NeutronRouter_Interface> getInterfaces() {
154 public void addInterface(String s, NeutronRouter_Interface i) {
155 interfaces.put(s, i);
158 public void removeInterface(String s) {
159 interfaces.remove(s);
162 public void initDefaults() {