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