Merge "Complete implementation of DataChangeListenerProxy"
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronRouter.java
1 /*
2  * Copyright IBM Corporation, 2013.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.networkconfig.neutron;
10
11 import java.io.Serializable;
12 import java.util.HashMap;
13 import java.util.Iterator;
14 import java.util.List;
15
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;
20
21 import org.opendaylight.controller.configuration.ConfigurationObject;
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.NONE)
25
26 public class NeutronRouter extends ConfigurationObject implements Serializable, INeutronObject {
27     private static final long serialVersionUID = 1L;
28
29     // See OpenStack Network API v2.0 Reference for description of
30     // annotated attributes
31     @XmlElement (name="id")
32     String routerUUID;
33
34     @XmlElement (name="name")
35     String name;
36
37     @XmlElement (defaultValue="true", name="admin_state_up")
38     Boolean adminStateUp;
39
40     @XmlElement (name="status")
41     String status;
42
43     @XmlElement (name="tenant_id")
44     String tenantID;
45
46     @XmlElement (name="external_gateway_info")
47     NeutronRouter_NetworkReference externalGatewayInfo;
48
49     /* Holds a map of OpenStackRouterInterfaces by subnet UUID
50      * used for internal mapping to DOVE
51      */
52     HashMap<String, NeutronRouter_Interface> interfaces;
53
54     public NeutronRouter() {
55         interfaces = new HashMap<String, NeutronRouter_Interface>();
56     }
57
58     public String getID() { return routerUUID; }
59
60     public void setID(String id) { this.routerUUID = id; }
61
62     public String getRouterUUID() {
63         return routerUUID;
64     }
65
66     public void setRouterUUID(String routerUUID) {
67         this.routerUUID = routerUUID;
68     }
69
70     public String getName() {
71         return name;
72     }
73
74     public void setName(String name) {
75         this.name = name;
76     }
77
78     public boolean isAdminStateUp() {
79         if (adminStateUp == null) {
80             return true;
81         }
82         return adminStateUp;
83     }
84
85     public Boolean getAdminStateUp() { return adminStateUp; }
86
87     public void setAdminStateUp(Boolean newValue) {
88         adminStateUp = newValue;
89     }
90
91     public String getStatus() {
92         return status;
93     }
94
95     public void setStatus(String status) {
96         this.status = status;
97     }
98
99     public String getTenantID() {
100         return tenantID;
101     }
102
103     public void setTenantID(String tenantID) {
104         this.tenantID = tenantID;
105     }
106
107     public NeutronRouter_NetworkReference getExternalGatewayInfo() {
108         return externalGatewayInfo;
109     }
110
111     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
112         this.externalGatewayInfo = externalGatewayInfo;
113     }
114
115     /**
116      * This method copies selected fields from the object and returns them
117      * as a new object, suitable for marshaling.
118      *
119      * @param fields
120      *            List of attributes to be extracted
121      * @return an OpenStackRouters object with only the selected fields
122      * populated
123      */
124
125     public NeutronRouter extractFields(List<String> fields) {
126         NeutronRouter ans = new NeutronRouter();
127         Iterator<String> i = fields.iterator();
128         while (i.hasNext()) {
129             String s = i.next();
130             if (s.equals("id")) {
131                 ans.setRouterUUID(this.getRouterUUID());
132             }
133             if (s.equals("name")) {
134                 ans.setName(this.getName());
135             }
136             if (s.equals("admin_state_up")) {
137                 ans.setAdminStateUp(this.getAdminStateUp());
138             }
139             if (s.equals("status")) {
140                 ans.setStatus(this.getStatus());
141             }
142             if (s.equals("tenant_id")) {
143                 ans.setTenantID(this.getTenantID());
144             }
145             if (s.equals("external_gateway_info")) {
146                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
147             }
148         }
149         return ans;
150     }
151
152     public HashMap<String, NeutronRouter_Interface> getInterfaces() {
153         return interfaces;
154     }
155
156     public void addInterface(String s, NeutronRouter_Interface i) {
157         interfaces.put(s, i);
158     }
159
160     public void removeInterface(String s) {
161         interfaces.remove(s);
162     }
163
164     public void initDefaults() {
165         adminStateUp = true;
166     }
167 }