2 * Copyright (c) 2013, 2015 IBM Corporation and others. All rights reserved.
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
9 package org.opendaylight.ovsdb.openstack.netvirt.translator;
12 import java.io.Serializable;
13 import java.util.ArrayList;
14 import java.util.List;
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;
23 @XmlAccessorType(XmlAccessType.NONE)
25 public class NeutronPort implements Serializable, INeutronObject {
26 private static final long serialVersionUID = 1L;
28 // See OpenStack Network API v2.0 Reference for description of
29 // annotated attributes
31 @XmlElement (name = "id")
34 @XmlElement (name = "network_id")
37 @XmlElement (name = "name")
40 @XmlElement (defaultValue = "true", name = "admin_state_up")
43 @XmlElement (name = "status")
46 @XmlElement (name = "mac_address")
49 @XmlElement (name = "fixed_ips")
50 List<Neutron_IPs> fixedIPs;
52 @XmlElement (name = "device_id")
55 @XmlElement (name = "device_owner")
58 @XmlElement (name = "tenant_id")
61 @XmlElement (name = "security_groups")
62 List<NeutronSecurityGroup> securityGroups;
64 @XmlElement (name = "allowed_address_pairs")
65 List<NeutronPort_AllowedAddressPairs> allowedAddressPairs;
67 //@XmlElement (name = "binding:host_id")
68 @XmlElement (namespace = "binding", name = "host_id")
71 //@XmlElement (name = "binding:vnic_type")
72 @XmlElement (namespace = "binding", name = "vnic_type")
73 String bindingvnicType;
75 //@XmlElement (name = "binding:vif_type")
76 @XmlElement (namespace = "binding", name = "vif_type")
77 String bindingvifType;
79 //@XmlElement (name = "binding:vif_details")
80 @XmlElement (namespace = "binding", name = "vif_details")
81 List<NeutronPort_VIFDetail> vifDetails;
83 @XmlElement (name = "extra_dhcp_opts")
84 List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
86 NeutronPort originalPort;
88 public NeutronPort() {
91 public String getID() { return portUUID; }
93 public void setID(String id) { this.portUUID = id; }
95 public String getPortUUID() {
99 public void setPortUUID(String portUUID) {
100 this.portUUID = portUUID;
103 public String getNetworkUUID() {
107 public void setNetworkUUID(String networkUUID) {
108 this.networkUUID = networkUUID;
111 public String getName() {
115 public void setName(String name) {
119 public boolean isAdminStateUp() {
120 if (adminStateUp == null) {
126 public Boolean getAdminStateUp() { return adminStateUp; }
128 public void setAdminStateUp(Boolean newValue) {
129 adminStateUp = newValue;
132 public String getStatus() {
136 public void setStatus(String status) {
137 this.status = status;
140 public String getMacAddress() {
144 public void setMacAddress(String macAddress) {
145 this.macAddress = macAddress;
148 public List<Neutron_IPs> getFixedIPs() {
152 public void setFixedIPs(List<Neutron_IPs> fixedIPs) {
153 this.fixedIPs = fixedIPs;
156 public String getDeviceID() {
160 public void setDeviceID(String deviceID) {
161 this.deviceID = deviceID;
164 public String getDeviceOwner() {
168 public void setDeviceOwner(String deviceOwner) {
169 this.deviceOwner = deviceOwner;
172 public String getTenantID() {
176 public void setTenantID(String tenantID) {
177 this.tenantID = tenantID;
180 public List<NeutronSecurityGroup> getSecurityGroups() {
181 return securityGroups;
184 public void setSecurityGroups(List<NeutronSecurityGroup> securityGroups) {
185 this.securityGroups = securityGroups;
188 public List<NeutronPort_AllowedAddressPairs> getAllowedAddressPairs() {
189 return allowedAddressPairs;
192 public void setAllowedAddressPairs(List<NeutronPort_AllowedAddressPairs> allowedAddressPairs) {
193 this.allowedAddressPairs = allowedAddressPairs;
196 public List<NeutronPort_ExtraDHCPOption> getExtraDHCPOptions() {
197 return extraDHCPOptions;
200 public void setExtraDHCPOptions(List<NeutronPort_ExtraDHCPOption> extraDHCPOptions) {
201 this.extraDHCPOptions = extraDHCPOptions;
204 public List<NeutronPort_VIFDetail> getVIFDetail() {
208 public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
209 this.vifDetails = vifDetails;
212 public String getBindinghostID() {
213 return bindinghostID;
216 public void setBindinghostID(String bindinghostID) {
217 this.bindinghostID = bindinghostID;
220 public String getBindingvnicType() {
221 return bindingvnicType;
224 public void setBindingvnicType(String bindingvnicType) {
225 this.bindingvnicType = bindingvnicType;
228 public String getBindingvifType() {
229 return bindingvifType;
232 public void setBindingvifType(String bindingvifType) {
233 this.bindingvifType = bindingvifType;
236 public NeutronPort getOriginalPort() {
241 public void setOriginalPort(NeutronPort originalPort) {
242 this.originalPort = originalPort;
246 * This method copies selected fields from the object and returns them
247 * as a new object, suitable for marshaling.
250 * List of attributes to be extracted
251 * @return an OpenStackPorts object with only the selected fields
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());
261 if ("network_id".equals(field)) {
262 ans.setNetworkUUID(this.getNetworkUUID());
264 if ("name".equals(field)) {
265 ans.setName(this.getName());
267 if ("admin_state_up".equals(field)) {
268 ans.setAdminStateUp(this.getAdminStateUp());
270 if ("status".equals(field)) {
271 ans.setStatus(this.getStatus());
273 if ("mac_address".equals(field)) {
274 ans.setMacAddress(this.getMacAddress());
276 if ("fixed_ips".equals(field)) {
277 ans.setFixedIPs(new ArrayList<>(this.getFixedIPs()));
279 if ("device_id".equals(field)) {
280 ans.setDeviceID(this.getDeviceID());
282 if ("device_owner".equals(field)) {
283 ans.setDeviceOwner(this.getDeviceOwner());
285 if ("tenant_id".equals(field)) {
286 ans.setTenantID(this.getTenantID());
288 if ("security_groups".equals(field)) {
289 ans.setSecurityGroups(new ArrayList<>(this.getSecurityGroups()));
295 public void initDefaults() {
297 if (status == null) {
300 if (fixedIPs == null) {
301 fixedIPs = new ArrayList<>();
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 + "]";