Initial push of Neutron interface
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronRouter.java
1 /*\r
2  * Copyright IBM Corporation, 2013.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.controller.networkconfig.neutron;\r
10 \r
11 import java.util.HashMap;\r
12 import java.util.Iterator;\r
13 import java.util.List;\r
14 import javax.xml.bind.annotation.XmlAccessType;\r
15 import javax.xml.bind.annotation.XmlAccessorType;\r
16 import javax.xml.bind.annotation.XmlElement;\r
17 import javax.xml.bind.annotation.XmlRootElement;\r
18 \r
19 @XmlRootElement\r
20 @XmlAccessorType(XmlAccessType.NONE)\r
21 \r
22 public class NeutronRouter {\r
23     // See OpenStack Network API v2.0 Reference for description of\r
24     // annotated attributes\r
25     @XmlElement (name="id")\r
26     String routerUUID;\r
27 \r
28     @XmlElement (name="name")\r
29     String name;\r
30 \r
31     @XmlElement (defaultValue="true", name="admin_state_up")\r
32     Boolean adminStateUp;\r
33 \r
34     @XmlElement (name="status")\r
35     String status;\r
36 \r
37     @XmlElement (name="tenant_id")\r
38     String tenantID;\r
39 \r
40     @XmlElement (name="external_gateway_info")\r
41     NeutronRouter_NetworkReference externalGatewayInfo;\r
42 \r
43     /* Holds a map of OpenStackRouterInterfaces by subnet UUID\r
44      * used for internal mapping to DOVE\r
45      */\r
46     HashMap<String, NeutronRouter_Interface> interfaces;\r
47 \r
48     public NeutronRouter() {\r
49         interfaces = new HashMap<String, NeutronRouter_Interface>();\r
50     }\r
51 \r
52     public String getID() { return routerUUID; }\r
53 \r
54     public String getRouterUUID() {\r
55         return routerUUID;\r
56     }\r
57 \r
58     public void setRouterUUID(String routerUUID) {\r
59         this.routerUUID = routerUUID;\r
60     }\r
61 \r
62     public String getName() {\r
63         return name;\r
64     }\r
65 \r
66     public void setName(String name) {\r
67         this.name = name;\r
68     }\r
69 \r
70     public boolean isAdminStateUp() {\r
71         if (adminStateUp == null)\r
72             return true;\r
73         return adminStateUp;\r
74     }\r
75 \r
76     public Boolean getAdminStateUp() { return adminStateUp; }\r
77 \r
78     public void setAdminStateUp(Boolean newValue) {\r
79         this.adminStateUp = newValue;\r
80     }\r
81 \r
82     public String getStatus() {\r
83         return status;\r
84     }\r
85 \r
86     public void setStatus(String status) {\r
87         this.status = status;\r
88     }\r
89 \r
90     public String getTenantID() {\r
91         return tenantID;\r
92     }\r
93 \r
94     public void setTenantID(String tenantID) {\r
95         this.tenantID = tenantID;\r
96     }\r
97 \r
98     public NeutronRouter_NetworkReference getExternalGatewayInfo() {\r
99         return externalGatewayInfo;\r
100     }\r
101 \r
102     public void setExternalGatewayInfo(NeutronRouter_NetworkReference externalGatewayInfo) {\r
103         this.externalGatewayInfo = externalGatewayInfo;\r
104     }\r
105 \r
106     /**\r
107      * This method copies selected fields from the object and returns them\r
108      * as a new object, suitable for marshaling.\r
109      *\r
110      * @param fields\r
111      *            List of attributes to be extracted\r
112      * @return an OpenStackRouters object with only the selected fields\r
113      * populated\r
114      */\r
115 \r
116     public NeutronRouter extractFields(List<String> fields) {\r
117         NeutronRouter ans = new NeutronRouter();\r
118         Iterator<String> i = fields.iterator();\r
119         while (i.hasNext()) {\r
120             String s = i.next();\r
121             if (s.equals("id"))\r
122                 ans.setRouterUUID(this.getRouterUUID());\r
123             if (s.equals("name"))\r
124                 ans.setName(this.getName());\r
125             if (s.equals("admin_state_up"))\r
126                 ans.setAdminStateUp(this.getAdminStateUp());\r
127             if (s.equals("status"))\r
128                 ans.setStatus(this.getStatus());\r
129             if (s.equals("tenant_id"))\r
130                 ans.setTenantID(this.getTenantID());\r
131             if (s.equals("external_gateway_info")) {\r
132                 ans.setExternalGatewayInfo(this.getExternalGatewayInfo());\r
133             }\r
134         }\r
135         return ans;\r
136     }\r
137 \r
138     public HashMap<String, NeutronRouter_Interface> getInterfaces() {\r
139         return interfaces;\r
140     }\r
141 \r
142     public void addInterface(String s, NeutronRouter_Interface i) {\r
143         interfaces.put(s, i);\r
144     }\r
145 \r
146     public void removeInterface(String s) {\r
147         interfaces.remove(s);\r
148     }\r
149 \r
150     public void initDefaults() {\r
151         adminStateUp = true;\r
152     }\r
153 }\r