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>
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";
"\"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\" : {" +
"\"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");
}
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\"}}";
prefix neutron-binding;
- import ietf-yang-types { prefix "yang"; }
import yang-ext { prefix "ext"; }
import neutron { prefix "neutron"; }
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 {
}
}
- 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";
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;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-
public class NeutronPort extends NeutronObject implements Serializable, INeutronObject {
private static final long serialVersionUID = 1L;
//@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;
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;
}
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()));
--- /dev/null
+/*
+ * 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;
+ }
+}
+++ /dev/null
-/*
- * 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; }
-}
package org.opendaylight.neutron.spi;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
+ "\"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\", "
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());
import org.junit.Test;
import java.util.List;
+import java.util.Map;
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\", "
+ "\"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\", "
+ "\"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\", "
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());
+++ /dev/null
-/*
- * 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);
- }
- }
-
-}
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;
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;
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());
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());
}
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>();
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>();