yang model revise: neutron-binding.yang 30/39330/4
authorIsaku Yamahata <isaku.yamahata@intel.com>
Wed, 18 May 2016 19:44:12 +0000 (12:44 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 09:14:03 +0000 (02:14 -0700)
This patch revises yang model for neutron-binding and the related code.
- fix vif details. it's a dictionary

Change-Id: Ie1f7e4a63638f143c9396a5d6f1a81aad0628595
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/Neutron_Bug3812_Tests.java
integration/test/src/test/java/org/opendaylight/neutron/e2etest/Neutron_Bug4027_Tests.java
integration/test/src/test/java/org/opendaylight/neutron/e2etest/Tempest_PortsIpV6TestJSON.java
model/src/main/yang/neutron-binding.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFAdapter.java [new file with mode: 0644]
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetail.java [deleted file]
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronPortJAXBTest.java
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronPortSecurityJAXBTest.java
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetailJAXBTest.java [deleted file]
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronPortInterface.java

index b8bf52cfc3554d28fcd9c071df0a963c0a061a69..03f2df7700d9506b828a55d87f44bd64ec8378c7 100644 (file)
@@ -40,18 +40,18 @@ public class Neutron_Bug3812_Tests {
         ITNeutronE2E.test_create(url_p, content_p1, "Bug 3812 DHCP Port 1 Post Failed");
 
         String url_p1 = url_p + "/fcd1d7ab-8486-42a0-8f60-9d1a682aa00e";
-        String content_p1m1 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"binding:profile\": {}, \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": true}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
+        String content_p1m1 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"binding:profile\": {}, \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": \"true\"}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
         ITNeutronE2E.test_modify(url_p1, content_p1m1, "Bug 3812 DHCP Port 1 Put 1 Failed");
 
         // subnet 2 create
         String content_s2 = "{\"subnet\": {\"name\": \"s2\", \"enable_dhcp\": true, \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"tenant_id\": \"04684ce029a6415ca8a9293a24f884b9\", \"dns_nameservers\": [], \"gateway_ip\": \"20.0.0.1\", \"ipv6_ra_mode\": \"\", \"allocation_pools\": [{\"start\": \"20.0.0.2\", \"end\": \"20.0.3.254\"}], \"host_routes\": [], \"shared\": false, \"ip_version\": 4, \"ipv6_address_mode\": \"\", \"cidr\": \"20.0.0.0/22\", \"id\": \"dd9b62eb-d9a3-42b5-b2f1-bffa43475614\", \"subnetpool_id\": \"\"}}";
         ITNeutronE2E.test_create(url_s, content_s2, "Bug 3812 Subnet 2 Post Failed");
 
-        String content_p1m2 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"binding:profile\": {}, \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": true}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
+        String content_p1m2 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"binding:profile\": {}, \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": \"true\"}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
         ITNeutronE2E.test_modify(url_p1, content_p1m2, "Bug 3812 DHCP Port Put 2 Failed");
 
         // delete first subnet
-        String content_p1m3 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"binding:profile\": {}, \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": true}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
+        String content_p1m3 = "{\"port\": {\"binding:host_id\": \"00000000-1111-2222-3333-444444444444\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"binding:profile\": {}, \"network_id\": \"ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"security_groups\": [], \"device_id\": \"dhcp1c8f692f-b8db-5449-80ea-c9243b652e59-ec36ae5a-ff7f-4441-8229-179e5d5207a7\", \"name\": \"\", \"admin_state_up\": true, \"binding:vif_details\": {\"port_filter\": \"true\"}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\"}}";
         ITNeutronE2E.test_modify(url_p1, content_p1m3, "Bug 3812 DHCP Port Put 3 Failed");
 
         String url_s1 = url_s + "/64605c41-688d-4548-97da-0f895943f840";
index 273b46575a0b7264e5cd73658bd24545c34565c5..de45abe61ece4645e9123ed760b46ed22f462ecb 100644 (file)
@@ -44,7 +44,7 @@ public class Neutron_Bug4027_Tests {
             "\"binding:host_id\" : \"devstack-control\"," +
             "\"binding:vnic_type\" : \"normal\"," +
             "\"binding:vif_type\" : \"unbound\"," +
-            "\"binding:vif_details\" : [ { } ] } }";
+            "\"binding:vif_details\" : { } } }";
         ITNeutronE2E.test_create(url_n, content_n, "Bug 4027 Port Post Failed");
         String url_2 = base + "/ports/ea2ac142-8454-4990-8bfb-7a218479864b";
         String content_2 = " { \"port\" : {" +
@@ -58,7 +58,7 @@ public class Neutron_Bug4027_Tests {
             "\"binding:host_id\" : \"devstack-control\"," +
             "\"binding:vnic_type\" : \"normal\"," +
             "\"binding:vif_type\" : \"ovs\"," +
-            "\"binding:vif_details\" : [ { \"port_filter\" : true } ]," +
+            "\"binding:vif_details\" : { \"port_filter\" : \"true\" }," +
             "\"extra_dhcp_opts\" : [ ] } } }";
         ITNeutronE2E.test_modify(url_2, content_2, "Bug 4027 Port Modify Failed");
     }
index a840f412a87c870a5bbaf4dacbb658b3e8879f3a..e56777ccb2220185879330c5b5cd95b18ec11595 100644 (file)
@@ -36,7 +36,7 @@ public class Tempest_PortsIpV6TestJSON {
         ITNeutronE2E.test_create(url_s, content_s1, "test_create_port_in_allowed_allocation_pools Subnet Post Failed");
 
         String url_p = base + "/ports";
-        String content_p1 = "{ \"port\": {\"status\": \"ACTIVE\", \"binding:host_id\": \"odl-devstack\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"port_security_enabled\": false, \"binding:profile\": {}, \"fixed_ips\": [{\"subnet_id\": \"77c68c25-72a6-415b-a6f0-886fe26f1b02\", \"ip_address\": \"2003::5\"}], \"id\": \"7d8f5c18-fcde-471e-8a64-3dfd249cae92\", \"security_groups\": [], \"device_id\": \"dhcpff2867ff-b137-5086-a214-70bb12c3ea19-114ddf69-8ccd-46bb-92fb-bc3e921318d4\", \"name\": \"\", \"admin_state_up\": true, \"network_id\": \"114ddf69-8ccd-46bb-92fb-bc3e921318d4\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"binding:vif_details\": {\"port_filter\": true}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\", \"mac_address\": \"fa:16:3e:09:db:75\"}}";
+        String content_p1 = "{ \"port\": {\"status\": \"ACTIVE\", \"binding:host_id\": \"odl-devstack\", \"allowed_address_pairs\": [], \"extra_dhcp_opts\": [], \"device_owner\": \"network:dhcp\", \"port_security_enabled\": false, \"binding:profile\": {}, \"fixed_ips\": [{\"subnet_id\": \"77c68c25-72a6-415b-a6f0-886fe26f1b02\", \"ip_address\": \"2003::5\"}], \"id\": \"7d8f5c18-fcde-471e-8a64-3dfd249cae92\", \"security_groups\": [], \"device_id\": \"dhcpff2867ff-b137-5086-a214-70bb12c3ea19-114ddf69-8ccd-46bb-92fb-bc3e921318d4\", \"name\": \"\", \"admin_state_up\": true, \"network_id\": \"114ddf69-8ccd-46bb-92fb-bc3e921318d4\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"binding:vif_details\": {\"port_filter\": \"true\"}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"ovs\", \"mac_address\": \"fa:16:3e:09:db:75\"}}";
         ITNeutronE2E.test_create(url_p, content_p1, "test_create_port_in_allowed_allocation_pools Port Post Failed");
 
         String content_p2 = "{\"port\": {\"binding:host_id\": \"\", \"allowed_address_pairs\": [], \"device_owner\": \"\", \"port_security_enabled\": true, \"binding:profile\": {}, \"fixed_ips\": [{\"subnet_id\": \"77c68c25-72a6-415b-a6f0-886fe26f1b02\", \"ip_address\": \"2003::4\"}], \"id\": \"856c48ea-fd3a-4ee2-b0c6-bf86f8813888\", \"security_groups\": [{\"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"description\": \"Default security group\", \"id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\", \"security_group_rules\": [{\"remote_group_id\": \"\", \"direction\": \"egress\", \"remote_ip_prefix\": \"\", \"protocol\": \"\", \"ethertype\": \"IPv6\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"port_range_max\": \"\", \"port_range_min\": \"\", \"id\": \"7b506947-9f16-444e-b027-33a11aaed6bb\", \"security_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\"}, {\"remote_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\", \"direction\": \"ingress\", \"remote_ip_prefix\": \"\", \"protocol\": \"\", \"ethertype\": \"IPv6\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"port_range_max\": \"\", \"port_range_min\": \"\", \"id\": \"7ba1a85b-3e05-44b5-90dd-0c50fe01ac46\", \"security_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\"}, {\"remote_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\", \"direction\": \"ingress\", \"remote_ip_prefix\": \"\", \"protocol\": \"\", \"ethertype\": \"IPv4\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"port_range_max\": \"\", \"port_range_min\": \"\", \"id\": \"7f1ad334-7588-4ab5-ab02-d1080d401f66\", \"security_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\"}, {\"remote_group_id\": \"\", \"direction\": \"egress\", \"remote_ip_prefix\": \"\", \"protocol\": \"\", \"ethertype\": \"IPv4\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"port_range_max\": \"\", \"port_range_min\": \"\", \"id\": \"862f79a2-f96c-4b64-8fbe-50a77b38bd77\", \"security_group_id\": \"111f2d2d-4fe3-4679-b43a-17857ce91cab\"}], \"name\": \"default\"}], \"device_id\": \"\", \"name\": \"\", \"admin_state_up\": true, \"network_id\": \"114ddf69-8ccd-46bb-92fb-bc3e921318d4\", \"tenant_id\": \"4c1be4874f0048fc8205acffe2821cd3\", \"binding:vif_details\": {}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"unbound\", \"mac_address\": \"FA:16:3E:66:B1:38\"}}";
index bb7a890b7c54d79c0a0a1fda17dd8af61827431c..1721fb8364e744b0ccf1524623e9e4d1c2381b56 100644 (file)
@@ -13,7 +13,6 @@ module neutron-binding {
 
     prefix neutron-binding;
 
-    import ietf-yang-types { prefix "yang"; }
     import yang-ext { prefix "ext"; }
     import neutron { prefix "neutron"; }
 
@@ -42,11 +41,18 @@ module neutron-binding {
                         about functions that the Networking API provides. To enable or
                         disable port filtering features such as security group and anti-MAC/IP
                         spoofing, specify port-filter: True or port-filter: False ";
-            leaf port-filter {
-                type boolean;
+            // work around: "key" as leaf name in list can't be used due to java code
+            // generation. getKey() method is reserved for to retrieve key of the list
+            // and get<Name>() is also generated as a getter. it results in name
+            // collision.
+            // please see BindingGeneratorImpl#typeBuildersToGenTypes() for details.
+            // This isn't easily fixed as it's deeply hard-coded.
+            key details-key;
+            leaf details-key {
+                type string;
             }
-            leaf ovs-hybrid-plug {
-                type boolean;
+            leaf value {
+                type string;
             }
         }
         leaf vif-type {
@@ -60,7 +66,7 @@ module neutron-binding {
         }
     }
 
-    augment "/neutron:neutron/neutron:ports/neutron:port"{
+    augment "/neutron:neutron/neutron:ports/neutron:port" {
         description "This module augments the ports container in
                 the neutron-ports module with binding information.";
         ext:augment-identifier "port-binding-extension";
index b027606eb4835bd7c7a23cc20605bfcb56238903..80ef344bc9768b44eeae7b875d64cd8d0e43634f 100644 (file)
@@ -11,8 +11,11 @@ package org.opendaylight.neutron.spi;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -21,7 +24,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-
 public class NeutronPort extends NeutronObject implements Serializable, INeutronObject {
     private static final long serialVersionUID = 1L;
 
@@ -72,7 +74,8 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
 
     //@XmlElement (name = "binding:vif_details")
     @XmlElement (namespace = "binding", name = "vif_details")
-    List<NeutronPort_VIFDetail> vifDetails;
+    @XmlJavaTypeAdapter(NeutronPort_VIFAdapter.class)
+    Map<String, String> vifDetails;
 
     @XmlElement (name = "extra_dhcp_opts")
     List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
@@ -177,11 +180,11 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
         this.extraDHCPOptions = extraDHCPOptions;
     }
 
-    public List<NeutronPort_VIFDetail> getVIFDetail() {
+    public Map<String, String> getVIFDetails() {
         return vifDetails;
     }
 
-    public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
+    public void setVIFDetails(Map<String, String> vifDetails) {
         this.vifDetails = vifDetails;
     }
 
@@ -279,7 +282,7 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
                 ans.setBindingvifType(this.getBindingvifType());
             }
             if ("binding:vif_details".equals(field)) {
-                ans.setVIFDetail(new ArrayList<NeutronPort_VIFDetail>(this.getVIFDetail()));
+                ans.setVIFDetails(new HashMap<String, String>(this.getVIFDetails()));
             }
             if ("extra_dhcp_opts".equals(field)) {
                 ans.setExtraDHCPOptions(new ArrayList<NeutronPort_ExtraDHCPOption>(this.getExtraDHCPOptions()));
diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFAdapter.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFAdapter.java
new file mode 100644 (file)
index 0000000..7675376
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 Intel Corporation and others.  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.neutron.spi;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class NeutronPort_VIFAdapter extends XmlAdapter<Object, Map<String, String>> {
+    private static final Logger LOGGER = LoggerFactory
+        .getLogger(NeutronPort_VIFAdapter.class);
+
+    @Override
+    public Map<String, String> unmarshal(Object domTree) {
+        Map<String, String> map = new HashMap<>();
+        Element content = (Element) domTree;
+        NodeList childNodes = content.getChildNodes();
+        for (int i = 0; i < childNodes.getLength(); i++) {
+            Node child = childNodes.item(i);
+            String key = child.getNodeName();
+            String value = ((Text) child.getChildNodes().item(0)).getWholeText();
+            map.put(key, value);
+        }
+        return map;
+    }
+
+    @Override
+    public Object marshal(Map<String, String> map) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document doc = db.newDocument();
+            Element customXml = doc.createElement("Map");
+            if (map != null) {
+                for (Map.Entry<String, String> entry : map.entrySet()) {
+                    Element keyValuePair = doc.createElement(entry.getKey());
+                    keyValuePair.appendChild(doc.createTextNode(entry.getValue()));
+                    customXml.appendChild(keyValuePair);
+                }
+            }
+            return customXml;
+        } catch (javax.xml.parsers.ParserConfigurationException e) {
+            LOGGER.error("ParserConfigurationException", e);
+        }
+
+        return null;
+    }
+}
diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetail.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetail.java
deleted file mode 100644 (file)
index df4cead..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2015 IBM Corporation and others.  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.neutron.spi;
-
-import java.io.Serializable;
-
-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
-@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronPort_VIFDetail implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @XmlElement (name = "port_filter")
-    Boolean portFilter;
-
-    @XmlElement (name = "ovs_hybrid_plug")
-    Boolean ovsHybridPlug;
-
-    public NeutronPort_VIFDetail() {
-    }
-
-    public NeutronPort_VIFDetail(Boolean portFilter, Boolean ovsHybridPlug) {
-        this.portFilter = portFilter;
-        this.ovsHybridPlug = ovsHybridPlug;
-    }
-
-    public Boolean getPortFilter() { return(portFilter); }
-
-    public void setPortFilter(Boolean portFilter) { this.portFilter = portFilter; }
-
-    public Boolean getOvsHybridPlug() { return(ovsHybridPlug); }
-
-    public void setOvsHybridPlug(Boolean ovsHybridPlug) { this.ovsHybridPlug = ovsHybridPlug; }
-}
index 15bab8544e623235422345d88b30842e7c389c8c..157688bffe4c7a98ba46ebe4e80357e2c230c82f 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.neutron.spi;
 
 import java.util.List;
+import java.util.Map;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -24,7 +25,7 @@ public class NeutronPortJAXBTest {
             + "\"admin_state_up\": true, "
             + "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "
             + "\"fixed_ips\": [ { \"ip_address\":\"192.168.111.3\" , \"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" } ],"
-            + "\"binding:vif_details\": [{\"port_filter\": true , \"ovs_hybrid_plug\": true } ], "
+            + "\"binding:vif_details\": {\"port_filter\": \"true\" , \"ovs_hybrid_plug\": \"false\" }, "
             + "\"extra_dhcp_opts\": [\"\"], " + "\"security_groups\": [\"\"], " + "\"allowed_address_pairs\": [\"\"], "
             + "\"device_id\": \"257614cc-e178-4c92-9c61-3b28d40eca44\", " + "\"device_owner\": \"\", "
             + "\"binding:host_id\": \"\", " + "\"binding:vif_type\": \"unbound\", "
@@ -70,16 +71,16 @@ public class NeutronPortJAXBTest {
             Assert.assertEquals("NeutronPort JAXB Test 8: Testing allowed_address_pairs list length failed", 1,
                     allowedAddressPairs.size());
 
-            List<NeutronPort_VIFDetail> vifDetails = neutronObject.getVIFDetail();
+            Map<String, String> vifDetails = neutronObject.getVIFDetails();
 
-            Assert.assertEquals("NeutronPort JAXB Test 9.1: Testing vif_details list length failed", 1,
+            Assert.assertEquals("NeutronPort JAXB Test 9.1: Testing vif_details list length failed", 2,
                     vifDetails.size());
 
-            Assert.assertEquals("NeutronPort JAXB Test 9.2: Testing port_filter value failed", true,
-                    vifDetails.get(0).portFilter);
+            Assert.assertEquals("NeutronPort JAXB Test 9.2: Testing port_filter value failed", "true",
+                    vifDetails.get("port_filter"));
 
-            Assert.assertEquals("NeutronNetwork JAXB Test 9.3: Testing ovs_hybrid_plug value failed", true,
-                    vifDetails.get(0).ovsHybridPlug);
+            Assert.assertEquals("NeutronPort JAXB Test 9.3: Testing ovs_hybrid_plug value failed", "false",
+                    vifDetails.get("ovs_hybrid_plug"));
 
             Assert.assertEquals("NeutronPort JAXB Test 10: Testing name failed", "net1", neutronObject.getName());
 
index f345d8becec97da0d31943de5ffe25e43a7ad5bc..ca5c77236589b74cdca2117525291cb3aaa5651f 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.List;
+import java.util.Map;
 
 public class NeutronPortSecurityJAXBTest {
 
@@ -22,7 +23,7 @@ public class NeutronPortSecurityJAXBTest {
             + "\"admin_state_up\": true, "
             + "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "
             + "\"fixed_ips\": [ { \"ip_address\":\"192.168.111.3\" , \"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" } ],"
-            + "\"binding:vif_details\": [{\"port_filter\": true , \"ovs_hybrid_plug\": true } ], "
+            + "\"binding:vif_details\": {\"port_filter\": \"true\" , \"ovs_hybrid_plug\": \"false\" }, "
             + "\"extra_dhcp_opts\": [\"\"], " + "\"security_groups\": [\"\"], " + "\"allowed_address_pairs\": [\"\"], "
             + "\"device_id\": \"257614cc-e178-4c92-9c61-3b28d40eca44\", " + "\"device_owner\": \"\", "
             + "\"binding:host_id\": \"\", " + "\"binding:vif_type\": \"unbound\", "
@@ -39,7 +40,7 @@ public class NeutronPortSecurityJAXBTest {
             + "\"admin_state_up\": true, "
             + "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "
             + "\"fixed_ips\": [ { \"ip_address\":\"192.168.111.3\" , \"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" } ],"
-            + "\"binding:vif_details\": [{\"port_filter\": true , \"ovs_hybrid_plug\": true } ], "
+            + "\"binding:vif_details\": {\"port_filter\": \"true\" , \"ovs_hybrid_plug\": \"false\" }, "
             + "\"extra_dhcp_opts\": [\"\"], " + "\"security_groups\": [\"\"], " + "\"allowed_address_pairs\": [\"\"], "
             + "\"device_id\": \"257614cc-e178-4c92-9c61-3b28d40eca44\", " + "\"device_owner\": \"\", "
             + "\"binding:host_id\": \"\", " + "\"binding:vif_type\": \"unbound\", "
@@ -55,7 +56,7 @@ public class NeutronPortSecurityJAXBTest {
             + "\"admin_state_up\": true, "
             + "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "
             + "\"fixed_ips\": [ { \"ip_address\":\"192.168.111.3\" , \"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" } ],"
-            + "\"binding:vif_details\": [{\"port_filter\": true , \"ovs_hybrid_plug\": true } ], "
+            + "\"binding:vif_details\": {\"port_filter\": \"true\" , \"ovs_hybrid_plug\": \"false\" }, "
             + "\"extra_dhcp_opts\": [\"\"], " + "\"security_groups\": [\"\"], " + "\"allowed_address_pairs\": [\"\"], "
             + "\"device_id\": \"257614cc-e178-4c92-9c61-3b28d40eca44\", " + "\"device_owner\": \"\", "
             + "\"binding:host_id\": \"\", " + "\"binding:vif_type\": \"unbound\", "
@@ -119,16 +120,16 @@ public class NeutronPortSecurityJAXBTest {
             Assert.assertEquals("NeutronPort JAXB Test 8: Testing allowed_address_pairs list length failed", 1,
                     allowedAddressPairs.size());
 
-            List<NeutronPort_VIFDetail> vifDetails = neutronObject.getVIFDetail();
+            Map<String, String> vifDetails = neutronObject.getVIFDetails();
 
-            Assert.assertEquals("NeutronPort JAXB Test 9.1: Testing vif_details list length failed", 1,
+            Assert.assertEquals("NeutronPort JAXB Test 9.1: Testing vif_details list length failed", 2,
                     vifDetails.size());
 
-            Assert.assertEquals("NeutronPort JAXB Test 9.2: Testing port_filter value failed", true,
-                    vifDetails.get(0).portFilter);
+            Assert.assertEquals("NeutronPort JAXB Test 9.2: Testing port_filter value failed", "true",
+                    vifDetails.get("port_filter"));
 
-            Assert.assertEquals("NeutronNetwork JAXB Test 9.3: Testing ovs_hybrid_plug value failed", true,
-                    vifDetails.get(0).ovsHybridPlug);
+            Assert.assertEquals("NeutronPort JAXB Test 9.3: Testing ovs_hybrid_plug value failed", "false",
+                    vifDetails.get("ovs_hybrid_plug"));
 
             Assert.assertEquals("NeutronPort JAXB Test 10: Testing name failed", "net1", neutronObject.getName());
 
diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetailJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronPort_VIFDetailJAXBTest.java
deleted file mode 100644 (file)
index 8bd3559..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright Tata Consultancy Services, 2015.  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.neutron.spi;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.neutron.spi.JaxbTestHelper;
-import org.opendaylight.neutron.spi.NeutronPort_VIFDetail;
-
-public class NeutronPort_VIFDetailJAXBTest {
-
-    private static final String NeutronPort_VIFDetail_sourceJson = "{" + "\"port_filter\": true, "
-            + "\"ovs_hybrid_plug\": true }";
-
-    @Test
-    public void test_NeutronPort_VIFDetail_JAXB() {
-        NeutronPort_VIFDetail portObject = new NeutronPort_VIFDetail();
-        try {
-            NeutronPort_VIFDetail testObject = (NeutronPort_VIFDetail) JaxbTestHelper.jaxbUnmarshall(portObject,
-                    NeutronPort_VIFDetail_sourceJson);
-
-            Assert.assertEquals("NeutronPort_VIFDetail JAXB Test 1: Testing port_filter failed", true,
-                    testObject.getPortFilter());
-
-            Assert.assertEquals("NeutronPort_VIFDetail JAXB Test 10: Testing ovs_hybrid_plug failed", true,
-                    testObject.getOvsHybridPlug());
-
-        } catch (Exception e) {
-            Assert.assertFalse("Tests Failed", true);
-        }
-    }
-
-}
index 09e9e80e4352da812c730f916a74b0fde160ab6e..7aad6e2dcf311374435e995bd7d3a1d5b1ed1d1e 100644 (file)
@@ -10,7 +10,9 @@ package org.opendaylight.neutron.transcriber;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
@@ -20,7 +22,6 @@ import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
 import org.opendaylight.neutron.spi.NeutronPort;
 import org.opendaylight.neutron.spi.NeutronPort_AllowedAddressPairs;
 import org.opendaylight.neutron.spi.NeutronPort_ExtraDHCPOption;
-import org.opendaylight.neutron.spi.NeutronPort_VIFDetail;
 import org.opendaylight.neutron.spi.NeutronSecurityGroup;
 import org.opendaylight.neutron.spi.Neutron_IPs;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
@@ -122,14 +123,11 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
         final PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
         result.setBindinghostID(binding.getHostId());
         if (binding.getVifDetails() != null) {
-            final List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+            final Map<String, String> details = new HashMap<String, String>(binding.getVifDetails().size());
             for (final VifDetails vifDetail : binding.getVifDetails()) {
-                final NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
-                detail.setPortFilter(vifDetail.isPortFilter());
-                detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
-                details.add(detail);
+                details.put(vifDetail.getDetailsKey(), vifDetail.getValue());
             }
-            result.setVIFDetail(details);
+            result.setVIFDetails(details);
         }
         result.setBindingvifType(binding.getVifType());
         result.setBindingvnicType(binding.getVnicType());
@@ -208,15 +206,16 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
         if (neutronPort.getBindinghostID() != null) {
             bindingBuilder.setHostId(neutronPort.getBindinghostID());
         }
-        if (neutronPort.getVIFDetail() != null) {
-            final List<VifDetails> listVifDetail = new ArrayList<VifDetails>();
-            for (final NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
+        if (neutronPort.getVIFDetails() != null) {
+            final Map<String, String> vifDetails = neutronPort.getVIFDetails();
+            final List<VifDetails> listVifDetail = new ArrayList<VifDetails>(vifDetails.size());
+            for (final Map.Entry<String, String> vifDetail : vifDetails.entrySet()) {
                 final VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
-                if (detail.getPortFilter() != null) {
-                    vifDetailsBuilder.setPortFilter(detail.getPortFilter());
+                if (vifDetail.getKey() != null) {
+                    vifDetailsBuilder.setDetailsKey(vifDetail.getKey());
                 }
-                if (detail.getOvsHybridPlug() != null) {
-                    vifDetailsBuilder.setOvsHybridPlug(detail.getOvsHybridPlug());
+                if (vifDetail.getValue() != null) {
+                    vifDetailsBuilder.setValue(vifDetail.getValue());
                 }
                 listVifDetail.add(vifDetailsBuilder.build());
             }
@@ -253,7 +252,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             portBuilder.setDeviceId(neutronPort.getDeviceID());
         }
         if (neutronPort.getDeviceOwner() != null) {
-        portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());
+            portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());
         }
         if (neutronPort.getExtraDHCPOptions() != null) {
             final List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<ExtraDhcpOpts>();
@@ -285,10 +284,10 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             portBuilder.setMacAddress(new MacAddress(neutronPort.getMacAddress()));
         }
         if (neutronPort.getName() != null) {
-        portBuilder.setName(neutronPort.getName());
+            portBuilder.setName(neutronPort.getName());
         }
         if (neutronPort.getNetworkUUID() != null) {
-        portBuilder.setNetworkId(toUuid(neutronPort.getNetworkUUID()));
+            portBuilder.setNetworkId(toUuid(neutronPort.getNetworkUUID()));
         }
         if (neutronPort.getSecurityGroups() != null) {
             final List<Uuid> listSecurityGroups = new ArrayList<Uuid>();