X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2FNeutronNetwork.java;h=1277436e236fa375467d3ec07e6dda12a62f70c0;hp=eccbbcc3464a24a272d1e4371ee59b273884a5e9;hb=d10665e0255089f18f34149c4d2ed6f045d0f63f;hpb=f39735ca424bb6a64b46505c9c2b25cbe4940c24 diff --git a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java index eccbbcc346..1277436e23 100644 --- a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java +++ b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java @@ -1,233 +1,255 @@ -/* - * Copyright IBM Corporation, 2013. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.networkconfig.neutron; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "network") -@XmlAccessorType(XmlAccessType.NONE) - -public class NeutronNetwork { - // See OpenStack Network API v2.0 Reference for description of - // annotated attributes - - @XmlElement (name="id") - String networkUUID; // network UUID - - @XmlElement (name="name") - String networkName; // name - - @XmlElement (defaultValue="true", name="admin_state_up") - Boolean adminStateUp; // admin state up (true/false) - - @XmlElement (defaultValue="false", name="shared") - Boolean shared; // shared network or not - - @XmlElement (name="tenant_id") - String tenantID; // tenant for this network - - @XmlElement (defaultValue="false", namespace="router", name="external") - Boolean routerExternal; // network external or not - - @XmlElement (defaultValue="flat", namespace="provider", name="network_type") - String providerNetworkType; // provider network type (flat or vlan) - - @XmlElement (namespace="provider", name="physical_network") - String providerPhysicalNetwork; // provider physical network (name) - - @XmlElement (namespace="provider", name="segmentation_id") - String providerSegmentationID; // provide segmentation ID (vlan ID) - - @XmlElement (name="status") - String status; // status (read-only) - - @XmlElement (name="subnets") - List subnets; // subnets (read-only) - - /* This attribute lists the ports associated with an instance - * which is needed for determining if that instance can be deleted - */ - - List myPorts; - - public NeutronNetwork() { - myPorts = new ArrayList(); - } - - public void initDefaults() { - subnets = new ArrayList(); - if (this.status == null) - this.status = "ACTIVE"; - if (this.adminStateUp == null) - this.adminStateUp = true; - if (this.shared == null) - this.shared = false; - if (this.routerExternal == null) - this.routerExternal = false; - if (this.providerNetworkType == null) - this.providerNetworkType = "flat"; - } - - public String getID() { return networkUUID; } - - public String getNetworkUUID() { - return networkUUID; - } - - public void setNetworkUUID(String networkUUID) { - this.networkUUID = networkUUID; - } - - public String getNetworkName() { - return networkName; - } - - public void setNetworkName(String networkName) { - this.networkName = networkName; - } - - public boolean isAdminStateUp() { - return adminStateUp; - } - - public Boolean getAdminStateUp() { return adminStateUp; } - - public void setAdminStateUp(boolean newValue) { - this.adminStateUp = newValue; - } - - public boolean isShared() { return shared; } - - public Boolean getShared() { return shared; } - - public void setShared(boolean newValue) { - this.shared = newValue; - } - - public String getTenantID() { - return tenantID; - } - - public void setTenantID(String tenantID) { - this.tenantID = tenantID; - } - - public boolean isRouterExternal() { return routerExternal; } - - public Boolean getRouterExternal() { return routerExternal; } - - public void setRouterExternal(boolean newValue) { - this.routerExternal = newValue; - } - - public String getProviderNetworkType() { - return providerNetworkType; - } - - public void setProviderNetworkType(String providerNetworkType) { - this.providerNetworkType = providerNetworkType; - } - - public String getProviderPhysicalNetwork() { - return providerPhysicalNetwork; - } - - public void setProviderPhysicalNetwork(String providerPhysicalNetwork) { - this.providerPhysicalNetwork = providerPhysicalNetwork; - } - - public String getProviderSegmentationID() { - return providerSegmentationID; - } - - public void setProviderSegmentationID(String providerSegmentationID) { - this.providerSegmentationID = providerSegmentationID; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public List getSubnets() { - return subnets; - } - - public void setSubnets(List subnets) { - this.subnets = subnets; - } - - public void addSubnet(String uuid) { - this.subnets.add(uuid); - } - - public void removeSubnet(String uuid) { - this.subnets.remove(uuid); - } - - public List getPortsOnNetwork() { - return myPorts; - } - - public void addPort(NeutronPort port) { - myPorts.add(port); - } - - public void removePort(NeutronPort port) { - myPorts.remove(port); - } - - /** - * This method copies selected fields from the object and returns them - * as a new object, suitable for marshaling. - * - * @param fields - * List of attributes to be extracted - * @return an OpenStackNetworks object with only the selected fields - * populated - */ - - public NeutronNetwork extractFields(List fields) { - NeutronNetwork ans = new NeutronNetwork(); - Iterator i = fields.iterator(); - while (i.hasNext()) { - String s = i.next(); - if (s.equals("id")) - ans.setNetworkUUID(this.getNetworkUUID()); - if (s.equals("name")) - ans.setNetworkName(this.getNetworkName()); - if (s.equals("admin_state_up")) - ans.setAdminStateUp(this.adminStateUp); - if (s.equals("status")) - ans.setStatus(this.getStatus()); - if (s.equals("subnets")) { - List subnetList = new ArrayList(); - subnetList.addAll(this.getSubnets()); - ans.setSubnets(subnetList); - } - if (s.equals("shared")) - ans.setShared(this.shared); - if (s.equals("tenant_id")) - ans.setTenantID(this.getTenantID()); - } - return ans; - } - -} - +/* + * Copyright IBM Corporation, 2013. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.networkconfig.neutron; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "network") +@XmlAccessorType(XmlAccessType.NONE) + +public class NeutronNetwork implements Serializable { + // See OpenStack Network API v2.0 Reference for description of + // annotated attributes + + private static final long serialVersionUID = 1L; + + @XmlElement (name="id") + String networkUUID; // network UUID + + @XmlElement (name="name") + String networkName; // name + + @XmlElement (defaultValue="true", name="admin_state_up") + Boolean adminStateUp; // admin state up (true/false) + + @XmlElement (defaultValue="false", name="shared") + Boolean shared; // shared network or not + + @XmlElement (name="tenant_id") + String tenantID; // tenant for this network + + @XmlElement (defaultValue="false", namespace="router", name="external") + Boolean routerExternal; // network external or not + + @XmlElement (defaultValue="flat", namespace="provider", name="network_type") + String providerNetworkType; // provider network type (flat or vlan) + + @XmlElement (namespace="provider", name="physical_network") + String providerPhysicalNetwork; // provider physical network (name) + + @XmlElement (namespace="provider", name="segmentation_id") + String providerSegmentationID; // provide segmentation ID (vlan ID) + + @XmlElement (name="status") + String status; // status (read-only) + + @XmlElement (name="subnets") + List subnets; // subnets (read-only) + + /* This attribute lists the ports associated with an instance + * which is needed for determining if that instance can be deleted + */ + + List myPorts; + + public NeutronNetwork() { + myPorts = new ArrayList(); + } + + public void initDefaults() { + subnets = new ArrayList(); + if (status == null) { + status = "ACTIVE"; + } + if (adminStateUp == null) { + adminStateUp = true; + } + if (shared == null) { + shared = false; + } + if (routerExternal == null) { + routerExternal = false; + } + if (providerNetworkType == null) { + providerNetworkType = "flat"; + } + } + + public String getID() { return networkUUID; } + + public String getNetworkUUID() { + return networkUUID; + } + + public void setNetworkUUID(String networkUUID) { + this.networkUUID = networkUUID; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public boolean isAdminStateUp() { + return adminStateUp; + } + + public Boolean getAdminStateUp() { return adminStateUp; } + + public void setAdminStateUp(boolean newValue) { + adminStateUp = newValue; + } + + public boolean isShared() { return shared; } + + public Boolean getShared() { return shared; } + + public void setShared(boolean newValue) { + shared = newValue; + } + + public String getTenantID() { + return tenantID; + } + + public void setTenantID(String tenantID) { + this.tenantID = tenantID; + } + + public boolean isRouterExternal() { return routerExternal; } + + public Boolean getRouterExternal() { return routerExternal; } + + public void setRouterExternal(boolean newValue) { + routerExternal = newValue; + } + + public String getProviderNetworkType() { + return providerNetworkType; + } + + public void setProviderNetworkType(String providerNetworkType) { + this.providerNetworkType = providerNetworkType; + } + + public String getProviderPhysicalNetwork() { + return providerPhysicalNetwork; + } + + public void setProviderPhysicalNetwork(String providerPhysicalNetwork) { + this.providerPhysicalNetwork = providerPhysicalNetwork; + } + + public String getProviderSegmentationID() { + return providerSegmentationID; + } + + public void setProviderSegmentationID(String providerSegmentationID) { + this.providerSegmentationID = providerSegmentationID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getSubnets() { + return subnets; + } + + public void setSubnets(List subnets) { + this.subnets = subnets; + } + + public void addSubnet(String uuid) { + subnets.add(uuid); + } + + public void removeSubnet(String uuid) { + subnets.remove(uuid); + } + + public List getPortsOnNetwork() { + return myPorts; + } + + public void addPort(NeutronPort port) { + myPorts.add(port); + } + + public void removePort(NeutronPort port) { + myPorts.remove(port); + } + + /** + * This method copies selected fields from the object and returns them + * as a new object, suitable for marshaling. + * + * @param fields + * List of attributes to be extracted + * @return an OpenStackNetworks object with only the selected fields + * populated + */ + + public NeutronNetwork extractFields(List fields) { + NeutronNetwork ans = new NeutronNetwork(); + Iterator i = fields.iterator(); + while (i.hasNext()) { + String s = i.next(); + if (s.equals("id")) { + ans.setNetworkUUID(this.getNetworkUUID()); + } + if (s.equals("name")) { + ans.setNetworkName(this.getNetworkName()); + } + if (s.equals("admin_state_up")) { + ans.setAdminStateUp(adminStateUp); + } + if (s.equals("status")) { + ans.setStatus(this.getStatus()); + } + if (s.equals("subnets")) { + List subnetList = new ArrayList(); + subnetList.addAll(this.getSubnets()); + ans.setSubnets(subnetList); + } + if (s.equals("shared")) { + ans.setShared(shared); + } + if (s.equals("tenant_id")) { + ans.setTenantID(this.getTenantID()); + } + } + return ans; + } + + @Override + public String toString() { + return "NeutronNetwork [networkUUID=" + networkUUID + ", networkName=" + networkName + ", adminStateUp=" + + adminStateUp + ", shared=" + shared + ", tenantID=" + tenantID + ", routerExternal=" + routerExternal + + ", providerNetworkType=" + providerNetworkType + ", providerPhysicalNetwork=" + + providerPhysicalNetwork + ", providerSegmentationID=" + providerSegmentationID + ", status=" + status + + ", subnets=" + subnets + ", myPorts=" + myPorts + "]"; + } +} +