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