summaryrefslogtreecommitdiffstats
path: root/quantum-model/src
diff options
context:
space:
mode:
authorChrisC <cc697w@intl.att.com>2017-01-31 13:57:24 +0100
committerChrisC <cc697w@intl.att.com>2017-01-31 14:55:11 +0100
commit2e984294ac28c6f2ede290c38164c5d536ccaf4a (patch)
tree5eba5a929b7a961c98749fa69e03cfea58e1a724 /quantum-model/src
parent86c0f28c8ed469486b64d6422dc53e3a7bcc8adb (diff)
Initial OpenECOMP MSO OpenStack SDK lib commit
Change-Id: Ieaacb2b2c0dcc469669880e73f0cda9fa59a6c5a Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'quantum-model/src')
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java24
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java27
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java321
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java9
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java38
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/NeutronError.java69
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Pool.java40
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java373
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java12
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java40
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java77
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java28
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java75
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java19
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java38
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Segment.java79
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java264
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java34
-rw-r--r--quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java36
-rw-r--r--quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java119
-rw-r--r--quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java155
-rw-r--r--quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java137
22 files changed, 2014 insertions, 0 deletions
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java
new file mode 100644
index 0000000..2a7766f
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java
@@ -0,0 +1,24 @@
+package com.woorea.openstack.quantum.model;
+
+import java.util.List;
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class GatewayInfo implements Serializable {
+
+ @JsonProperty("network_id")
+ private String networkId;
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String id) {
+ this.networkId = id;
+ }
+
+ @Override public String toString() {
+ return "[networkId=" + networkId + "]";
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java
new file mode 100644
index 0000000..979add3
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java
@@ -0,0 +1,27 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+public class HostRoute implements Serializable {
+
+ private String destination;
+ private String nexthop;
+
+ public String getDestination() {
+ return destination;
+ }
+ public void setDestination(String destination) {
+ this.destination = destination;
+ }
+
+ public String getNexthop() {
+ return nexthop;
+ }
+ public void setNexthop(String nexthop) {
+ this.nexthop = nexthop;
+ }
+
+ @Override public String toString() {
+ return "[destination=" + destination + ", nexthop=" + nexthop + "]";
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java
new file mode 100644
index 0000000..f880619
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java
@@ -0,0 +1,321 @@
+package com.woorea.openstack.quantum.model;
+
+/*
+ * Modifications copyright (c) 2017 AT&T Intellectual Property
+ */
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+/**
+ * Network Extension supporting both Provider networks and Multi-Provider networks.
+ * The attributes for both of these network extensions are included.
+ * It is the responsibility of users to populate only one or the other. It is
+ * also critical that the Mapper is set for serialization inclusion.NON_NULL, or
+ * both would be sent to Openstack which would cause an error.
+ *
+ */
+@SuppressWarnings("serial")
+@JsonRootName("network")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Network implements Serializable {
+
+ private String status;
+
+ private List<String> subnets;
+
+ private String name;
+
+ @JsonProperty("admin_state_up")
+ private Boolean adminStateUp;
+
+ @JsonProperty("tenant_id")
+ private String tenantId;
+
+ @JsonProperty("provider:physical_network")
+ private String providerPhysicalNetwork;
+
+ @JsonProperty("provider:network_type")
+ private String providerNetworkType;
+
+ @JsonProperty("provider:segmentation_id")
+ private Integer providerSegmentationId;
+
+ @JsonProperty("router:external")
+ private String routerExternal;
+
+ private String id;
+
+ private String shared;
+
+ private List<Segment> segments;
+
+ /**
+ * @return the status
+ */
+ @JsonIgnore
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status
+ * the status to set
+ */
+ @JsonProperty
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * @return the subnets
+ */
+ @JsonIgnore
+ public List<String> getSubnets() {
+ return subnets;
+ }
+
+ /**
+ * @param subnets
+ * the subnets to set
+ */
+ @JsonProperty
+ public void setSubnets(List<String> subnets) {
+ this.subnets = subnets;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the providerPhyNet
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public String getProviderPhyNet() {
+ return getProviderPhysicalNetwork();
+ }
+
+ /**
+ * @param providerPhyNet
+ * the providerPhyNet to set
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public void setProviderPhyNet(String providerPhyNet) {
+ setProviderPhysicalNetwork(providerPhyNet);
+ }
+
+ /**
+ * @return the adminStateUp
+ */
+ @JsonIgnore
+ public boolean isAdminStateUp() {
+ return adminStateUp;
+ }
+
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @param adminStateUp
+ * the adminStateUp to set
+ */
+ public void setAdminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ }
+
+ /**
+ * @return the tenantId
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId
+ * the tenantId to set
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return the netType
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public String getNetType() {
+ return getProviderNetworkType();
+ }
+
+ /**
+ * @param netType
+ * the netType to set
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public void setNetType(String netType) {
+ setProviderNetworkType(netType);
+ }
+
+ /**
+ * @return the routerExternal
+ */
+ public String getRouterExternal() {
+ return routerExternal;
+ }
+
+ /**
+ * @param routerExternal
+ * the routerExternal to set
+ */
+ public void setRouterExternal(String routerExternal) {
+ this.routerExternal = routerExternal;
+ }
+
+ /**
+ * @return the id
+ */
+ @JsonIgnore
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ @JsonProperty
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the shared
+ */
+ public String getShared() {
+ return shared;
+ }
+
+ /**
+ * @param shared
+ * the shared to set
+ */
+ public void setShared(String shared) {
+ this.shared = shared;
+ }
+
+ /**
+ * @return the providerSegID
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public String getProviderSegID() {
+ return getProviderSegmentationId() == null ? null : Integer.toString(getProviderSegmentationId());
+ }
+
+ /**
+ * @param providerSegID
+ * the providerSegID to set
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public void setProviderSegID(String providerSegID) {
+ setProviderSegmentationId(providerSegID == null ? null : Integer.parseInt(providerSegID));
+ }
+
+ 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 Integer getProviderSegmentationId() {
+ return providerSegmentationId;
+ }
+
+ public void setProviderSegmentationId(Integer providerSegmentationId) {
+ this.providerSegmentationId = providerSegmentationId;
+ }
+
+ public List<Segment> getSegments() {
+ return segments;
+ }
+
+ public void setSegments(List<Segment> segments) {
+ this.segments = segments;
+ }
+
+ /**
+ * Function to detect and return the network type
+ */
+ public enum NetworkType { BASIC, PROVIDER, MULTI_PROVIDER };
+
+ @JsonIgnore
+ public NetworkType getNetworkType () {
+ if (segments != null)
+ return NetworkType.MULTI_PROVIDER;
+ else if (providerNetworkType != null)
+ return NetworkType.PROVIDER;
+ else
+ return NetworkType.BASIC;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer buf = new StringBuffer("Network [id=" + id + ", name=" + name + ", subnets="
+ + subnets + ", status=" + status + ", admin_state_up=" + adminStateUp + ", tenant_id=" +
+ tenantId + ", shared=" + shared + ", router:external=" + routerExternal);
+ if (getNetworkType() == NetworkType.PROVIDER)
+ buf.append (", provider:physical_network=" + providerPhysicalNetwork +
+ ", provider:network_type=" + providerNetworkType +
+ ", provider:segmentation_id=" + providerSegmentationId);
+ if (getNetworkType() == NetworkType.MULTI_PROVIDER) {
+ buf.append (", segments: ");
+ for (Segment s : segments)
+ buf.append (s.toString()).append(" ");
+ }
+ buf.append ("]");
+ return buf.toString();
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java
new file mode 100644
index 0000000..507e39b
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java
@@ -0,0 +1,9 @@
+package com.woorea.openstack.quantum.model;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@SuppressWarnings("serial")
+@JsonRootName("network")
+@Deprecated
+public class NetworkForCreate extends Network {
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java
new file mode 100644
index 0000000..a4fd330
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java
@@ -0,0 +1,38 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Networks implements Iterable<Network>, Serializable{
+
+ @JsonProperty("networks")
+ private List<Network> list;
+
+ /**
+ * @return the list
+ */
+ public List<Network> getList() {
+ return list;
+ }
+
+
+ /**
+ * @param list the list to set
+ */
+ public void setList(List<Network> list) {
+ this.list = list;
+ }
+
+
+ public String toString() {
+ return "Networks [list=" + list + "]";
+ }
+
+
+ public Iterator<Network> iterator() {
+ return list.iterator();
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NeutronError.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NeutronError.java
new file mode 100644
index 0000000..3fbd390
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NeutronError.java
@@ -0,0 +1,69 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@JsonRootName("NeutronError")
+public class NeutronError implements Serializable {
+
+ private String type;
+
+ private String message;
+
+ private String detail;
+
+ /**
+ * @return the code
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return the title
+ */
+ public String getDetail() {
+ return detail;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "NeutronError [type=" + type + ", title=" + detail + ", message="
+ + message + "]";
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Pool.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Pool.java
new file mode 100644
index 0000000..d25bafe
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Pool.java
@@ -0,0 +1,40 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+public class Pool implements Serializable{
+
+ private String start;
+ private String end;
+
+ /**
+ * @return the start
+ */
+ public String getStart() {
+ return start;
+ }
+ /**
+ * @param start the start to set
+ */
+ public void setStart(String start) {
+ this.start = start;
+ }
+ /**
+ * @return the end
+ */
+ public String getEnd() {
+ return end;
+ }
+ /**
+ * @param end the end to set
+ */
+ public void setEnd(String end) {
+ this.end = end;
+ }
+
+ @Override
+ public String toString() {
+ return "Allocation_pool [start=" + start + ", end=" + end + "]";
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java
new file mode 100644
index 0000000..8ca74f1
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java
@@ -0,0 +1,373 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonUnwrapped;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@SuppressWarnings("serial")
+@JsonRootName("port")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Port implements Serializable {
+
+ public static final class Ip implements Serializable {
+
+ @JsonProperty("ip_address")
+ private String address;
+
+ @JsonProperty("subnet_id")
+ private String subnetId;
+
+ /**
+ * @return the address
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @param address
+ * the address to set
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ /**
+ * @return the subnetId
+ */
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @param subnetId
+ * the subnetId to set
+ */
+ public void setSubnetId(String subnetId) {
+ this.subnetId = subnetId;
+ }
+
+ @Override
+ public String toString() {
+ return "ip_addresses [ip_address=" + address + ", subnet_id=" + subnetId + "]";
+ }
+
+ }
+
+ public static final class Binding {
+
+ /**
+ * The host on which the port will be allocated.
+ */
+ @JsonProperty("binding:host_id")
+ private String hostId;
+
+ /**
+ * The vif type for the specific port.
+ */
+ @JsonProperty("binding:vif_type")
+ private String vifType;
+
+ /**
+ * The type of vnic that this port should be attached to
+ */
+ @JsonProperty("binding:vnic_type")
+ private String vnicType;
+
+ /**
+ * A map containing additional information needed by the interface driver
+ */
+ @JsonProperty("binding:vif_details")
+ private Map<String, String> vifDetails;
+
+ /**
+ * A map to enable applications running on the specific host to pass and receive vif port specific information
+ * to the plugin.
+ */
+ @JsonProperty("binding:profile")
+ private Map<String, String> profile;
+
+ public String getHostId() {
+ return hostId;
+ }
+
+ public void setHostId(String hostId) {
+ this.hostId = hostId;
+ }
+
+ public String getVifType() {
+ return vifType;
+ }
+
+ public void setVifType(String vifType) {
+ this.vifType = vifType;
+ }
+
+ public String getVnicType() {
+ return vnicType;
+ }
+
+ public void setVnicType(String vnicType) {
+ this.vnicType = vnicType;
+ }
+
+ public Map<String, String> getVifDetails() {
+ return vifDetails;
+ }
+
+ public void setVifDetails(Map<String, String> vifDetails) {
+ this.vifDetails = vifDetails;
+ }
+
+ public Map<String, String> getProfile() {
+ return profile;
+ }
+
+ public void setProfile(Map<String, String> profile) {
+ this.profile = profile;
+ }
+
+ @Override
+ public String toString() {
+ return "Binding [hostId=" + hostId
+ + ", vifType=" + vifType +
+ ", vnicType=" + vnicType +
+ ", vifDetails=" + vifDetails +
+ ", profile=" + profile + "]";
+ }
+ }
+
+ @JsonProperty("admin_state_up")
+ private Boolean adminStateUp;
+
+ @JsonProperty("device_id")
+ private String deviceId;
+
+ @JsonProperty("device_owner")
+ private String deviceOwner;
+
+ @JsonProperty("fixed_ips")
+ private List<Ip> list;
+
+ private String id;
+
+ @JsonProperty("mac_address")
+ private String macAddress;
+
+ private String name;
+
+ @JsonProperty("network_id")
+ private String networkId;
+
+ private String status;
+
+ @JsonProperty("tenant_id")
+ private String tenantId;
+
+ @JsonProperty("security_groups")
+ private List<String> securityGroups;
+
+ @JsonUnwrapped
+ private Binding binding;
+
+ /**
+ * @return the adminStateUp
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @param adminStateUp
+ * the adminStateUp to set
+ */
+ public void setAdminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ }
+
+ /**
+ * @return the deviceId
+ */
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @param deviceId
+ * the deviceId to set
+ */
+ public void setDeviceId(String deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ /**
+ * @return the deviceOwner
+ */
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @param deviceOwner
+ * the deviceOwner to set
+ */
+ public void setDeviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ }
+
+ /**
+ * @return the list
+ */
+ public List<Ip> getList() {
+ return list;
+ }
+
+ /**
+ * @param list
+ * the list to set
+ */
+ public void setList(List<Ip> list) {
+ this.list = list;
+ }
+
+ /**
+ * @return the id
+ */
+ @JsonIgnore
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ @JsonProperty
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the macAddress
+ */
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ /**
+ * @param macAddress
+ * the macAddress to set
+ */
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the networkId
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @param networkId
+ * the networkId to set
+ */
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ /**
+ * @return the status
+ */
+ @JsonIgnore
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status
+ * the status to set
+ */
+ @JsonProperty
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * @return the tenantId
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId
+ * the tenantId to set
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return the associated security group IDs
+ */
+ public List<String> getSecurityGroups() {
+ return securityGroups;
+ }
+
+ /**
+ * @param securityGroups
+ * IDs of security groups to associate to the port
+ */
+ public void setSecurityGroups(List<String> securityGroups) {
+ this.securityGroups = securityGroups;
+ }
+
+ /**
+ * @return the binding of the port
+ */
+ public Binding getBinding() {
+ return binding;
+ }
+
+ /**
+ * @param binding
+ * The port bindings by which the port is bind to network on host
+ */
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ }
+
+ @Override
+ public String toString() {
+ return "Port [id=" + id + ", name=" + name + ", mac_address="
+ + macAddress + ", admin_state_up=" + adminStateUp + ", device_id=" + deviceId
+ + ", device_owner=" + deviceOwner + ", fixed_ips=" + list
+ + ", network_id=" + networkId + ", status=" + status
+ + ", tenant_id=" + tenantId
+ + ", securityGroups=" + securityGroups
+ + ", binding=" + binding + "]";
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java
new file mode 100644
index 0000000..3c1af50
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java
@@ -0,0 +1,12 @@
+package com.woorea.openstack.quantum.model;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+/**
+ * @deprecated Please use {@link Port} directly.
+ */
+@SuppressWarnings("serial")
+@JsonRootName("port")
+@Deprecated
+public class PortForCreate extends Port {
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java
new file mode 100644
index 0000000..5f10d35
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java
@@ -0,0 +1,40 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@SuppressWarnings("serial")
+public class Ports implements Iterable<Port>, Serializable {
+
+ @JsonProperty("ports")
+ private List<Port> list;
+
+ /**
+ * @return the list
+ */
+ public List<Port> getList() {
+ return list;
+ }
+
+ /**
+ * @param list
+ * the list to set
+ */
+ public void setList(List<Port> list) {
+ this.list = list;
+ }
+
+ @Override
+ public Iterator<Port> iterator() {
+ return list.iterator();
+ }
+
+ @Override
+ public String toString() {
+ return "Ports [list=" + list + "]";
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java
new file mode 100644
index 0000000..a94afd5
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java
@@ -0,0 +1,77 @@
+package com.woorea.openstack.quantum.model;
+
+import java.util.List;
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@JsonRootName("router")
+public class Router implements Serializable {
+
+ @JsonProperty("status")
+ private String status;
+
+ @JsonProperty("external_gateway_info")
+ private GatewayInfo externalGatewayInfo;
+
+ @JsonProperty("name")
+ private String name;
+
+ @JsonProperty("admin_state_up")
+ private String admin_state_up;
+
+ @JsonProperty("tenant_id")
+ private String tenantId;
+
+ @JsonProperty("id")
+ private String id;
+
+ @JsonProperty("routes")
+ private List<HostRoute> routes;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public List<HostRoute> getRoutes() {
+ return routes;
+ }
+ public void setRoutes(List<HostRoute> routes) {
+ this.routes = routes;
+ }
+ public String getAdmin_state_up() {
+ return admin_state_up;
+ }
+ public void setAdmin_state_up(String admin_state_up) {
+ this.admin_state_up = admin_state_up;
+ }
+ public String getStatus() {
+ return status;
+ }
+ public void setStatus(String status) {
+ this.status = status;
+ }
+ public GatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+ public void setExternalGatewayInfo(GatewayInfo externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+ public String getTenantId() {
+ return tenantId;
+ }
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java
new file mode 100644
index 0000000..62ec302
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java
@@ -0,0 +1,28 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class RouterForAddInterface implements Serializable {
+
+ @JsonProperty("subnet_id")
+ String subnetId;
+ String routerId;
+
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ public void setSubnetId(String subnetId) {
+ this.subnetId = subnetId;
+ }
+
+ public String getRouterId() {
+ return routerId;
+ }
+
+ public void setRouterId(String routerId) {
+ this.routerId = routerId;
+ }
+ }
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java
new file mode 100644
index 0000000..b8c9291
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java
@@ -0,0 +1,75 @@
+package com.woorea.openstack.quantum.model;
+
+import java.util.List;
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@JsonRootName("router")
+public class RouterForCreate implements Serializable {
+
+ @JsonProperty("name")
+ private String name;
+
+ private List<HostRoute> routes;
+
+ @JsonProperty("admin_state_up")
+ private String admin_state_up;
+
+ @JsonProperty("status")
+ private String status;
+
+ @JsonProperty("external_gateway_info")
+ private GatewayInfo externalGatewayInfo;
+
+ @JsonProperty("tenant_id")
+ private String tenantId;
+
+ @JsonProperty("id")
+ private String id;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public List<HostRoute> getRoutes() {
+ return routes;
+ }
+ public void setRoutes(List<HostRoute> routes) {
+ this.routes = routes;
+ }
+ public String getAdmin_state_up() {
+ return admin_state_up;
+ }
+ public void setAdmin_state_up(String admin_state_up) {
+ this.admin_state_up = admin_state_up;
+ }
+ public String getStatus() {
+ return status;
+ }
+ public void setStatus(String status) {
+ this.status = status;
+ }
+ public GatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+ public void setExternalGatewayInfo(GatewayInfo externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+ public String getTenantId() {
+ return tenantId;
+ }
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java
new file mode 100644
index 0000000..2d7551f
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java
@@ -0,0 +1,19 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+public class RouterInterface implements Serializable {
+
+ @JsonProperty("subnet_id")
+ String subnetId;
+ @JsonProperty("port_id")
+ String portId;
+ @JsonProperty("tenant_id")
+ String tenantId;
+ @JsonProperty("id")
+ String id;
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java
new file mode 100644
index 0000000..e2a56b2
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java
@@ -0,0 +1,38 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Routers implements Iterable<Router>, Serializable{
+
+ @JsonProperty("routers")
+ private List<Router> list;
+
+ /**
+ * @return the list
+ */
+ public List<Router> getList() {
+ return list;
+ }
+
+
+ /**
+ * @param list the list to set
+ */
+ public void setList(List<Router> list) {
+ this.list = list;
+ }
+
+
+ public String toString() {
+ return "Routers [list=" + list + "]";
+ }
+
+
+ public Iterator<Router> iterator() {
+ return list.iterator();
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Segment.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Segment.java
new file mode 100644
index 0000000..de78967
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Segment.java
@@ -0,0 +1,79 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@SuppressWarnings("serial")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Segment implements Serializable {
+
+ @JsonProperty("provider:physical_network")
+ private String providerPhysicalNetwork;
+
+ @JsonProperty("provider:network_type")
+ private String providerNetworkType;
+
+ @JsonProperty("provider:segmentation_id")
+ private Integer providerSegmentationId;
+
+ 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 Integer getProviderSegmentationId() {
+ return providerSegmentationId;
+ }
+
+ public void setProviderSegmentationId(Integer providerSegmentationId) {
+ this.providerSegmentationId = providerSegmentationId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Segment [ provider:physical_network=" + providerPhysicalNetwork +
+ ", provider:network_type=" + providerNetworkType +
+ ", provider:segmentation_id=" + providerSegmentationId + "]";
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java
new file mode 100644
index 0000000..7301514
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java
@@ -0,0 +1,264 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonValue;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+@SuppressWarnings("serial")
+@JsonRootName("subnet")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Subnet implements Serializable {
+
+ private String name;
+
+ @JsonProperty("enable_dhcp")
+ private Boolean enableDHCP;
+
+ @JsonProperty("network_id")
+ private String networkId;
+
+ @JsonProperty("tenant_id")
+ private String tenantId;
+
+ @JsonProperty("dns_nameservers")
+ private List<String> dnsNames;
+
+ @JsonProperty("allocation_pools")
+ private List<Pool> list;
+
+ @JsonProperty("host_routes")
+ private List<String> hostRoutes;
+
+ @JsonProperty("ip_version")
+ private IpVersion ipversion;
+
+ @JsonProperty("gateway_ip")
+ private String gw;
+
+ private String cidr;
+
+ private String id;
+
+ public static enum IpVersion implements Serializable {
+ IPV4(4),
+ IPV6(6);
+ private int code;
+
+ IpVersion(int code) {
+ this.code = code;
+ }
+
+ @JsonValue
+ public int code() {
+ return code;
+ }
+
+ @JsonCreator
+ public static IpVersion valueOf(int value) {
+ for (IpVersion ipVersion : IpVersion.values()) {
+ if (ipVersion.code() == value) {
+ return ipVersion;
+ }
+ }
+ return IPV4;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(code);
+ }
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the enableDHCP
+ */
+ @JsonIgnore
+ public boolean isEnableDHCP() {
+ return enableDHCP;
+ }
+
+ public Boolean getEnableDHCP() {
+ return enableDHCP;
+ }
+
+ /**
+ * @param enableDHCP
+ * the enableDHCP to set
+ */
+ public void setEnableDHCP(Boolean enableDHCP) {
+ this.enableDHCP = enableDHCP;
+ }
+
+ /**
+ * @return the networkId
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @param networkId
+ * the networkId to set
+ */
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ /**
+ * @return the tenantId
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId
+ * the tenantId to set
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return the dnsNames
+ */
+ public List<String> getDnsNames() {
+ return dnsNames;
+ }
+
+ /**
+ * @param dnsNames
+ * the dnsNames to set
+ */
+ public void setDnsNames(List<String> dnsNames) {
+ this.dnsNames = dnsNames;
+ }
+
+ /**
+ * @return the list
+ */
+ public List<Pool> getList() {
+ return list;
+ }
+
+ /**
+ * @param list
+ * the list to set
+ */
+ public void setList(List<Pool> list) {
+ this.list = list;
+ }
+
+ /**
+ * @return the hostRoutes
+ */
+ public List<String> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ /**
+ * @param hostRoutes
+ * the hostRoutes to set
+ */
+ public void setHostRoutes(List<String> hostRoutes) {
+ this.hostRoutes = hostRoutes;
+ }
+
+ /**
+ * @return the ipversion
+ */
+ public IpVersion getIpversion() {
+ return ipversion;
+ }
+
+ /**
+ * @param ipversion
+ * the ipversion to set
+ */
+ public void setIpversion(IpVersion ipversion) {
+ this.ipversion = ipversion;
+ }
+
+ /**
+ * @return the gw
+ */
+ public String getGw() {
+ return gw;
+ }
+
+ /**
+ * @param gw
+ * the gw to set
+ */
+ public void setGw(String gw) {
+ this.gw = gw;
+ }
+
+ /**
+ * @return the cidr
+ */
+ public String getCidr() {
+ return cidr;
+ }
+
+ /**
+ * @param cidr
+ * the cidr to set
+ */
+ public void setCidr(String cidr) {
+ this.cidr = cidr;
+ }
+
+ /**
+ * @return the id
+ */
+ @JsonIgnore
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ @JsonProperty
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Subnet [id=" + id + ", name=" + name + ", network_id="
+ + networkId + ", tenant_id=" + tenantId + ", allocation_pools=" + list
+ + ", gateway_ip=" + gw + ", ip_version=" + ipversion
+ + ", cidr=" + cidr + ", enable_dhcp=" + enableDHCP + ", dns_nameservers="
+ + dnsNames + ", host_routes=" + hostRoutes + "]";
+ }
+
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java
new file mode 100644
index 0000000..2c07ab2
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java
@@ -0,0 +1,34 @@
+package com.woorea.openstack.quantum.model;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+/**
+ * Please use {@link Subnet} directly.
+ */
+@SuppressWarnings("serial")
+@JsonRootName("subnet")
+@Deprecated
+public class SubnetForCreate extends Subnet {
+
+ /**
+ * @return the ipVersion
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public int getIpVersion() {
+ return getIpversion().code();
+ }
+
+ /**
+ * @param ipVersion
+ * the ipVersion to set
+ * @deprecated
+ */
+ @Deprecated
+ @JsonIgnore
+ public void setIpVersion(int ipVersion) {
+ setIpversion(IpVersion.valueOf(ipVersion));
+ }
+}
diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java
new file mode 100644
index 0000000..e9b21f4
--- /dev/null
+++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java
@@ -0,0 +1,36 @@
+package com.woorea.openstack.quantum.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Subnets implements Serializable, Iterable<Subnet> {
+
+ @JsonProperty("subnets")
+ private List<Subnet> list;
+
+ /**
+ * @return the list
+ */
+ public List<Subnet> getList() {
+ return list;
+ }
+
+ /**
+ * @param list the list to set
+ */
+ public void setList(List<Subnet> list) {
+ this.list = list;
+ }
+
+ public String toString() {
+ return "Subnets [list=" + list + "]";
+ }
+
+ public Iterator<Subnet> iterator() {
+ return list.iterator();
+ }
+
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java
new file mode 100644
index 0000000..b6255b9
--- /dev/null
+++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java
@@ -0,0 +1,119 @@
+package com.woorea.openstack.quantum.model;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+public class NetworkTest {
+
+ private static final String ID = "testId";
+
+ private static final boolean ADMIN_STATE_UP = true;
+
+ private static final String NAME = "name";
+
+ private static final String TENANT_ID = "tenantId";
+
+ private static final String SHARED = "shared";
+
+ private static final String STATUS = "status";
+
+ private static final String SUBNET = "subnet";
+
+ private static final String PROVIDER_NETWORK_TYPE = "vlan";
+
+ private static final String PROVIDER_PHYSICAL_NETWORK = "physicalNetwork";
+
+ private static final int PROVIDER_SEGMENTATION_ID = 100;
+
+ private static final String ROUTER_EXTERNAL = "routerExternal";
+
+ /**
+ * JSON with read only attributes.
+ */
+ private static final String NETWORK_JSON = "{"
+ + " \"network\" : {"
+ + " \"id\" : \"" + ID + "\","
+ + " \"status\" : \"" + STATUS + "\","
+ + " \"subnets\" : [ \"" + SUBNET + "\" ]"
+ + " }"
+ + "}";
+
+ private ObjectMapper objectMapper;
+
+ private String serializedNetwork;
+
+ @Before
+ public void setUp() throws Exception {
+ objectMapper = PortTest.initializeObjectMapper();
+ }
+
+ @Test
+ public void testSerialization() throws Exception {
+ Network network = new Network();
+ network.setId(ID);
+ network.setProviderNetworkType(PROVIDER_NETWORK_TYPE);
+ network.setProviderPhysicalNetwork(PROVIDER_PHYSICAL_NETWORK);
+ network.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID);
+ network.setAdminStateUp(ADMIN_STATE_UP);
+ network.setSubnets(Arrays.asList(SUBNET));
+ network.setRouterExternal(ROUTER_EXTERNAL);
+ network.setName(NAME);
+ network.setShared(SHARED);
+ network.setTenantId(TENANT_ID);
+
+ serializedNetwork = objectMapper.writeValueAsString(network);
+ assertThat(serializedNetwork, not(containsString(ID)));
+ assertThat(serializedNetwork, not(containsString(STATUS)));
+ assertThat(serializedNetwork, not(containsString(SUBNET)));
+ assertThat(serializedNetwork, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP));
+ assertThat(serializedNetwork, containsString(NAME));
+ assertThat(serializedNetwork, containsString(SHARED));
+ assertThat(serializedNetwork, containsString(TENANT_ID));
+ assertThat(serializedNetwork, containsString(ROUTER_EXTERNAL));
+ assertThat(serializedNetwork, containsString(PROVIDER_NETWORK_TYPE));
+ assertThat(serializedNetwork, containsString(PROVIDER_PHYSICAL_NETWORK));
+ assertThat(serializedNetwork, containsString(Integer.toString(PROVIDER_SEGMENTATION_ID)));
+ }
+
+ @Test
+ public void testSerializationEmpty() throws Exception {
+ Network network = new Network();
+ serializedNetwork = objectMapper.writeValueAsString(network);
+
+ assertThat(serializedNetwork, containsString("\"network\" : { }"));
+ }
+
+ @Test
+ public void testDeserializationReadOnlyFields() throws Exception {
+ Network network = objectMapper.readValue(NETWORK_JSON, Network.class);
+
+ assertThat(network.getId(), is(equalTo(ID)));
+ assertThat(network.getSubnets(), hasItem(equalTo(SUBNET)));
+ assertThat(network.getStatus(), is(equalTo(STATUS)));
+ }
+
+ @Test
+ public void testDeserialization() throws Exception {
+ testSerialization();
+ Network network = objectMapper.readValue(serializedNetwork, Network.class);
+
+ assertThat(network.getName(), is(equalTo(NAME)));
+ assertThat(network.isAdminStateUp(), is(equalTo(ADMIN_STATE_UP)));
+ assertThat(network.getShared(), is(equalTo(SHARED)));
+ assertThat(network.getTenantId(), is(equalTo(TENANT_ID)));
+ assertThat(network.getRouterExternal(), is(equalTo(ROUTER_EXTERNAL)));
+ assertThat(network.getProviderNetworkType(), is(equalTo(PROVIDER_NETWORK_TYPE)));
+ assertThat(network.getProviderPhysicalNetwork(), is(equalTo(PROVIDER_PHYSICAL_NETWORK)));
+ assertThat(network.getProviderSegmentationId(), is(equalTo(PROVIDER_SEGMENTATION_ID)));
+ }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java
new file mode 100644
index 0000000..bce5044
--- /dev/null
+++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java
@@ -0,0 +1,155 @@
+package com.woorea.openstack.quantum.model;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.hamcrest.CustomMatcher;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.woorea.openstack.quantum.model.Port.Ip;
+
+public class PortTest {
+
+ private static final String TENANT_ID = "tenantId";
+
+ private static final String STATUS = "status";
+
+ private static final String NETWORK_ID = "networkId";
+
+ private static final String NAME = "name";
+
+ private static final String MAC_ADDRESS = "macAddress";
+
+ private static final String DEVICE_OWNER = "deviceOwner";
+
+ private static final String DEVICE_ID = "deviceId";
+
+ private static final String IP_SUBNET_ID = "ipSubnetId";
+
+ private static final String IP_ADDRESS = "10.0.0.1";
+
+ private static final boolean ADMIN_STATE_UP = true;
+
+ private static final String SEC_GROUP = "secGroup";
+
+ private static final String ID = "testId";
+
+ /**
+ * JSON with read only attributes.
+ */
+ private static final String PORT_JSON = "{"
+ + " \"port\" : {"
+ + " \"id\" : \"" + ID + "\","
+ + " \"status\" : \"" + STATUS + "\""
+ + " }"
+ + "}";
+
+ private ObjectMapper objectMapper;
+
+ private String serializedPort;
+
+ @Before
+ public void setUp() throws Exception {
+ objectMapper = initializeObjectMapper();
+ }
+
+ public static ObjectMapper initializeObjectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(Inclusion.NON_NULL)
+ .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+ .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+ .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+ .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ return objectMapper;
+ }
+
+ @Test
+ public void testSerialization() throws Exception {
+ Port port = new Port();
+ port.setId(ID);
+ port.setAdminStateUp(ADMIN_STATE_UP);
+ port.setSecurityGroups(Arrays.asList(SEC_GROUP));
+ port.setDeviceId(DEVICE_ID);
+ port.setDeviceOwner(DEVICE_OWNER);
+ port.setMacAddress(MAC_ADDRESS);
+ port.setName(NAME);
+ port.setNetworkId(NETWORK_ID);
+ port.setStatus(STATUS);
+ port.setTenantId(TENANT_ID);
+
+ List<Ip> ips = new ArrayList<Port.Ip>();
+ Ip ip = new Ip();
+ ip.setAddress(IP_ADDRESS);
+ ip.setSubnetId(IP_SUBNET_ID);
+ ips.add(ip);
+ port.setList(ips);
+
+ serializedPort = objectMapper.writeValueAsString(port);
+ assertThat(serializedPort, not(containsString(ID)));
+ assertThat(serializedPort, not(containsString(STATUS)));
+ assertThat(serializedPort, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP));
+ assertThat(serializedPort, containsString(SEC_GROUP));
+ assertThat(serializedPort, containsString(IP_ADDRESS));
+ assertThat(serializedPort, containsString(DEVICE_ID));
+ assertThat(serializedPort, containsString(DEVICE_OWNER));
+ assertThat(serializedPort, containsString(MAC_ADDRESS));
+ assertThat(serializedPort, containsString(NAME));
+ assertThat(serializedPort, containsString(NETWORK_ID));
+ assertThat(serializedPort, containsString(TENANT_ID));
+ }
+
+ @Test
+ public void testSerializationEmpty() throws Exception {
+ Port port = new Port();
+ serializedPort = objectMapper.writeValueAsString(port);
+
+ assertThat(serializedPort, containsString("\"port\" : { }"));
+ }
+
+ @Test
+ public void testDeserializationReadOnlyFields() throws Exception {
+ Port port = objectMapper.readValue(PORT_JSON, Port.class);
+
+ assertThat(port.getId(), is(equalTo(ID)));
+ assertThat(port.getStatus(), is(equalTo(STATUS)));
+ }
+
+ @Test
+ public void testDeserializationAfterSerialization() throws Exception {
+ testSerialization();
+ Port port = objectMapper.readValue(serializedPort, Port.class);
+
+ assertThat(port.getAdminStateUp(), is(equalTo(ADMIN_STATE_UP)));
+ assertThat(port.getDeviceId(), is(equalTo(DEVICE_ID)));
+ assertThat(port.getDeviceOwner(), is(equalTo(DEVICE_OWNER)));
+ assertThat(port.getMacAddress(), is(equalTo(MAC_ADDRESS)));
+ assertThat(port.getName(), is(equalTo(NAME)));
+ assertThat(port.getNetworkId(), is(equalTo(NETWORK_ID)));
+ assertThat(port.getTenantId(), is(equalTo(TENANT_ID)));
+
+ assertThat(port.getSecurityGroups(), hasItem(equalTo(SEC_GROUP)));
+ assertThat(port.getList(), hasItem(new CustomMatcher<Ip>(
+ "an Ip object with address " + IP_ADDRESS + " and subnet id " + IP_SUBNET_ID) {
+
+ @Override
+ public boolean matches(Object ip) {
+ return ip instanceof Ip
+ && IP_ADDRESS.equals(((Ip) ip).getAddress())
+ && IP_SUBNET_ID.equals(((Ip) ip).getSubnetId());
+ }
+ }));
+ }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java
new file mode 100644
index 0000000..9136a38
--- /dev/null
+++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java
@@ -0,0 +1,137 @@
+package com.woorea.openstack.quantum.model;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.hamcrest.CustomMatcher;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.woorea.openstack.quantum.model.Subnet.IpVersion;
+
+public class SubnetTest {
+
+ private static final String POOL_END = "poolEnd";
+
+ private static final String POOL_START = "poolStart";
+
+ private static final String TENANT_ID = "tenantId";
+
+ private static final String NETWORK_ID = "networkId";
+
+ private static final String NAME = "name";
+
+ private static final String HOST_ROUTE = "hostRoute";
+
+ private static final String GATEWAY = "gw";
+
+ private static final boolean ENABLE_DHCP = true;
+
+ private static final String ID = "testId";
+
+ private static final String CIDR = "10.0.0.0/8";
+
+ private static final String DNS_SERVER = "dnsServer";
+
+ private static final IpVersion IP_VERSION = IpVersion.IPV4;
+
+ /**
+ * JSON with read only attributes.
+ */
+ private static final String SUBNET_JSON = "{"
+ + " \"subnet\" : {"
+ + " \"id\" : \"" + ID + "\""
+ + " }"
+ + "}";
+
+ private ObjectMapper objectMapper;
+
+ private String serializedSubnet;
+
+ @Before
+ public void setUp() throws Exception {
+ objectMapper = PortTest.initializeObjectMapper();
+ }
+
+ @Test
+ public void testSerialization() throws Exception {
+ Subnet subnet = new Subnet();
+ subnet.setId(ID);
+ subnet.setCidr(CIDR);
+ subnet.setDnsNames(Arrays.asList(DNS_SERVER));
+ subnet.setEnableDHCP(ENABLE_DHCP);
+ subnet.setIpversion(IP_VERSION);
+ subnet.setGw(GATEWAY);
+ subnet.setHostRoutes(Arrays.asList(HOST_ROUTE));
+ subnet.setName(NAME);
+ subnet.setNetworkId(NETWORK_ID);
+ subnet.setTenantId(TENANT_ID);
+
+ Pool pool = new Pool();
+ pool.setStart(POOL_START);
+ pool.setEnd(POOL_END);
+ subnet.setList(Arrays.asList(pool));
+
+ serializedSubnet = objectMapper.writeValueAsString(subnet);
+ assertThat(serializedSubnet, not(containsString(ID)));
+ assertThat(serializedSubnet, containsString(CIDR));
+ assertThat(serializedSubnet, containsString(DNS_SERVER));
+ assertThat(serializedSubnet, containsString("\"enable_dhcp\" : " + ENABLE_DHCP));
+ assertThat(serializedSubnet, containsString(Integer.toString(IP_VERSION.code())));
+ assertThat(serializedSubnet, containsString(GATEWAY));
+ assertThat(serializedSubnet, containsString(HOST_ROUTE));
+ assertThat(serializedSubnet, containsString(NAME));
+ assertThat(serializedSubnet, containsString(NETWORK_ID));
+ assertThat(serializedSubnet, containsString(TENANT_ID));
+ assertThat(serializedSubnet, containsString(POOL_START));
+ assertThat(serializedSubnet, containsString(POOL_END));
+ }
+
+ @Test
+ public void testSerializationEmpty() throws Exception {
+ Subnet subnet = new Subnet();
+ serializedSubnet = objectMapper.writeValueAsString(subnet);
+
+ assertThat(serializedSubnet, containsString("\"subnet\" : { }"));
+ }
+
+ @Test
+ public void testDeserializationReadOnlyFields() throws Exception {
+ Subnet subnet = objectMapper.readValue(SUBNET_JSON, Subnet.class);
+
+ assertThat(subnet.getId(), is(equalTo(ID)));
+ }
+
+ @Test
+ public void testDeserializationAfterSerialization() throws Exception {
+ testSerialization();
+ Subnet subnet = objectMapper.readValue(serializedSubnet, Subnet.class);
+
+ assertThat(subnet.getCidr(), is(equalTo(CIDR)));
+ assertThat(subnet.getDnsNames(), hasItem(equalTo(DNS_SERVER)));
+ assertThat(subnet.isEnableDHCP(), is(equalTo(ENABLE_DHCP)));
+ assertThat(subnet.getIpversion(), is(equalTo(IP_VERSION)));
+ assertThat(subnet.getGw(), is(equalTo(GATEWAY)));
+ assertThat(subnet.getHostRoutes(), hasItem(equalTo(HOST_ROUTE)));
+ assertThat(subnet.getName(), is(equalTo(NAME)));
+ assertThat(subnet.getNetworkId(), is(equalTo(NETWORK_ID)));
+ assertThat(subnet.getTenantId(), is(equalTo(TENANT_ID)));
+ assertThat(subnet.getList(), hasItem(new CustomMatcher<Pool>(
+ "a Pool object with start " + POOL_START + " and end " + POOL_END) {
+
+ @Override
+ public boolean matches(Object pool) {
+ return pool instanceof Pool
+ && POOL_START.equals(((Pool) pool).getStart())
+ && POOL_END.equals(((Pool) pool).getEnd());
+ }
+ }));
+ }
+}