fa35f71fd6ae425aac90f7d31524198413ade2f2
[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 {
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 String getRouterUUID() {
61         return routerUUID;
62     }
63
64     public void setRouterUUID(String routerUUID) {
65         this.routerUUID = routerUUID;
66     }
67
68     public String getName() {
69         return name;
70     }
71
72     public void setName(String name) {
73         this.name = name;
74     }
75
76     public boolean isAdminStateUp() {
77         if (adminStateUp == null) {
78             return true;
79         }
80         return adminStateUp;
81     }
82
83     public Boolean getAdminStateUp() { return adminStateUp; }
84
85     public void setAdminStateUp(Boolean newValue) {
86         adminStateUp = newValue;
87     }
88
89     public String getStatus() {
90         return status;
91     }
92
93     public void setStatus(String status) {
94         this.status = status;
95     }
96
97     public String getTenantID() {
98         return tenantID;
99     }
100
101     public void setTenantID(String tenantID) {
102         this.tenantID = tenantID;
103     }
104
105     public NeutronRouter_NetworkReference getExternalGatewayInfo() {
106         return externalGatewayInfo;
107     }
108
109     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {
110         this.externalGatewayInfo = externalGatewayInfo;
111     }
112
113     /**
114      * This method copies selected fields from the object and returns them
115      * as a new object, suitable for marshaling.
116      *
117      * @param fields
118      *            List of attributes to be extracted
119      * @return an OpenStackRouters object with only the selected fields
120      * populated
121      */
122
123     public NeutronRouter extractFields(List<String> fields) {
124         NeutronRouter ans = new NeutronRouter();
125         Iterator<String> i = fields.iterator();
126         while (i.hasNext()) {
127             String s = i.next();
128             if (s.equals("id")) {
129                 ans.setRouterUUID(this.getRouterUUID());
130             }
131             if (s.equals("name")) {
132                 ans.setName(this.getName());
133             }
134             if (s.equals("admin_state_up")) {
135                 ans.setAdminStateUp(this.getAdminStateUp());
136             }
137             if (s.equals("status")) {
138                 ans.setStatus(this.getStatus());
139             }
140             if (s.equals("tenant_id")) {
141                 ans.setTenantID(this.getTenantID());
142             }
143             if (s.equals("external_gateway_info")) {
144                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());
145             }
146         }
147         return ans;
148     }
149
150     public HashMap<String, NeutronRouter_Interface> getInterfaces() {
151         return interfaces;
152     }
153
154     public void addInterface(String s, NeutronRouter_Interface i) {
155         interfaces.put(s, i);
156     }
157
158     public void removeInterface(String s) {
159         interfaces.remove(s);
160     }
161
162     public void initDefaults() {
163         adminStateUp = true;
164     }
165 }