From: manjunathpayala Date: Wed, 26 Feb 2020 13:22:02 +0000 (+0530) Subject: NEUTRON-208: BGPVPN network and router association X-Git-Tag: release/silicon~20 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=neutron.git;a=commitdiff_plain;h=f272a964775f9287809243f79d47f14e2d231bcf NEUTRON-208: BGPVPN network and router association + Currently, BGPVPN network and router associations are handled by BGPVPN update request. + Neutron model is changed to support bgpvpn network and router association as CREATE/DELETE calls instead of BGPVPN update. + The existing attributes are also retained to have back-ward compatibility. Change-Id: I6de1be538ef1d1e34d8d0e7f20786b6fae7b99b0 Signed-off-by: manjunathpayala Signed-off-by: Somashekar Byrappa --- diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronAllTests.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronAllTests.java index 451938d0b..1bbcec612 100644 --- a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronAllTests.java +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronAllTests.java @@ -38,6 +38,8 @@ public final class NeutronAllTests { NeutronIpSecSiteConnectionTests.runTests(baseURL); NeutronIKEPoliciesTests.runTests(baseURL); NeutronBgpvpnTests.runTests(baseURL); + NeutronBgpvpnNetworkAssociationTests.runTests(baseURL); + NeutronBgpvpnRouterAssociationTests.runTests(baseURL); NeutronL2GatewayTests.runTests(baseURL); NeutronL2GatewayConnectionTests.runTests(baseURL); NeutronQosPolicyTests.runTests(baseURL); diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnNetworkAssociationTests.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnNetworkAssociationTests.java new file mode 100644 index 000000000..1d9e5b7c5 --- /dev/null +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnNetworkAssociationTests.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.e2etest; + +public class NeutronBgpvpnNetworkAssociationTests { + String base; + + public NeutronBgpvpnNetworkAssociationTests(String base) { + this.base = base; + } + + public void bgpvpn_netasso_collection_get_test() { + String url = base + "/bgpvpn/networkassociations"; + HttpUtils.test_fetch(url, "BGPVPN network association collection GET failed"); + } + + public String singleton_bgpvpn_netasso_create_test() { + String url = base + "/bgpvpn/networkassociations"; + String content = "{ \"bgpvpn_network_association\" : { \"id\": \"7326ef73-378d-4981-bfa2-51cb80de78e0\"," + + " \"bgpvpn-id\": \"b472f6eb-3ff1-4c4b-8f1b-e1032e10c372\", " + + "\"network-id\": \"3ad0e6c3-80da-421e-8733-254e62adad16\" } }"; + HttpUtils.test_create(url, content, "Singleton Bgpvpn network association Post Failed NB"); + return content; + } + + public void singleton_bgpvpn_netasso_get_with_one_query_item_test(String createJsonString) { + String url = base + "/bgpvpn/networkassociations"; + HttpUtils.test_fetch_with_one_query_item(url, createJsonString, "bgpvpn_network_associations"); + } + + public void bgpvpn_netasso_element_get_test() { + String url = base + "/bgpvpn/networkassociations/7326ef73-378d-4981-bfa2-51cb80de78e0"; + HttpUtils.test_fetch(url, true, "Bgpvpn network association Element Get Failed"); + } + + public void bgpvpn_netasso_element_get_test_with_added_query() { + String url = base + "/bgpvpn/networkassociations/7326ef73-378d-4981-bfa2-51cb80de78e0" + + "?fields=id&fields=bgpvpn-id&fields=network-id"; + HttpUtils.test_fetch(url, true, "Bgpvpn network association Element Get Failed"); + } + + public void bgpvpn_netasso_element_negative_get_test() { + String url = base + "/bgpvpn/networkassociations/7326ef73-378d-4981-bfa2-51cb80de78e0"; + HttpUtils.test_fetch(url, false, "Bgpvpn network association Element Negative Get Failed"); + } + + public void bgpvpn_netasso_delete_test() { + String url = base + "/bgpvpn/networkassociations/7326ef73-378d-4981-bfa2-51cb80de78e0"; + HttpUtils.test_delete(url, "Bgpvpn network association Element Delete Failed"); + } + + public static void runTests(String base) { + NeutronBgpvpnNetworkAssociationTests bgpvpnNetAssoTester = new NeutronBgpvpnNetworkAssociationTests(base); + bgpvpnNetAssoTester.bgpvpn_netasso_collection_get_test(); + String createJsonString = bgpvpnNetAssoTester.singleton_bgpvpn_netasso_create_test(); + bgpvpnNetAssoTester.singleton_bgpvpn_netasso_get_with_one_query_item_test(createJsonString); + bgpvpnNetAssoTester.bgpvpn_netasso_element_get_test(); + bgpvpnNetAssoTester.bgpvpn_netasso_element_get_test_with_added_query(); + bgpvpnNetAssoTester.bgpvpn_netasso_delete_test(); + bgpvpnNetAssoTester.bgpvpn_netasso_element_negative_get_test(); + } +} diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnRouterAssociationTests.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnRouterAssociationTests.java new file mode 100644 index 000000000..0e93d4626 --- /dev/null +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnRouterAssociationTests.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.e2etest; + +public class NeutronBgpvpnRouterAssociationTests { + String base; + + public NeutronBgpvpnRouterAssociationTests(String base) { + this.base = base; + } + + public void bgpvpn_routerasso_collection_get_test() { + String url = base + "/bgpvpn/routerassociations"; + HttpUtils.test_fetch(url, "BGPVPN router association collection GET failed"); + } + + public String singleton_bgpvpn_routerasso_create_test() { + String url = base + "/bgpvpn/routerassociations"; + String content = "{ \"bgpvpn_router_association\" : { \"id\": \"8d819a7e-2f1b-4bb5-bbce-af476b237bc1\"," + + " \"bgpvpn-id\": \"b472f6eb-3ff1-4c4b-8f1b-e1032e10c372\"," + + " \"router-id\": \"3bbe9f3a-9c54-429f-8489-0611dbc99901\" } }"; + HttpUtils.test_create(url, content, "Singleton Bgpvpn router association Post Failed NB"); + return content; + } + + public void singleton_bgpvpn_routerasso_get_with_one_query_item_test(String createJsonString) { + String url = base + "/bgpvpn/routerassociations"; + HttpUtils.test_fetch_with_one_query_item(url, createJsonString, "bgpvpn_router_associations"); + } + + public void bgpvpn_routerasso_element_get_test() { + String url = base + "/bgpvpn/routerassociations/8d819a7e-2f1b-4bb5-bbce-af476b237bc1"; + HttpUtils.test_fetch(url, true, "Bgpvpn router association Element Get Failed"); + } + + public void bgpvpn_routerasso_element_get_test_with_added_query() { + String url = base + "/bgpvpn/routerassociations/8d819a7e-2f1b-4bb5-bbce-af476b237bc1" + + "?fields=id&fields=bgpvpn-id&fields=router-id"; + HttpUtils.test_fetch(url, true, "Bgpvpn router association Element Get Failed"); + } + + public void bgpvpn_routerasso_element_negative_get_test() { + String url = base + "/bgpvpn/routerassociations/8d819a7e-2f1b-4bb5-bbce-af476b237bc1"; + HttpUtils.test_fetch(url, false, "Bgpvpn router association Element Negative Get Failed"); + } + + public void bgpvpn_routerasso_delete_test() { + String url = base + "/bgpvpn/routerassociations/8d819a7e-2f1b-4bb5-bbce-af476b237bc1"; + HttpUtils.test_delete(url, "Bgpvpn router association Element Delete Failed"); + } + + public static void runTests(String base) { + NeutronBgpvpnRouterAssociationTests bgpvpnRouterAssoTester = new NeutronBgpvpnRouterAssociationTests(base); + bgpvpnRouterAssoTester.bgpvpn_routerasso_collection_get_test(); + String createJsonString = bgpvpnRouterAssoTester.singleton_bgpvpn_routerasso_create_test(); + bgpvpnRouterAssoTester.singleton_bgpvpn_routerasso_get_with_one_query_item_test(createJsonString); + bgpvpnRouterAssoTester.bgpvpn_routerasso_element_get_test(); + bgpvpnRouterAssoTester.bgpvpn_routerasso_element_get_test_with_added_query(); + bgpvpnRouterAssoTester.bgpvpn_routerasso_delete_test(); + bgpvpnRouterAssoTester.bgpvpn_routerasso_element_negative_get_test(); + } + +} diff --git a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnTests.java b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnTests.java index e31cf28f9..de2e3a728 100644 --- a/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnTests.java +++ b/integration/test-standalone/src/main/java/org/opendaylight/neutron/e2etest/NeutronBgpvpnTests.java @@ -26,7 +26,6 @@ public class NeutronBgpvpnTests { String content = "{ \"bgpvpn\": {" + " \"status\": \"ACTIVE\", \"type\": \"l3\", " + " \"name\": \"vpn1\", \"admin_state_up\": true, " + " \"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", " + " \"route_targets\": \"64512:1\", " - + " \"networks\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\", " + " \"vni\": 100, " + " \"auto_aggregate\": true, \"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" " + " } }"; HttpUtils.test_create(url, content, "Singleton Bgpvpn Post Failed NB"); diff --git a/integration/test-standalone/src/test/java/org/opendaylight/neutron/e2etest/NeutronTestWiring.java b/integration/test-standalone/src/test/java/org/opendaylight/neutron/e2etest/NeutronTestWiring.java index 64d259855..0eaa082b6 100644 --- a/integration/test-standalone/src/test/java/org/opendaylight/neutron/e2etest/NeutronTestWiring.java +++ b/integration/test-standalone/src/test/java/org/opendaylight/neutron/e2etest/NeutronTestWiring.java @@ -17,6 +17,8 @@ import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.neutron.northbound.api.WebInitializer; import org.opendaylight.neutron.spi.INeutronBgpvpnCRUD; +import org.opendaylight.neutron.spi.INeutronBgpvpnNetworkAssociationCRUD; +import org.opendaylight.neutron.spi.INeutronBgpvpnRouterAssociationCRUD; import org.opendaylight.neutron.spi.INeutronFirewallCRUD; import org.opendaylight.neutron.spi.INeutronFirewallPolicyCRUD; import org.opendaylight.neutron.spi.INeutronFirewallRuleCRUD; @@ -48,6 +50,8 @@ import org.opendaylight.neutron.spi.INeutronVpnIpSecPolicyCRUD; import org.opendaylight.neutron.spi.INeutronVpnIpSecSiteConnectionsCRUD; import org.opendaylight.neutron.spi.INeutronVpnServiceCRUD; import org.opendaylight.neutron.transcriber.NeutronBgpvpnInterface; +import org.opendaylight.neutron.transcriber.NeutronBgpvpnNetworkAssociationInterface; +import org.opendaylight.neutron.transcriber.NeutronBgpvpnRouterAssociationInterface; import org.opendaylight.neutron.transcriber.NeutronFirewallInterface; import org.opendaylight.neutron.transcriber.NeutronFirewallPolicyInterface; import org.opendaylight.neutron.transcriber.NeutronFirewallRuleInterface; @@ -79,6 +83,7 @@ import org.opendaylight.neutron.transcriber.NeutronVpnIpSecPolicyInterface; import org.opendaylight.neutron.transcriber.NeutronVpnIpSecSiteConnectionsInterface; import org.opendaylight.neutron.transcriber.NeutronVpnServiceInterface; + /** * Dependency Injection wiring for Neutron. * @@ -121,6 +126,8 @@ public class NeutronTestWiring extends AbstractModule { bind(INeutronLoadBalancerListenerCRUD.class).to(NeutronLoadBalancerListenerInterface.class); bind(INeutronLoadBalancerPoolCRUD.class).to(NeutronLoadBalancerPoolInterface.class); bind(INeutronBgpvpnCRUD.class).to(NeutronBgpvpnInterface.class); + bind(INeutronBgpvpnRouterAssociationCRUD.class).to(NeutronBgpvpnRouterAssociationInterface.class); + bind(INeutronBgpvpnNetworkAssociationCRUD.class).to(NeutronBgpvpnNetworkAssociationInterface.class); bind(INeutronL2gatewayCRUD.class).to(NeutronL2gatewayInterface.class); bind(INeutronL2gatewayConnectionCRUD.class).to(NeutronL2gatewayConnectionInterface.class); bind(INeutronLoadBalancerHealthMonitorCRUD.class).to(NeutronLoadBalancerHealthMonitorInterface.class); diff --git a/model/src/main/yang/neutron-bgpvpn-network-associations.yang b/model/src/main/yang/neutron-bgpvpn-network-associations.yang new file mode 100644 index 000000000..cdbeaf5b8 --- /dev/null +++ b/model/src/main/yang/neutron-bgpvpn-network-associations.yang @@ -0,0 +1,50 @@ +/* + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +module neutron-bgpvpn-network-association { + + yang-version 1; + + namespace "urn:opendaylight:neutron-bgpvpn-network-association"; + + prefix neutron-bgpvpn-network-association; + + import ietf-yang-types { prefix "yang"; } + import neutron-attrs { prefix "attrs"; } + + organization "OpenDaylight Neutron Group"; + + contact "Manjunath N P "; + + description "This YANG module defines Openstack Liberty Neutron BGPVPN Network Association model"; + + revision "2019-05-02" { + description + "Initial version of Openstack Neutron Liberty BGPVPN Network Association model."; + } + + grouping bgpvpn-network-association-attributes { + leaf bgpvpn-id { + type yang:uuid; + } + leaf network-id { + type yang:uuid; + description "Network associated to this VPN."; + } + } + + grouping bgpvpn-network-associations-attributes { + container bgpvpn-network-associations { + list bgpvpn-network-association { + key "uuid"; + uses attrs:base-attributes; + uses attrs:admin-attributes; + uses bgpvpn-network-association-attributes; + } + } + } +} diff --git a/model/src/main/yang/neutron-bgpvpn-router-associations.yang b/model/src/main/yang/neutron-bgpvpn-router-associations.yang new file mode 100644 index 000000000..50b0b480e --- /dev/null +++ b/model/src/main/yang/neutron-bgpvpn-router-associations.yang @@ -0,0 +1,50 @@ +/* + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +module neutron-bgpvpn-router-association { + + yang-version 1; + + namespace "urn:opendaylight:neutron-bgpvpn-router-association"; + + prefix neutron-bgpvpn-router-association; + + import ietf-yang-types { prefix "yang"; } + import neutron-attrs { prefix "attrs"; } + + organization "OpenDaylight Neutron Group"; + + contact "Manjunath N P "; + + description "This YANG module defines Openstack Liberty Neutron BGPVPN Router Association model"; + + revision "2019-05-02" { + description + "Initial version of Openstack Neutron Liberty BGPVPN Router Association model."; + } + + grouping bgpvpn-router-association-attributes { + leaf bgpvpn-id { + type yang:uuid; + } + leaf router-id { + type yang:uuid; + description "Router associated to this VPN."; + } + } + + grouping bgpvpn-router-associations-attributes { + container bgpvpn-router-associations { + list bgpvpn-router-association { + key "uuid"; + uses attrs:base-attributes; + uses attrs:admin-attributes; + uses bgpvpn-router-association-attributes; + } + } + } +} diff --git a/model/src/main/yang/neutron.yang b/model/src/main/yang/neutron.yang index 0e9fa50e8..187f2295d 100644 --- a/model/src/main/yang/neutron.yang +++ b/model/src/main/yang/neutron.yang @@ -26,6 +26,8 @@ module neutron { import neutron-vpnaas { prefix "vpnaas"; } import neutron-fwaas { prefix "fwaas"; } import neutron-bgpvpns { prefix "bgpvpns"; } + import neutron-bgpvpn-network-association { prefix "bgpvpn-network-associations"; } + import neutron-bgpvpn-router-association { prefix "bgpvpn-router-associations"; } import neutron-hostconfig { prefix "hostconfig"; } import neutron-qos { prefix "qos"; } import neutron-sfc-flow-classifier { prefix "sfc-flow-classifier"; } @@ -65,6 +67,8 @@ module neutron { uses vpnaas:ipsecpolicies-attributes; uses vpnaas:ipsecconnections-attributes; uses bgpvpns:bgpvpns-attributes; + uses bgpvpn-network-associations:bgpvpn-network-associations-attributes; + uses bgpvpn-router-associations:bgpvpn-router-associations-attributes; uses l2gateways:l2gateways-attributes; uses l2gateways:l2gateway-connections-attributes; uses hostconfig:hostconfig-attributes; diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnNetworkAssociationCRUD.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnNetworkAssociationCRUD.java new file mode 100644 index 000000000..49ad40807 --- /dev/null +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnNetworkAssociationCRUD.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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; + +public interface INeutronBgpvpnNetworkAssociationCRUD extends INeutronCRUD { + // Nothing Here. + // This class is defined to use reflection like INeutronBgpvpnNetworkAssociationCRUD.class +} diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnRouterAssociationCRUD.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnRouterAssociationCRUD.java new file mode 100644 index 000000000..4c38a6057 --- /dev/null +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronBgpvpnRouterAssociationCRUD.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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; + +public interface INeutronBgpvpnRouterAssociationCRUD extends INeutronCRUD { + // Nothing Here. + // This class is defined to use reflection like INeutronBgpvpnRouterAssociationCRUD.class +} diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnNetworkAssociation.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnNetworkAssociation.java new file mode 100644 index 000000000..3cf9e81d9 --- /dev/null +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnNetworkAssociation.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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(name = "bgpvpn_network_association") +@XmlAccessorType(XmlAccessType.NONE) +public final class NeutronBgpvpnNetworkAssociation extends NeutronAdminAttributes + implements Serializable { + + private static final long serialVersionUID = 1L; + + @XmlElement(name = "bgpvpn_id") + String bgpvpnId; + + @XmlElement(name = "network_id") + String networkIds; + + @Override + public void initDefaults() { + } + + public String getBgpvpnId() { + return bgpvpnId; + } + + public void setBgpvpnId(String bgpvpnId) { + this.bgpvpnId = bgpvpnId; + } + + public String getNetworkIds() { + return networkIds; + } + + public void setNetworkIds(String networkIds) { + this.networkIds = networkIds; + } + + @Override + protected boolean extractField(String field, NeutronBgpvpnNetworkAssociation ans) { + switch (field) { + case "bgpvpn_id": + ans.setBgpvpnId(this.getBgpvpnId()); + break; + case "network_id": + ans.setNetworkIds(this.getNetworkIds()); + break; + default: + return super.extractField(field, ans); + } + return true; + } + + @Override + public String toString() { + return "NeutronBgpvpnNetworkAssociation [bgpvpnNetworkAssociationUUID=" + uuid + ", bgpvpnId=" + bgpvpnId + + ", networkId=" + networkIds + "]"; + } +} + diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnRouterAssociation.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnRouterAssociation.java new file mode 100644 index 000000000..19e2071cc --- /dev/null +++ b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronBgpvpnRouterAssociation.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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(name = "bgpvpn_router_association") +@XmlAccessorType(XmlAccessType.NONE) +public final class NeutronBgpvpnRouterAssociation extends NeutronAdminAttributes + implements Serializable { + + private static final long serialVersionUID = 1L; + + @XmlElement(name = "bgpvpn_id") + String bgpvpnId; + + @XmlElement(name = "router_id") + String routerId; + + @Override + public void initDefaults() { + } + + public String getBgpvpnId() { + return bgpvpnId; + } + + public void setBgpvpnId(String bgpvpnId) { + this.bgpvpnId = bgpvpnId; + } + + public String getRouterId() { + return routerId; + } + + public void setRouterId(String routerId) { + this.routerId = routerId; + } + + @Override + protected boolean extractField(String field, NeutronBgpvpnRouterAssociation ans) { + switch (field) { + case "bgpvpn_id": + ans.setBgpvpnId(this.getBgpvpnId()); + break; + case "router_id": + ans.setRouterId(this.getRouterId()); + break; + default: + return super.extractField(field, ans); + } + return true; + } + + @Override + public String toString() { + return "NeutronBgpvpnRouterAssociation [bgpvpnRouterAssociationUUID=" + uuid + ", bgpvpnId=" + bgpvpnId + + ", routerId=" + routerId + "]"; + } +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationRequest.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationRequest.java new file mode 100644 index 000000000..1968f0b4f --- /dev/null +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.northbound.api; + +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import org.opendaylight.neutron.spi.NeutronBgpvpnNetworkAssociation; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class NeutronBgpvpnNetworkAssociationRequest implements INeutronRequest { + + @XmlElement(name = "bgpvpn_network_association") + NeutronBgpvpnNetworkAssociation singleton; + + @XmlElement(name = "bgpvpn_network_associations") + List bulkRequest; + + NeutronBgpvpnNetworkAssociationRequest() { + } + + @edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD") + NeutronBgpvpnNetworkAssociationRequest(NeutronBgpvpnNetworkAssociation bgpvpnNetworkAssociation) { + this.singleton = bgpvpnNetworkAssociation; + } + + @edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD") + NeutronBgpvpnNetworkAssociationRequest(List bulk) { + this.bulkRequest = bulk; + } +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationsNorthbound.java new file mode 100644 index 000000000..36d4da023 --- /dev/null +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnNetworkAssociationsNorthbound.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.northbound.api; + +import com.webcohesion.enunciate.metadata.rs.ResponseCode; +import com.webcohesion.enunciate.metadata.rs.StatusCodes; +import com.webcohesion.enunciate.metadata.rs.TypeHint; +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import org.apache.aries.blueprint.annotation.service.Reference; +import org.opendaylight.neutron.spi.INeutronBgpvpnNetworkAssociationCRUD; +import org.opendaylight.neutron.spi.NeutronBgpvpnNetworkAssociation; + +/** + * Neutron Northbound REST APIs for BgpvpnNetworkAssociation.
+ * This class provides REST APIs for managing neutron BgpvpnNetworkAssociations + * + *
+ *
+ * Authentication scheme : HTTP Basic
+ * Authentication realm : opendaylight
+ * Transport : HTTP and HTTPS
+ *
+ * HTTPS Authentication is disabled by default. Administrator can enable it in + * tomcat-server.xml after adding a proper keystore / SSL certificate from a + * trusted authority.
+ * More info : + * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * + */ +@Singleton +@Path("/bgpvpn/networkassociations") +public final class NeutronBgpvpnNetworkAssociationsNorthbound + extends AbstractNeutronNorthbound { + + @Context + UriInfo uriInfo; + + private static final String RESOURCE_NAME = "Bgpvpn Network Associations"; + + @Inject + public NeutronBgpvpnNetworkAssociationsNorthbound(@Reference INeutronBgpvpnNetworkAssociationCRUD neutronCRUD) { + super(neutronCRUD); + } + + @Override + protected String getResourceName() { + return RESOURCE_NAME; + } + + /** + * Returns a list of all BgpvpnNetworkAssociations. + */ + + @GET + @Produces({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response listBgpvpnNetworkAssociations( + // return fields + @QueryParam("fields") List fields, + @QueryParam("id") String queryID, + @QueryParam("bgpvpn_id") String queryBgpvpnId, + @QueryParam("network_id") String queryNetworkId, + // pagination + @QueryParam("limit") Integer limit, + @QueryParam("marker") String marker, + @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse + ) { + INeutronBgpvpnNetworkAssociationCRUD neutronBgpvpnNetworkAssociation = getNeutronCRUD(); + List allBgpvpnNetAssos = neutronBgpvpnNetworkAssociation.getAll(); + List ans = new ArrayList<>(); + for (NeutronBgpvpnNetworkAssociation bgpvpnNetAsso : allBgpvpnNetAssos) { + //match filters: + if ((queryID == null || queryID.equals(bgpvpnNetAsso.getID())) + && (queryBgpvpnId == null || queryBgpvpnId.equals(bgpvpnNetAsso.getBgpvpnId())) + && (queryNetworkId == null || queryNetworkId.equals(bgpvpnNetAsso.getNetworkIds()))) { + if (fields.size() > 0) { + ans.add(bgpvpnNetAsso.extractFields(fields)); + } else { + ans.add(bgpvpnNetAsso); + } + } + } + + if (limit != null && ans.size() > 1) { + // Return a paginated request + NeutronBgpvpnNetworkAssociationRequest request = (NeutronBgpvpnNetworkAssociationRequest) + PaginatedRequestFactory.createRequest(limit, marker, pageReverse, uriInfo, ans, + NeutronBgpvpnNetworkAssociation.class); + return Response.status(HttpURLConnection.HTTP_OK).entity(request).build(); + } + return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronBgpvpnNetworkAssociationRequest(ans)) + .build(); + } + + /** + * Returns a specific BgpvpnNetworkAssociation. + */ + + @Path("{networkassociationUUID}") + @GET + @Produces({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response showBgpvpnNetworkAssociation( + @PathParam("networkassociationUUID") String bgpvpnNetworkAssociationUUID, + // return fields + @QueryParam("fields") List fields) { + return show(bgpvpnNetworkAssociationUUID, fields); + } + + /** + * Creates new BgpvpnNetworkAssociations. + */ + @POST + @Produces({ MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_JSON }) + @TypeHint(NeutronBgpvpnNetworkAssociation.class) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response createBgpvpnNetworkAssociations(final NeutronBgpvpnNetworkAssociationRequest input) { + return create(input); + } + + /** + * Updates a BgpvpnNetworkAssociation. + */ + + @Path("{networkassociationUUID}") + @PUT + @Produces({ MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response updateBgpvpnNetworkAssociation(@PathParam("networkassociationUUID") + String bgpvpnNetworkAssociationUUID, + final NeutronBgpvpnNetworkAssociationRequest input) { + return update(bgpvpnNetworkAssociationUUID, input); + } + + /** + * Deletes a Bgpvpn. + */ + + @Path("{networkassociationUUID}") + @DELETE + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response deleteBgpvpnNetworkAssociation( + @PathParam("networkassociationUUID") String bgpvpnNetworkAssociationUUID) { + return delete(bgpvpnNetworkAssociationUUID); + } + +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationRequest.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationRequest.java new file mode 100644 index 000000000..42788742d --- /dev/null +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.northbound.api; + +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import org.opendaylight.neutron.spi.NeutronBgpvpnRouterAssociation; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class NeutronBgpvpnRouterAssociationRequest implements INeutronRequest { + + @XmlElement(name = "bgpvpn_router_association") + NeutronBgpvpnRouterAssociation singleton; + + @XmlElement(name = "bgpvpn_router_associations") + List bulkRequest; + + NeutronBgpvpnRouterAssociationRequest() { + } + + @edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD") + NeutronBgpvpnRouterAssociationRequest(NeutronBgpvpnRouterAssociation bgpvpnRouterAssociation) { + singleton = bgpvpnRouterAssociation; + } + + @edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD") + NeutronBgpvpnRouterAssociationRequest(List bulk) { + bulkRequest = bulk; + } +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationsNorthbound.java new file mode 100644 index 000000000..478619519 --- /dev/null +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnRouterAssociationsNorthbound.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.northbound.api; + +import com.webcohesion.enunciate.metadata.rs.ResponseCode; +import com.webcohesion.enunciate.metadata.rs.StatusCodes; +import com.webcohesion.enunciate.metadata.rs.TypeHint; +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import org.apache.aries.blueprint.annotation.service.Reference; +import org.opendaylight.neutron.spi.INeutronBgpvpnRouterAssociationCRUD; +import org.opendaylight.neutron.spi.NeutronBgpvpnRouterAssociation; + +/** + * Neutron Northbound REST APIs for BgpvpnRouterAssociation.
+ * This class provides REST APIs for managing neutron BgpvpnRouterAssociations + * + *
+ *
+ * Authentication scheme : HTTP Basic
+ * Authentication realm : opendaylight
+ * Transport : HTTP and HTTPS
+ *
+ * HTTPS Authentication is disabled by default. Administrator can enable it in + * tomcat-server.xml after adding a proper keystore / SSL certificate from a + * trusted authority.
+ * More info : + * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * + */ +@Singleton +@Path("/bgpvpn/routerassociations") +public final class NeutronBgpvpnRouterAssociationsNorthbound extends + AbstractNeutronNorthbound { + + @Context + UriInfo uriInfo; + + @Inject + public NeutronBgpvpnRouterAssociationsNorthbound(@Reference INeutronBgpvpnRouterAssociationCRUD neutronCRUD) { + super(neutronCRUD); + } + + private static final String RESOURCE_NAME = "Bgpvpn Router Associations"; + + @Override + protected String getResourceName() { + return RESOURCE_NAME; + } + + /** + * Returns a list of all BgpvpnRouterAssociations. + */ + + @GET + @Produces({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response listBgpvpnRouterAssociations( + // return fields + @QueryParam("fields") List fields, + + @QueryParam("id") String queryID, + @QueryParam("bgpvpn_id") String queryBgpvpnId, + @QueryParam("router_id") String queryRouterId, + // pagination + @QueryParam("limit") Integer limit, + @QueryParam("marker") String marker, + @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse + ) { + INeutronBgpvpnRouterAssociationCRUD neutronBgpvpnRouterAssociation = getNeutronCRUD(); + List allBgpvpnRouteAssos = neutronBgpvpnRouterAssociation.getAll(); + List ans = new ArrayList<>(); + for (NeutronBgpvpnRouterAssociation bgpvpnRouteAsso : allBgpvpnRouteAssos) { + //match filters: + if ((queryID == null || queryID.equals(bgpvpnRouteAsso.getID())) + && (queryBgpvpnId == null || queryBgpvpnId.equals(bgpvpnRouteAsso.getBgpvpnId())) + && (queryRouterId == null || queryRouterId.equals(bgpvpnRouteAsso.getRouterId()))) { + if (fields.size() > 0) { + ans.add(bgpvpnRouteAsso.extractFields(fields)); + } else { + ans.add(bgpvpnRouteAsso); + } + } + } + + if (limit != null && ans.size() > 1) { + // Return a paginated request + NeutronBgpvpnRouterAssociationRequest request = (NeutronBgpvpnRouterAssociationRequest) + PaginatedRequestFactory.createRequest(limit, marker, pageReverse, uriInfo, ans, + NeutronBgpvpnRouterAssociation.class); + return Response.status(HttpURLConnection.HTTP_OK).entity(request).build(); + } + return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronBgpvpnRouterAssociationRequest(ans)) + .build(); + } + + /** + * Returns a specific BgpvpnRouterAssociation. + */ + + @Path("{routerassociationUUID}") + @GET + @Produces({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response showBgpvpnRouterAssociation( + @PathParam("routerassociationUUID") String bgpvpnRouterAssociationUUID, + // return fields + @QueryParam("fields") List fields) { + return show(bgpvpnRouterAssociationUUID, fields); + } + + /** + * Creates new BgpvpnRouterAssociations. + */ + @POST + @Produces({ MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_JSON }) + @TypeHint(NeutronBgpvpnRouterAssociation.class) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response createBgpvpnRouterAssociations(final NeutronBgpvpnRouterAssociationRequest input) { + return create(input); + } + + /** + * Updates a BgpvpnRouterAssociation. + */ + + @Path("{routerassociationUUID}") + @PUT + @Produces({ MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_JSON }) + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response updateBgpvpnRouterAssociation( + @PathParam("routerassociationUUID") String bgpvpnRouterAssociationUUID, + final NeutronBgpvpnRouterAssociationRequest input) { + return update(bgpvpnRouterAssociationUUID, input); + } + + /** + * Deletes a BgpvpnRouterAssociation. + */ + + @Path("{routerassociationUUID}") + @DELETE + @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"), + @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), + @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) + public Response deleteBgpvpn(@PathParam("routerassociationUUID") String bgpvpnRouterAssociationUUID) { + return delete(bgpvpnRouterAssociationUUID); + } + +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnsNorthbound.java index 55e7bc5d3..42db59a98 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronBgpvpnsNorthbound.java @@ -31,7 +31,12 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.aries.blueprint.annotation.service.Reference; import org.opendaylight.neutron.spi.INeutronBgpvpnCRUD; +import org.opendaylight.neutron.spi.INeutronBgpvpnNetworkAssociationCRUD; +import org.opendaylight.neutron.spi.INeutronBgpvpnRouterAssociationCRUD; import org.opendaylight.neutron.spi.NeutronBgpvpn; +import org.opendaylight.neutron.spi.NeutronBgpvpnNetworkAssociation; +import org.opendaylight.neutron.spi.NeutronBgpvpnRouterAssociation; + /** * Neutron Northbound REST APIs for Bgpvpn. @@ -46,9 +51,18 @@ public final class NeutronBgpvpnsNorthbound @Context UriInfo uriInfo; + + INeutronBgpvpnNetworkAssociationCRUD neutronBgpvpnNetworkAssociation; + INeutronBgpvpnRouterAssociationCRUD neutronBgpvpnRouterAssociation; + @Inject - public NeutronBgpvpnsNorthbound(@Reference INeutronBgpvpnCRUD neutronCRUD) { + public NeutronBgpvpnsNorthbound(@Reference INeutronBgpvpnCRUD neutronCRUD, + INeutronBgpvpnNetworkAssociationCRUD neutronBgpvpnNetworkAssociation, + INeutronBgpvpnRouterAssociationCRUD neutronBgpvpnRouterAssociation) { super(neutronCRUD); + this.neutronBgpvpnNetworkAssociation = neutronBgpvpnNetworkAssociation; + this.neutronBgpvpnRouterAssociation = neutronBgpvpnRouterAssociation; + } @Override @@ -178,6 +192,23 @@ public final class NeutronBgpvpnsNorthbound @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) public Response deleteBgpvpn(@PathParam("bgpvpnUUID") String bgpvpnUUID) { + NeutronBgpvpnNetworkAssociationsNorthbound netAssoNorthBound = + new NeutronBgpvpnNetworkAssociationsNorthbound(neutronBgpvpnNetworkAssociation); + List allBgpvpnNetAssos = neutronBgpvpnNetworkAssociation.getAll(); + for (NeutronBgpvpnNetworkAssociation bgpvpnNetAsso : allBgpvpnNetAssos) { + if (bgpvpnUUID != null && bgpvpnUUID.equals(bgpvpnNetAsso.getBgpvpnId())) { + netAssoNorthBound.delete(bgpvpnNetAsso.getID()); + } + } + + NeutronBgpvpnRouterAssociationsNorthbound routeAssoNorthBound = + new NeutronBgpvpnRouterAssociationsNorthbound(neutronBgpvpnRouterAssociation); + List allBgpvpnRouteAssos = neutronBgpvpnRouterAssociation.getAll(); + for (NeutronBgpvpnRouterAssociation bgpvpnRouteAsso : allBgpvpnRouteAssos) { + if (bgpvpnUUID != null && bgpvpnUUID.equals(bgpvpnRouteAsso.getBgpvpnId())) { + routeAssoNorthBound.delete(bgpvpnRouteAsso.getID()); + } + } return delete(bgpvpnUUID); } } diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNorthboundRSApplication.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNorthboundRSApplication.java index 0fdd9b774..522f1c2b5 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNorthboundRSApplication.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNorthboundRSApplication.java @@ -65,6 +65,8 @@ public final class NeutronNorthboundRSApplication extends Application { private final NeutronTrunksNorthbound neutronTrunksNorthbound; private final NeutronTapServiceNorthbound neutronTapServiceNorthbound; private final NeutronTapFlowNorthbound neutronTapFlowNorthbound; + private final NeutronBgpvpnNetworkAssociationsNorthbound neutronBgpvpnNetworkAssociationsNorthbound; + private final NeutronBgpvpnRouterAssociationsNorthbound neutronBgpvpnRouterAssociationsNorthbound; @Inject public NeutronNorthboundRSApplication( @@ -98,7 +100,9 @@ public final class NeutronNorthboundRSApplication extends Application { NeutronQosPolicyNorthbound neutronQosPolicyNorthbound, NeutronTrunksNorthbound neutronTrunksNorthbound, NeutronTapServiceNorthbound neutronTapServiceNorthbound, - NeutronTapFlowNorthbound neutronTapFlowNorthbound) { + NeutronTapFlowNorthbound neutronTapFlowNorthbound, + NeutronBgpvpnNetworkAssociationsNorthbound neutronBgpvpnNetworkAssociationsNorthbound, + NeutronBgpvpnRouterAssociationsNorthbound neutronBgpvpnRouterAssociationsNorthbound) { this.neutronNetworksNorthbound = neutronNetworksNorthbound; this.neutronSubnetsNorthbound = neutronSubnetsNorthbound; @@ -131,6 +135,8 @@ public final class NeutronNorthboundRSApplication extends Application { this.neutronTrunksNorthbound = neutronTrunksNorthbound; this.neutronTapServiceNorthbound = neutronTapServiceNorthbound; this.neutronTapFlowNorthbound = neutronTapFlowNorthbound; + this.neutronBgpvpnNetworkAssociationsNorthbound = neutronBgpvpnNetworkAssociationsNorthbound; + this.neutronBgpvpnRouterAssociationsNorthbound = neutronBgpvpnRouterAssociationsNorthbound; } @Override @@ -140,7 +146,7 @@ public final class NeutronNorthboundRSApplication extends Application { @Override public Set getSingletons() { - return ImmutableSet.builderWithExpectedSize(32) + return ImmutableSet.builderWithExpectedSize(34) .add(getMOXyJsonProvider()) // Northbound URIs JAX RS Resources: .add(neutronNetworksNorthbound) @@ -164,6 +170,8 @@ public final class NeutronNorthboundRSApplication extends Application { .add(neutronVpnIpSecPoliciesNorthbound) .add(neutronVpnIpSecSiteConnectionsNorthbound) .add(neutronBgpvpnsNorthbound) + .add(neutronBgpvpnNetworkAssociationsNorthbound) + .add(neutronBgpvpnRouterAssociationsNorthbound) .add(neutronL2gatewayNorthbound) .add(neutronL2gatewayConnectionNorthbound) .add(neutronSFCFlowClassifiersNorthbound) diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnNetworkAssociationInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnNetworkAssociationInterface.java new file mode 100644 index 000000000..9ab223256 --- /dev/null +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnNetworkAssociationInterface.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.transcriber; + +import java.util.Collection; +import javax.inject.Inject; +import javax.inject.Singleton; +import org.apache.aries.blueprint.annotation.service.Service; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.neutron.spi.INeutronBgpvpnNetworkAssociationCRUD; +import org.opendaylight.neutron.spi.NeutronBgpvpnNetworkAssociation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.network.association.rev190502.bgpvpn.network.associations.attributes.BgpvpnNetworkAssociations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.network.association.rev190502.bgpvpn.network.associations.attributes.bgpvpn.network.associations.BgpvpnNetworkAssociation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.network.association.rev190502.bgpvpn.network.associations.attributes.bgpvpn.network.associations.BgpvpnNetworkAssociationBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.network.association.rev190502.bgpvpn.network.associations.attributes.bgpvpn.network.associations.BgpvpnNetworkAssociationKey; + +@Singleton +@Service(classes = INeutronBgpvpnNetworkAssociationCRUD.class) +public final class NeutronBgpvpnNetworkAssociationInterface extends AbstractNeutronInterface + implements INeutronBgpvpnNetworkAssociationCRUD { + + @Inject + public NeutronBgpvpnNetworkAssociationInterface(DataBroker db) { + super(BgpvpnNetworkAssociationBuilder.class, db); + } + + @Override + protected Collection getDataObjectList( + BgpvpnNetworkAssociations bgpvpnNetworkAssociations) { + return bgpvpnNetworkAssociations.nonnullBgpvpnNetworkAssociation().values(); + } + + @Override + protected NeutronBgpvpnNetworkAssociation fromMd(BgpvpnNetworkAssociation bgpvpnNetworkAssociation) { + final NeutronBgpvpnNetworkAssociation result = new NeutronBgpvpnNetworkAssociation(); + fromMdBaseAttributes(bgpvpnNetworkAssociation, result); + fromMdAdminAttributes(bgpvpnNetworkAssociation, result); + if (bgpvpnNetworkAssociation.getBgpvpnId() != null) { + result.setBgpvpnId(bgpvpnNetworkAssociation.getBgpvpnId().getValue()); + } + if (bgpvpnNetworkAssociation.getNetworkId() != null) { + result.setNetworkIds(bgpvpnNetworkAssociation.getNetworkId().getValue()); + } + return result; + } + + @Override + protected BgpvpnNetworkAssociation toMd(NeutronBgpvpnNetworkAssociation bgpvpnNetworkAssociation) { + final BgpvpnNetworkAssociationBuilder bgpvpnNetworkAssociationBuilder = new BgpvpnNetworkAssociationBuilder(); + toMdBaseAttributes(bgpvpnNetworkAssociation, bgpvpnNetworkAssociationBuilder); + toMdAdminAttributes(bgpvpnNetworkAssociation, bgpvpnNetworkAssociationBuilder); + if (bgpvpnNetworkAssociation.getBgpvpnId() != null) { + bgpvpnNetworkAssociationBuilder.setBgpvpnId(toUuid(bgpvpnNetworkAssociation.getBgpvpnId())); + } + if (bgpvpnNetworkAssociation.getNetworkIds() != null) { + bgpvpnNetworkAssociationBuilder.setNetworkId(toUuid(bgpvpnNetworkAssociation.getNetworkIds())); + } + return bgpvpnNetworkAssociationBuilder.build(); + } + +} diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnRouterAssociationInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnRouterAssociationInterface.java new file mode 100644 index 000000000..06831f397 --- /dev/null +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronBgpvpnRouterAssociationInterface.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.transcriber; + +import java.util.Collection; +import javax.inject.Inject; +import javax.inject.Singleton; +import org.apache.aries.blueprint.annotation.service.Service; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.neutron.spi.INeutronBgpvpnRouterAssociationCRUD; +import org.opendaylight.neutron.spi.NeutronBgpvpnRouterAssociation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.router.association.rev190502.bgpvpn.router.associations.attributes.BgpvpnRouterAssociations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.router.association.rev190502.bgpvpn.router.associations.attributes.bgpvpn.router.associations.BgpvpnRouterAssociation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.router.association.rev190502.bgpvpn.router.associations.attributes.bgpvpn.router.associations.BgpvpnRouterAssociationBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.bgpvpn.router.association.rev190502.bgpvpn.router.associations.attributes.bgpvpn.router.associations.BgpvpnRouterAssociationKey; + +@Singleton +@Service(classes = INeutronBgpvpnRouterAssociationCRUD.class) +public final class NeutronBgpvpnRouterAssociationInterface extends AbstractNeutronInterface + implements INeutronBgpvpnRouterAssociationCRUD { + + @Inject + public NeutronBgpvpnRouterAssociationInterface(DataBroker db) { + super(BgpvpnRouterAssociationBuilder.class, db); + } + + @Override + protected Collection getDataObjectList(BgpvpnRouterAssociations bgpvpnRouterAssociations) { + return bgpvpnRouterAssociations.nonnullBgpvpnRouterAssociation().values(); + } + + @Override + protected NeutronBgpvpnRouterAssociation fromMd(BgpvpnRouterAssociation bgpvpnRouterAssociation) { + final NeutronBgpvpnRouterAssociation result = new NeutronBgpvpnRouterAssociation(); + fromMdBaseAttributes(bgpvpnRouterAssociation, result); + fromMdAdminAttributes(bgpvpnRouterAssociation, result); + if (bgpvpnRouterAssociation.getBgpvpnId() != null) { + result.setBgpvpnId(bgpvpnRouterAssociation.getBgpvpnId().getValue()); + } + if (bgpvpnRouterAssociation.getRouterId() != null) { + result.setRouterId(bgpvpnRouterAssociation.getRouterId().getValue()); + } + return result; + } + + @Override + protected BgpvpnRouterAssociation toMd(NeutronBgpvpnRouterAssociation bgpvpnRouterAssociation) { + final BgpvpnRouterAssociationBuilder bgpvpnRouterAssociationBuilder = new BgpvpnRouterAssociationBuilder(); + toMdBaseAttributes(bgpvpnRouterAssociation, bgpvpnRouterAssociationBuilder); + toMdAdminAttributes(bgpvpnRouterAssociation, bgpvpnRouterAssociationBuilder); + if (bgpvpnRouterAssociation.getBgpvpnId() != null) { + bgpvpnRouterAssociationBuilder.setBgpvpnId(toUuid(bgpvpnRouterAssociation.getBgpvpnId())); + } + if (bgpvpnRouterAssociation.getRouterId() != null) { + bgpvpnRouterAssociationBuilder.setRouterId(toUuid(bgpvpnRouterAssociation.getRouterId())); + } + return bgpvpnRouterAssociationBuilder.build(); + } + +}