Full <> clean-up
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / translator / NeutronPort.java
1 /*
2  * Copyright (c) 2013, 2015 IBM Corporation and others.  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.ovsdb.openstack.netvirt.translator;
10
11
12 import java.io.Serializable;
13 import java.util.ArrayList;
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
22 @XmlRootElement
23 @XmlAccessorType(XmlAccessType.NONE)
24
25 public class NeutronPort implements Serializable, INeutronObject {
26     private static final long serialVersionUID = 1L;
27
28     // See OpenStack Network API v2.0 Reference for description of
29     // annotated attributes
30
31     @XmlElement (name = "id")
32     String portUUID;
33
34     @XmlElement (name = "network_id")
35     String networkUUID;
36
37     @XmlElement (name = "name")
38     String name;
39
40     @XmlElement (defaultValue = "true", name = "admin_state_up")
41     Boolean adminStateUp;
42
43     @XmlElement (name = "status")
44     String status;
45
46     @XmlElement (name = "mac_address")
47     String macAddress;
48
49     @XmlElement (name = "fixed_ips")
50     List<Neutron_IPs> fixedIPs;
51
52     @XmlElement (name = "device_id")
53     String deviceID;
54
55     @XmlElement (name = "device_owner")
56     String deviceOwner;
57
58     @XmlElement (name = "tenant_id")
59     String tenantID;
60
61     @XmlElement (name = "security_groups")
62     List<NeutronSecurityGroup> securityGroups;
63
64     @XmlElement (name = "allowed_address_pairs")
65     List<NeutronPort_AllowedAddressPairs> allowedAddressPairs;
66
67     //@XmlElement (name = "binding:host_id")
68     @XmlElement (namespace = "binding", name = "host_id")
69     String bindinghostID;
70
71     //@XmlElement (name = "binding:vnic_type")
72     @XmlElement (namespace = "binding", name = "vnic_type")
73     String bindingvnicType;
74
75     //@XmlElement (name = "binding:vif_type")
76     @XmlElement (namespace = "binding", name = "vif_type")
77     String bindingvifType;
78
79     //@XmlElement (name = "binding:vif_details")
80     @XmlElement (namespace = "binding", name = "vif_details")
81     List<NeutronPort_VIFDetail> vifDetails;
82
83     @XmlElement (name = "extra_dhcp_opts")
84     List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
85
86     NeutronPort originalPort;
87
88     public NeutronPort() {
89     }
90
91     public String getID() { return portUUID; }
92
93     public void setID(String id) { this.portUUID = id; }
94
95     public String getPortUUID() {
96         return portUUID;
97     }
98
99     public void setPortUUID(String portUUID) {
100         this.portUUID = portUUID;
101     }
102
103     public String getNetworkUUID() {
104         return networkUUID;
105     }
106
107     public void setNetworkUUID(String networkUUID) {
108         this.networkUUID = networkUUID;
109     }
110
111     public String getName() {
112         return name;
113     }
114
115     public void setName(String name) {
116         this.name = name;
117     }
118
119     public boolean isAdminStateUp() {
120         if (adminStateUp == null) {
121             return true;
122         }
123         return adminStateUp;
124     }
125
126     public Boolean getAdminStateUp() { return adminStateUp; }
127
128     public void setAdminStateUp(Boolean newValue) {
129             adminStateUp = newValue;
130     }
131
132     public String getStatus() {
133         return status;
134     }
135
136     public void setStatus(String status) {
137         this.status = status;
138     }
139
140     public String getMacAddress() {
141         return macAddress;
142     }
143
144     public void setMacAddress(String macAddress) {
145         this.macAddress = macAddress;
146     }
147
148     public List<Neutron_IPs> getFixedIPs() {
149         return fixedIPs;
150     }
151
152     public void setFixedIPs(List<Neutron_IPs> fixedIPs) {
153         this.fixedIPs = fixedIPs;
154     }
155
156     public String getDeviceID() {
157         return deviceID;
158     }
159
160     public void setDeviceID(String deviceID) {
161         this.deviceID = deviceID;
162     }
163
164     public String getDeviceOwner() {
165         return deviceOwner;
166     }
167
168     public void setDeviceOwner(String deviceOwner) {
169         this.deviceOwner = deviceOwner;
170     }
171
172     public String getTenantID() {
173         return tenantID;
174     }
175
176     public void setTenantID(String tenantID) {
177         this.tenantID = tenantID;
178     }
179
180     public List<NeutronSecurityGroup> getSecurityGroups() {
181         return securityGroups;
182     }
183
184     public void setSecurityGroups(List<NeutronSecurityGroup> securityGroups) {
185         this.securityGroups = securityGroups;
186     }
187
188     public List<NeutronPort_AllowedAddressPairs> getAllowedAddressPairs() {
189         return allowedAddressPairs;
190     }
191
192     public void setAllowedAddressPairs(List<NeutronPort_AllowedAddressPairs> allowedAddressPairs) {
193         this.allowedAddressPairs = allowedAddressPairs;
194     }
195
196     public List<NeutronPort_ExtraDHCPOption> getExtraDHCPOptions() {
197         return extraDHCPOptions;
198     }
199
200     public void setExtraDHCPOptions(List<NeutronPort_ExtraDHCPOption> extraDHCPOptions) {
201         this.extraDHCPOptions = extraDHCPOptions;
202     }
203
204     public List<NeutronPort_VIFDetail> getVIFDetail() {
205         return vifDetails;
206     }
207
208     public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
209         this.vifDetails = vifDetails;
210     }
211
212     public String getBindinghostID() {
213       return bindinghostID;
214     }
215
216     public void setBindinghostID(String bindinghostID) {
217       this.bindinghostID = bindinghostID;
218     }
219
220     public String getBindingvnicType() {
221         return bindingvnicType;
222     }
223
224     public void setBindingvnicType(String bindingvnicType) {
225         this.bindingvnicType = bindingvnicType;
226     }
227
228     public String getBindingvifType() {
229         return bindingvifType;
230     }
231
232     public void setBindingvifType(String bindingvifType) {
233         this.bindingvifType = bindingvifType;
234     }
235
236     public NeutronPort getOriginalPort() {
237         return originalPort;
238     }
239
240
241     public void setOriginalPort(NeutronPort originalPort) {
242         this.originalPort = originalPort;
243     }
244
245     /**
246      * This method copies selected fields from the object and returns them
247      * as a new object, suitable for marshaling.
248      *
249      * @param fields
250      *            List of attributes to be extracted
251      * @return an OpenStackPorts object with only the selected fields
252      * populated
253      */
254
255     public NeutronPort extractFields(List<String> fields) {
256         NeutronPort ans = new NeutronPort();
257         for (String field: fields) {
258             if ("id".equals(field)) {
259                 ans.setPortUUID(this.getPortUUID());
260             }
261             if ("network_id".equals(field)) {
262                 ans.setNetworkUUID(this.getNetworkUUID());
263             }
264             if ("name".equals(field)) {
265                 ans.setName(this.getName());
266             }
267             if ("admin_state_up".equals(field)) {
268                 ans.setAdminStateUp(this.getAdminStateUp());
269             }
270             if ("status".equals(field)) {
271                 ans.setStatus(this.getStatus());
272             }
273             if ("mac_address".equals(field)) {
274                 ans.setMacAddress(this.getMacAddress());
275             }
276             if ("fixed_ips".equals(field)) {
277                 ans.setFixedIPs(new ArrayList<>(this.getFixedIPs()));
278             }
279             if ("device_id".equals(field)) {
280                 ans.setDeviceID(this.getDeviceID());
281             }
282             if ("device_owner".equals(field)) {
283                 ans.setDeviceOwner(this.getDeviceOwner());
284             }
285             if ("tenant_id".equals(field)) {
286                 ans.setTenantID(this.getTenantID());
287             }
288             if ("security_groups".equals(field)) {
289                 ans.setSecurityGroups(new ArrayList<>(this.getSecurityGroups()));
290             }
291         }
292         return ans;
293     }
294
295     public void initDefaults() {
296         adminStateUp = true;
297         if (status == null) {
298             status = "ACTIVE";
299         }
300         if (fixedIPs == null) {
301             fixedIPs = new ArrayList<>();
302         }
303     }
304
305     @Override
306     public String toString() {
307         return "NeutronPort [portUUID=" + portUUID + ", networkUUID=" + networkUUID + ", name=" + name
308                 + ", adminStateUp=" + adminStateUp + ", status=" + status + ", macAddress=" + macAddress
309                 + ", fixedIPs=" + fixedIPs + ", deviceID=" + deviceID + ", deviceOwner=" + deviceOwner + ", tenantID="
310                 + tenantID + ", securityGroups=" + securityGroups
311                 + ", bindinghostID=" + bindinghostID + ", bindingvnicType=" + bindingvnicType
312                 + ", bindingvnicType=" + bindingvnicType + "]";
313     }
314 }