This time adding LBaaS and VPNaaS classes...
Patch Set 5 works, but without metering and VPNaaS...
Patch Set 8 adds tests of metering lables and rules correctly
Patch Set 17 adds testing of VPNaaS items (- IPSECPolicy)
Patch Set 20 completes VPNaaS
Subsequent patches are aimed at resolving the issues
with LBaaS URL issues
Change-Id: I41a08cc974c71c5f9bf207c8ea7e4e3600fee494
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
import org.opendaylight.neutron.spi.INeutronLoadBalancerListenerAware;
import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolAware;
import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolMemberAware;
+import org.opendaylight.neutron.spi.INeutronMeteringLabelAware;
+import org.opendaylight.neutron.spi.INeutronMeteringLabelRuleAware;
import org.opendaylight.neutron.spi.INeutronNetworkAware;
import org.opendaylight.neutron.spi.INeutronPortAware;
import org.opendaylight.neutron.spi.INeutronRouterAware;
import org.opendaylight.neutron.spi.INeutronSecurityGroupAware;
import org.opendaylight.neutron.spi.INeutronSecurityRuleAware;
import org.opendaylight.neutron.spi.INeutronSubnetAware;
+import org.opendaylight.neutron.spi.INeutronVPNIKEPolicyAware;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECPolicyAware;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECSiteConnectionAware;
+import org.opendaylight.neutron.spi.INeutronVPNServiceAware;
import org.osgi.framework.BundleContext;
manager.add(createComponent().setInterface(new String[] {
INeutronLoadBalancerPoolMemberAware.class.getName()}, null)
.setImplementation(NeutronLoadBalancerPoolMemberDummyProvider.class));
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronMeteringLabelAware.class.getName()}, null)
+ .setImplementation(NeutronMeteringLabelDummyProvider.class));
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronMeteringLabelRuleAware.class.getName()}, null)
+ .setImplementation(NeutronMeteringLabelRuleDummyProvider.class));
+
manager.add(createComponent().setInterface(new String[] {
INeutronNetworkAware.class.getName()}, null)
.setImplementation(NeutronNetworkDummyProvider.class));
manager.add(createComponent().setInterface(new String[] {
INeutronSubnetAware.class.getName()}, null)
.setImplementation(NeutronSubnetDummyProvider.class));
+
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronVPNIKEPolicyAware.class.getName()}, null)
+ .setImplementation(NeutronVPNIKEPolicyDummyProvider.class));
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronVPNIPSECPolicyAware.class.getName()}, null)
+ .setImplementation(NeutronVPNIPSECPolicyDummyProvider.class));
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronVPNIPSECSiteConnectionAware.class.getName()}, null)
+ .setImplementation(NeutronVPNIPSECSiteConnectionDummyProvider.class));
+ manager.add(createComponent().setInterface(new String[] {
+ INeutronVPNServiceAware.class.getName()}, null)
+ .setImplementation(NeutronVPNServiceDummyProvider.class));
}
/**
NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
securityRule_tester.securityRule_collection_get_test();
-// TODO: find why this is throwing a 404
-// NeutronMeteringLabelTests meteringLabel_tester = new NeutronMeteringLabelTests(base);
-// meteringLabel_tester.meteringLabel_collection_get_test();
+ NeutronLoadBalancerTests loadBalancer_tester = new NeutronLoadBalancerTests(base);
+ loadBalancer_tester.loadBalancer_collection_get_test();
-// TODO: find why this is throwing a 404
-// NeutronMeteringRuleTests meteringRule_tester = new NeutronMeteringRuleTests(base);
-// meteringRule_tester.meteringRule_collection_get_test();
+ NeutronLBListenerTests listener_tester = new NeutronLBListenerTests(base);
+ listener_tester.listener_collection_get_test();
+
+ NeutronLBPoolTests pool_tester = new NeutronLBPoolTests(base);
+ pool_tester.pool_collection_get_test();
+
+ NeutronLBHealthMonitorTests healthMonitor_tester = new NeutronLBHealthMonitorTests(base);
+ healthMonitor_tester.healthMonitor_collection_get_test();
+
+// TODO: add LoadBalancerPoolMembers testing
+
+ NeutronMeteringLabelTests meteringLabel_tester = new NeutronMeteringLabelTests(base);
+ meteringLabel_tester.meteringLabel_collection_get_test();
+
+ NeutronMeteringRuleTests meteringRule_tester = new NeutronMeteringRuleTests(base);
+ meteringRule_tester.meteringRule_collection_get_test();
+
+ NeutronVPNServicesTests vpnService_tester = new NeutronVPNServicesTests(base);
+ vpnService_tester.vpnService_collection_get_test();
+
+ NeutronIKEPoliciesTests ike_policy_tester = new NeutronIKEPoliciesTests(base);
+ ike_policy_tester.ikePolicy_collection_get_test();
+
+ NeutronIPSECPoliciesTests ipsec_policy_tester = new NeutronIPSECPoliciesTests(base);
+ ipsec_policy_tester.ipsecPolicy_collection_get_test();
+
+ NeutronIPSECSiteConnectionTests ipsec_siteConnection_test = new NeutronIPSECSiteConnectionTests(base);
+ ipsec_siteConnection_test.ipsecSiteConnection_collection_get_test();
}
}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronIKEPoliciesTests {
+ String base;
+
+ public NeutronIKEPoliciesTests(String base) {
+ this.base = base;
+ }
+
+ public void ikePolicy_collection_get_test() {
+ String url_s = base + "/vpn/ikepolicies";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("IKE Policy GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronIPSECPoliciesTests {
+ String base;
+
+ public NeutronIPSECPoliciesTests(String base) {
+ this.base = base;
+ }
+
+ public void ipsecPolicy_collection_get_test() {
+ String url_s = base + "/vpn/ipsecpolicies";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("IPSEC Policy Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronIPSECSiteConnectionTests {
+ String base;
+
+ public NeutronIPSECSiteConnectionTests(String base) {
+ this.base = base;
+ }
+
+ public void ipsecSiteConnection_collection_get_test() {
+ String url_s = base + "/vpn/ipsecsiteconnections";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("IPSEC Site Connection Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronLBHealthMonitorTests {
+ String base;
+
+ public NeutronLBHealthMonitorTests(String base) {
+ this.base = base;
+ }
+
+ public void healthMonitor_collection_get_test() {
+ String url_s = base + "/lbaas/healthmonitors";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("LB Health Monitor Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronLBListenerTests {
+ String base;
+
+ public NeutronLBListenerTests(String base) {
+ this.base = base;
+ }
+
+ public void listener_collection_get_test() {
+ String url_s = base + "/lbaas/listeners";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("LB Listener Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronLBPoolMembersTests {
+ String base;
+
+ public NeutronLBPoolMembersTests(String base) {
+ this.base = base;
+ }
+
+// TODO: have to be careful here as the pool id is included
+
+/* public void pool_collection_get_test() {
+ String url_s = base + "/pools";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("LB Pool Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ } */
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronLBPoolTests {
+ String base;
+
+ public NeutronLBPoolTests(String base) {
+ this.base = base;
+ }
+
+ public void pool_collection_get_test() {
+ String url_s = base + "/lbaas/pools";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("LB Pool Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronLoadBalancerTests {
+ String base;
+
+ public NeutronLoadBalancerTests(String base) {
+ this.base = base;
+ }
+
+ public void loadBalancer_collection_get_test() {
+ String url_s = base + "/lbaas/loadbalancers";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("Load Balancer Collection GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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;
+
+import java.io.OutputStreamWriter;
+
+import java.lang.Thread;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+
+public class NeutronVPNServicesTests {
+ String base;
+
+ public NeutronVPNServicesTests(String base) {
+ this.base = base;
+ }
+
+ public void vpnService_collection_get_test() {
+ String url_s = base + "/vpn/vpnservices";
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod("GET");
+ httpConn.setRequestProperty("Content-Type", "application/json");
+ httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
+ Assert.assertEquals("VPN Services GET failed",
+ 200, httpConn.getResponseCode());
+ } catch (Exception e) {
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 IBM Corporation. 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.List;
+
+public interface INeutronVPNIPSECPolicyCRUD {
+
+ /**yes
+ * Applications call this interface method to determine if a particular
+ *NeutronVPNIPSECPolicy object exists
+ *
+ * @param uuid
+ * UUID of the NeutronVPNIPSECPolicy object
+ * @return boolean
+ */
+
+ public boolean neutronVPNIPSECPolicyExists(String uuid);
+
+ /**
+ * Applications call this interface method to return if a particular
+ * NeutronVPNIPSECPolicy object exists
+ *
+ * @param uuid
+ * UUID of the NeutronVPNIPSECPolicy object
+ * @return {@link org.opendaylight.neutron.spi.NeutronVPNIPSECPolicy}
+ * OpenStackNeutronVPNIPSECPolicy class
+ */
+
+ public NeutronVPNIPSECPolicy getNeutronVPNIPSECPolicy(String uuid);
+
+ /**
+ * Applications call this interface method to return all NeutronVPNIPSECPolicy objects
+ *
+ * @return List of OpenStackNetworks objects
+ */
+
+ public List<NeutronVPNIPSECPolicy> getAllNeutronVPNIPSECPolicies();
+
+ /**
+ * Applications call this interface method to add a NeutronVPNIPSECPolicy object to the
+ * concurrent map
+ *
+ * @param input
+ * OpenStackNetwork object
+ * @return boolean on whether the object was added or not
+ */
+
+ public boolean addNeutronVPNIPSECPolicy(NeutronVPNIPSECPolicy input);
+
+ /**
+ * Applications call this interface method to remove a Neutron NeutronVPNIPSECPolicy object to the
+ * concurrent map
+ *
+ * @param uuid
+ * identifier for the NeutronVPNIPSECPolicy object
+ * @return boolean on whether the object was removed or not
+ */
+
+ public boolean removeNeutronVPNIPSECPolicy(String uuid);
+
+ /**
+ * Applications call this interface method to edit a NeutronVPNIPSECPolicy object
+ *
+ * @param uuid
+ * identifier of the NeutronVPNIPSECPolicy object
+ * @param delta
+ * OpenStackNeutronVPNIPSECPolicy object containing changes to apply
+ * @return boolean on whether the object was updated or not
+ */
+
+ public boolean updateNeutronVPNIPSECPolicy(String uuid, NeutronVPNIPSECPolicy delta);
+
+ /**
+ * Applications call this interface method to see if a MAC address is in use
+ *
+ * @param uuid
+ * identifier of the NeutronVPNIPSECPolicy object
+ * @return boolean on whether the macAddress is already associated with a
+ * port or not
+ */
+
+ public boolean neutronVPNIPSECPolicyInUse(String uuid);
+
+}
return answer;
}
+ public static INeutronVPNIPSECPolicyCRUD getINeutronVPNIPSECPolicyCRUD(Object o) {
+ INeutronVPNIPSECPolicyCRUD answer = (INeutronVPNIPSECPolicyCRUD) getInstances(INeutronVPNIPSECPolicyCRUD.class, o);
+ return answer;
+ }
+
public static INeutronVPNServiceCRUD getINeutronVPNServiceCRUD(Object o) {
INeutronVPNServiceCRUD answer = (INeutronVPNServiceCRUD) getInstances(INeutronVPNServiceCRUD.class, o);
return answer;
import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlElement (name = "transform_protocol")
String transformProtocol;
- @XmlElement (name = "encapsulaion_mode")
+ @XmlElement (name = "encapsulation_mode")
String encapsulationMode;
@XmlElement (name = "auth_algorithm")
this.lifetime = lifetime;
}
+ /**
+ * This method copies selected fields from the object and returns them
+ * as a new object, suitable for marshaling.
+ *
+ * @param fields
+ * List of attributes to be extracted
+ * @return a NeutronVPNIPSECPolicy object with only the selected fields
+ * populated
+ */
+ public NeutronVPNIPSECPolicy extractFields(List<String> fields) {
+ NeutronVPNIPSECPolicy ans = new NeutronVPNIPSECPolicy();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("name")) {
+ ans.setName(this.getName());
+ }
+ if (s.equals("description")) {
+ ans.setDescription(this.getDescription());
+ }
+ if (s.equals("transform_protocol")) {
+ ans.setTransformProtocol(this.getTransformProtocol());
+ }
+ if (s.equals("encapsulation_mode")) {
+ ans.setEncapsulationMode(this.getEncapsulationMode());
+ }
+ if (s.equals("auth_algorithm")) {
+ ans.setAuthAlgorithm(this.getAuthAlgorithm());
+ }
+ if (s.equals("encryption_algorithm")) {
+ ans.setEncryptionAlgorithm(this.getEncryptionAlgorithm());
+ }
+ if (s.equals("pfs")) {
+ ans.setPerfectForwardSecrecy(this.getPerfectForwardSecrecy());
+ }
+ }
+ return ans;
+ }
+
}
public class NeutronVPNIPSECPolicyJAXBTest {
- private static final String NeutronVPNISECPolicy_SingleProvider_sourceJson = "{" +
+ private static final String NeutronVPNIPSECPolicy_SingleProvider_sourceJson = "{" +
"\"id\": \"5291b189-fd84-46e5-84bd-78f40c05d69c\", " +
"\"tenant_id\": \"ccb81365fe36411a9011e90491fe1330\", " +
"\"name\": \"ipsecpolicy1\", " +
"\"description\": \"update description\", " +
"\"transform_protocol\": \"esp\", " +
- "\"encapsulaion_mode\": \"tunnel\", " +
+ "\"encapsulation_mode\": \"tunnel\", " +
"\"auth_algorithm\": \"sha1\", " +
"\"encryption_algorithm\": \"aes-128\", " +
"\"pfs\": \"group5\", " +
"\"lifetime\": { " + "\"units\": \"seconds\", " + "\"value\": 3600 " + "} }";
@Test
- public void test_NeutronVPNISECPolicy_JAXB() {
+ public void test_NeutronVPNIPSECPolicy_JAXB() {
NeutronVPNIPSECPolicy dummyObject = new NeutronVPNIPSECPolicy();
try {
- NeutronVPNIPSECPolicy testObject = (NeutronVPNIPSECPolicy) JaxbTestHelper.jaxbUnmarshall(dummyObject, NeutronVPNISECPolicy_SingleProvider_sourceJson);
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 1: Testing id failed",
+ NeutronVPNIPSECPolicy testObject = (NeutronVPNIPSECPolicy) JaxbTestHelper.jaxbUnmarshall(dummyObject, NeutronVPNIPSECPolicy_SingleProvider_sourceJson);
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 1: Testing id failed",
"5291b189-fd84-46e5-84bd-78f40c05d69c", testObject.getID());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 2: Testing tenant id failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 2: Testing tenant id failed",
"ccb81365fe36411a9011e90491fe1330", testObject.getTenantID());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 3: Testing name failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 3: Testing name failed",
"ipsecpolicy1", testObject.getName());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 4: Testing description failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 4: Testing description failed",
"update description", testObject.getDescription());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 5: Testing transform protocol failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 5: Testing transform protocol failed",
"esp", testObject.getTransformProtocol());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 6: Testing encapsulation mode failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 6: Testing encapsulation mode failed",
"tunnel", testObject.getEncapsulationMode());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 7: Testing authorization algorithm failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 7: Testing authorization algorithm failed",
"sha1", testObject.getAuthAlgorithm());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 8: Testing encryption algorithm failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 8: Testing encryption algorithm failed",
"aes-128", testObject.getEncryptionAlgorithm());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 9: Testing PerfectForwardSecrecy failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 9: Testing PerfectForwardSecrecy failed",
"group5", testObject.getPerfectForwardSecrecy());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 10: Testing Lifetime unit value failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 10: Testing Lifetime unit value failed",
"seconds", testObject.getLifetime().getUnits());
- Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 11: Testing Lifetime value failed",
+ Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 11: Testing Lifetime value failed",
new Integer(3600), testObject.getLifetime().getValue());
} catch (Exception e) {
Assert.fail("Tests failed");
* http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
*
*/
-@Path("/healthmonitors")
+@Path("/lbaas/healthmonitors")
public class NeutronLoadBalancerHealthMonitorNorthbound {
private static final Logger logger = LoggerFactory.getLogger(NeutronLoadBalancer.class);
* http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
*
*/
-@Path("/listeners")
+@Path("/lbaas/listeners")
public class NeutronLoadBalancerListenerNorthbound {
private NeutronLoadBalancerListener extractFields(NeutronLoadBalancerListener o, List<String> fields) {
* http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
*
*/
-@Path("/loadbalancers")
+@Path("/lbaas/loadbalancers")
public class NeutronLoadBalancerNorthbound {
private NeutronLoadBalancer extractFields(NeutronLoadBalancer o, List<String> fields) {
import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
-@Path("/pools/{loadBalancerPoolUUID}/members")
+@Path("/lbaas/pools/{loadBalancerPoolUUID}/members")
public class NeutronLoadBalancerPoolMembersNorthbound {
private NeutronLoadBalancerPoolMember extractFields(NeutronLoadBalancerPoolMember o, List<String> fields) {
return o.extractFields(fields);
* and not duplicated within the INeutronLoadBalancerPoolMemberCRUD's cache.
*/
-@Path("/pools")
+@Path("/lbaas/pools")
public class NeutronLoadBalancerPoolNorthbound {
private NeutronLoadBalancerPool extractFields(NeutronLoadBalancerPool o, List<String> fields) {
classes.add(NeutronLoadBalancerPoolNorthbound.class);
classes.add(NeutronLoadBalancerHealthMonitorNorthbound.class);
classes.add(NeutronLoadBalancerPoolMembersNorthbound.class);
+ classes.add(NeutronMeteringLabelsNorthbound.class);
+ classes.add(NeutronMeteringLabelRulesNorthbound.class);
+ classes.add(NeutronVPNServicesNorthbound.class);
+ classes.add(NeutronVPNIKEPoliciesNorthbound.class);
+ classes.add(NeutronVPNIPSECPoliciesNorthbound.class);
+ classes.add(NeutronVPNIPSECSiteConnectionsNorthbound.class);
+
classes.add(MOXyJsonProvider.class);
return classes;
}
--- /dev/null
+/*
+ * Copyright IBM Corporation, 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.northbound.api;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+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.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.codehaus.enunciate.jaxrs.TypeHint;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECPolicyAware;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECPolicyCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronVPNIPSECPolicy;
+
+/**
+ * Neutron Northbound REST APIs for VPN IPSEC Policy.<br>
+ * This class provides REST APIs for managing neutron VPN IPSEC Policies
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * 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.<br>
+ * More info :
+ * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ *
+ */
+
+@Path("/vpn/ipsecpolicies")
+public class NeutronVPNIPSECPoliciesNorthbound {
+
+ private NeutronVPNIPSECPolicy extractFields(NeutronVPNIPSECPolicy o, List<String> fields) {
+ return o.extractFields(fields);
+ }
+
+ @Context
+ UriInfo uriInfo;
+
+ /**
+ * Returns a list of all VPN IPSEC Policies */
+
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 401, condition = "Unauthorized"),
+ @ResponseCode(code = 501, condition = "Not Implemented"),
+ @ResponseCode(code = 503, condition = "No providers available") })
+ public Response listVPNIPSECPolicies(
+ // return fields
+ @QueryParam("fields") List<String> fields,
+ // filter fields
+ @QueryParam("id") String queryID,
+ @QueryParam("tenant_id") String queryTenantID,
+ @QueryParam("name") String queryName,
+ @QueryParam("description") String queryDescription,
+ @QueryParam("transform_protocol") String queryTransformProtocol,
+ @QueryParam("encapsulation_mode") String queryEncapsulationMode,
+ @QueryParam("auth_algorithm") String queryAuthAlgorithm,
+ @QueryParam("encryption_algorithm") String queryEncryptionAlgorithm,
+ @QueryParam("pfs") String queryPFS
+ // pagination and sorting are TODO
+ ) {
+ INeutronVPNIPSECPolicyCRUD labelInterface = NeutronCRUDInterfaces.getINeutronVPNIPSECPolicyCRUD(this);
+ if (labelInterface == null) {
+ throw new ServiceUnavailableException("NeutronVPNIPSECPolicy CRUD Interface "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+ List<NeutronVPNIPSECPolicy> allNeutronVPNIPSECPolicies = labelInterface.getAllNeutronVPNIPSECPolicies();
+ List<NeutronVPNIPSECPolicy> ans = new ArrayList<NeutronVPNIPSECPolicy>();
+ Iterator<NeutronVPNIPSECPolicy> i = allNeutronVPNIPSECPolicies.iterator();
+ while (i.hasNext()) {
+ NeutronVPNIPSECPolicy oSS = i.next();
+ if ((queryID == null || queryID.equals(oSS.getID())) &&
+ (queryName == null || queryName.equals(oSS.getName())) &&
+ (queryDescription == null || queryDescription.equals(oSS.getDescription())) &&
+ (queryAuthAlgorithm == null || queryAuthAlgorithm.equals(oSS.getAuthAlgorithm())) &&
+ (queryEncryptionAlgorithm == null || queryEncryptionAlgorithm.equals(oSS.getEncryptionAlgorithm())) &&
+ (queryPFS == null || queryPFS.equals(oSS.getPerfectForwardSecrecy())) &&
+ (queryTransformProtocol == null || queryTransformProtocol.equals(oSS.getTransformProtocol())) &&
+ (queryEncapsulationMode == null || queryEncapsulationMode.equals(oSS.getEncapsulationMode())) &&
+ (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
+ if (fields.size() > 0)
+ ans.add(extractFields(oSS,fields));
+ else
+ ans.add(oSS);
+ }
+ }
+ //TODO: apply pagination to results
+ return Response.status(200).entity(
+ new NeutronVPNIPSECPolicyRequest(ans)).build();
+ }
+
+ /**
+ * Returns a specific VPN IPSEC Policy */
+
+ @Path("{policyID}")
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 401, condition = "Unauthorized"),
+ @ResponseCode(code = 403, condition = "Forbidden"),
+ @ResponseCode(code = 404, condition = "Not Found"),
+ @ResponseCode(code = 501, condition = "Not Implemented"),
+ @ResponseCode(code = 503, condition = "No providers available") })
+ public Response showVPNIPSECPolicy(
+ @PathParam("policyID") String policyUUID,
+ // return fields
+ @QueryParam("fields") List<String> fields
+ ) {
+ INeutronVPNIPSECPolicyCRUD policyInterface = NeutronCRUDInterfaces.getINeutronVPNIPSECPolicyCRUD(this);
+ if (policyInterface == null) {
+ throw new ServiceUnavailableException("VPNIPSECPolicy CRUD Interface "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+ if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID)) {
+ throw new ResourceNotFoundException("VPNIPSECPolicy UUID not found");
+ }
+ if (fields.size() > 0) {
+ NeutronVPNIPSECPolicy ans = policyInterface.getNeutronVPNIPSECPolicy(policyUUID);
+ return Response.status(200).entity(
+ new NeutronVPNIPSECPolicyRequest(extractFields(ans, fields))).build();
+ } else {
+ return Response.status(200).entity(
+ new NeutronVPNIPSECPolicyRequest(policyInterface.getNeutronVPNIPSECPolicy(policyUUID))).build();
+ }
+ }
+
+ /**
+ * Creates new VPN IPSEC Policy */
+ @POST
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @TypeHint(NeutronVPNIPSECPolicy.class)
+ @StatusCodes({
+ @ResponseCode(code = 201, condition = "Created"),
+ @ResponseCode(code = 400, condition = "Bad Request"),
+ @ResponseCode(code = 401, condition = "Unauthorized"),
+ @ResponseCode(code = 501, condition = "Not Implemented"),
+ @ResponseCode(code = 503, condition = "No providers available") })
+ public Response createVPNIPSECPolicy(final NeutronVPNIPSECPolicyRequest input) {
+ INeutronVPNIPSECPolicyCRUD ipsecPolicyInterface = NeutronCRUDInterfaces.getINeutronVPNIPSECPolicyCRUD(this);
+ if (ipsecPolicyInterface == null) {
+ throw new ServiceUnavailableException("VPNIPSECPolicy CRUD Interface "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+ if (input.isSingleton()) {
+ NeutronVPNIPSECPolicy singleton = input.getSingleton();
+
+ /*
+ * verify that the ipsecPolicy doesn't already exist (issue: is deeper inspection necessary?)
+ */
+ if (ipsecPolicyInterface.neutronVPNIPSECPolicyExists(singleton.getID()))
+ throw new BadRequestException("ipsecPolicy UUID already exists");
+ Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
+ if (instances != null) {
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ int status = service.canCreateNeutronVPNIPSECPolicy(singleton);
+ if (status < 200 || status > 299)
+ return Response.status(status).build();
+ }
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
+ }
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
+ }
+
+ /*
+ * add ipsecPolicy to the cache
+ */
+ ipsecPolicyInterface.addNeutronVPNIPSECPolicy(singleton);
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ service.neutronVPNIPSECPolicyCreated(singleton);
+ }
+ }
+ } else {
+
+ /*
+ * only singleton ipsecPolicy creates supported
+ */
+ throw new BadRequestException("Only singleton ipsecPolicy creates supported");
+ }
+ return Response.status(201).entity(input).build();
+ }
+
+ /**
+ * Updates a VPN IPSEC Policy */
+ @Path("{policyID}")
+ @PUT
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 400, condition = "Bad Request"),
+ @ResponseCode(code = 401, condition = "Unauthorized"),
+ @ResponseCode(code = 404, condition = "Not Found"),
+ @ResponseCode(code = 501, condition = "Not Implemented"),
+ @ResponseCode(code = 503, condition = "No providers available") })
+ public Response updateVPNIPSECPolicy(
+ @PathParam("policyID") String policyUUID, final NeutronVPNIPSECPolicyRequest input
+ ) {
+ INeutronVPNIPSECPolicyCRUD ipsecPolicyInterface = NeutronCRUDInterfaces.getINeutronVPNIPSECPolicyCRUD(this);
+ if (ipsecPolicyInterface == null) {
+ throw new ServiceUnavailableException("VPNIPSECPolicy CRUD Interface "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ /*
+ * ipsecPolicy has to exist and only a single delta can be supplied
+ */
+ if (!ipsecPolicyInterface.neutronVPNIPSECPolicyExists(policyUUID))
+ throw new ResourceNotFoundException("VPNIPSECPolicy UUID not found");
+ if (!input.isSingleton())
+ throw new BadRequestException("Only single ipsecPolicy deltas supported");
+ NeutronVPNIPSECPolicy singleton = input.getSingleton();
+ NeutronVPNIPSECPolicy original = ipsecPolicyInterface.getNeutronVPNIPSECPolicy(policyUUID);
+
+ /*
+ * attribute changes blocked by Neutron
+ */
+ if (singleton.getID() != null || singleton.getTenantID() != null)
+ throw new BadRequestException("Request attribute change not allowed");
+
+ Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
+ if (instances != null) {
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ int status = service.canUpdateNeutronVPNIPSECPolicy(singleton, original);
+ if (status < 200 || status > 299)
+ return Response.status(status).build();
+ }
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
+ }
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
+ }
+ /*
+ * update the ipsecPolicy entry and return the modified object
+ */
+ ipsecPolicyInterface.updateNeutronVPNIPSECPolicy(policyUUID, singleton);
+ NeutronVPNIPSECPolicy updatedVPNIPSECPolicy = ipsecPolicyInterface.getNeutronVPNIPSECPolicy(policyUUID);
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ service.neutronVPNIPSECPolicyUpdated(updatedVPNIPSECPolicy);
+ }
+ }
+ return Response.status(200).entity(
+ new NeutronVPNIPSECPolicyRequest(ipsecPolicyInterface.getNeutronVPNIPSECPolicy(policyUUID))).build();
+ }
+
+ /**
+ * Deletes a VPN IPSEC Policy */
+
+ @Path("{policyID}")
+ @DELETE
+ @StatusCodes({
+ @ResponseCode(code = 204, condition = "No Content"),
+ @ResponseCode(code = 401, condition = "Unauthorized"),
+ @ResponseCode(code = 404, condition = "Not Found"),
+ @ResponseCode(code = 409, condition = "Conflict"),
+ @ResponseCode(code = 501, condition = "Not Implemented"),
+ @ResponseCode(code = 503, condition = "No providers available") })
+ public Response deleteVPNIPSECPolicy(
+ @PathParam("policyID") String policyUUID) {
+ INeutronVPNIPSECPolicyCRUD policyInterface = NeutronCRUDInterfaces.getINeutronVPNIPSECPolicyCRUD(this);
+ if (policyInterface == null) {
+ throw new ServiceUnavailableException("VPNIPSECPolicy CRUD Interface "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ /*
+ * verify that the policy exists and is not in use before removing it
+ */
+ if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID))
+ throw new ResourceNotFoundException("VPNIPSECPolicy UUID not found");
+ NeutronVPNIPSECPolicy singleton = policyInterface.getNeutronVPNIPSECPolicy(policyUUID);
+ Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
+ if (instances != null) {
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ int status = service.canDeleteNeutronVPNIPSECPolicy(singleton);
+ if (status < 200 || status > 299)
+ return Response.status(status).build();
+ }
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
+ }
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
+ }
+ policyInterface.removeNeutronVPNIPSECPolicy(policyUUID);
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
+ service.neutronVPNIPSECPolicyDeleted(singleton);
+ }
+ }
+ return Response.status(204).build();
+ }
+}
import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolMemberCRUD;
import org.opendaylight.neutron.spi.INeutronMeteringLabelCRUD;
+import org.opendaylight.neutron.spi.INeutronMeteringLabelRuleCRUD;
import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
import org.opendaylight.neutron.spi.INeutronPortCRUD;
import org.opendaylight.neutron.spi.INeutronRouterCRUD;
import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
+import org.opendaylight.neutron.spi.INeutronVPNIKEPolicyCRUD;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECPolicyCRUD;
import org.opendaylight.neutron.spi.INeutronVPNIPSECSiteConnectionsCRUD;
import org.opendaylight.neutron.spi.INeutronVPNServiceCRUD;
import org.osgi.framework.BundleActivator;
registrations.add(neutronMeteringLabelInterfaceRegistration);
}
+ NeutronMeteringLabelRuleInterface neutronMeteringLabelRuleInterface = new NeutronMeteringLabelRuleInterface(providerContext);
+ ServiceRegistration<INeutronMeteringLabelRuleCRUD> neutronMeteringLabelRuleInterfaceRegistration = context.registerService(INeutronMeteringLabelRuleCRUD.class, neutronMeteringLabelRuleInterface, null);
+ if(neutronMeteringLabelRuleInterfaceRegistration != null) {
+ registrations.add(neutronMeteringLabelRuleInterfaceRegistration);
+ }
+
NeutronVPNServiceInterface neutronVPNServiceInterface = new NeutronVPNServiceInterface(providerContext);
ServiceRegistration<INeutronVPNServiceCRUD> neutronVPNServiceInterfaceRegistration = context.registerService(INeutronVPNServiceCRUD.class, neutronVPNServiceInterface, null);
if(neutronVPNServiceInterfaceRegistration != null) {
registrations.add(neutronVPNServiceInterfaceRegistration);
}
+ NeutronVPNIKEPolicyInterface neutronVPNIKEPolicyInterface = new NeutronVPNIKEPolicyInterface(providerContext);
+ ServiceRegistration<INeutronVPNIKEPolicyCRUD> neutronVPNIKEPolicyInterfaceRegistration = context.registerService(INeutronVPNIKEPolicyCRUD.class, neutronVPNIKEPolicyInterface, null);
+ if(neutronVPNIKEPolicyInterfaceRegistration != null) {
+ registrations.add(neutronVPNIKEPolicyInterfaceRegistration);
+ }
+
+ NeutronVPNIPSECPolicyInterface neutronVPNIPSECPolicyInterface = new NeutronVPNIPSECPolicyInterface(providerContext);
+ ServiceRegistration<INeutronVPNIPSECPolicyCRUD> neutronVPNIPSECPolicyInterfaceRegistration = context.registerService(INeutronVPNIPSECPolicyCRUD.class, neutronVPNIPSECPolicyInterface, null);
+ if(neutronVPNIPSECPolicyInterfaceRegistration != null) {
+ registrations.add(neutronVPNIPSECPolicyInterfaceRegistration);
+ }
+
NeutronVPNIPSECSiteConnectionsInterface neutronVPNIPSECSiteConnectionsInterface = new NeutronVPNIPSECSiteConnectionsInterface(providerContext);
ServiceRegistration<INeutronVPNIPSECSiteConnectionsCRUD> neutronVPNIPSECSiteConnectionsInterfaceRegistration = context.registerService(INeutronVPNIPSECSiteConnectionsCRUD.class, neutronVPNIPSECSiteConnectionsInterface, null);
if (neutronVPNIPSECSiteConnectionsInterfaceRegistration != null) {
--- /dev/null
+/*
+ * Copyright IBM Corporation, 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.transcriber;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.neutron.spi.INeutronVPNIPSECPolicyCRUD;
+import org.opendaylight.neutron.spi.NeutronVPNIPSECPolicy;
+import org.opendaylight.neutron.spi.NeutronVPNLifetime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.vpnaas.rev141002.ipsecpolicy.attrs.LifetimeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.vpnaas.rev141002.vpnaas.attributes.IpsecPolicies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.vpnaas.rev141002.vpnaas.attributes.ipsec.policies.IpsecPolicy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.vpnaas.rev141002.vpnaas.attributes.ipsec.policies.IpsecPolicyBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronVPNIPSECPolicyInterface extends AbstractNeutronInterface<IpsecPolicy, NeutronVPNIPSECPolicy> implements INeutronVPNIPSECPolicyCRUD {
+ private static final Logger logger = LoggerFactory.getLogger(NeutronVPNIPSECPolicyInterface.class);
+ private ConcurrentMap<String, NeutronVPNIPSECPolicy> meteringLabelRuleDB = new ConcurrentHashMap<String, NeutronVPNIPSECPolicy>();
+
+
+ NeutronVPNIPSECPolicyInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+
+ // this method uses reflection to update an object from it's delta.
+
+ private boolean overwrite(Object target, Object delta) {
+ Method[] methods = target.getClass().getMethods();
+
+ for(Method toMethod: methods){
+ if(toMethod.getDeclaringClass().equals(target.getClass())
+ && toMethod.getName().startsWith("set")){
+
+ String toName = toMethod.getName();
+ String fromName = toName.replace("set", "get");
+
+ try {
+ Method fromMethod = delta.getClass().getMethod(fromName);
+ Object value = fromMethod.invoke(delta, (Object[])null);
+ if(value != null){
+ toMethod.invoke(target, value);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ // IfNBVPNIPSECPolicyCRUD methods
+
+ @Override
+ public boolean neutronVPNIPSECPolicyExists(String uuid) {
+ return meteringLabelRuleDB.containsKey(uuid);
+ }
+
+ @Override
+ public NeutronVPNIPSECPolicy getNeutronVPNIPSECPolicy(String uuid) {
+ if (!neutronVPNIPSECPolicyExists(uuid)) {
+ return null;
+ }
+ return meteringLabelRuleDB.get(uuid);
+ }
+
+ @Override
+ public List<NeutronVPNIPSECPolicy> getAllNeutronVPNIPSECPolicies() {
+ Set<NeutronVPNIPSECPolicy> allVPNIPSECPolicies = new HashSet<NeutronVPNIPSECPolicy>();
+ for (Entry<String, NeutronVPNIPSECPolicy> entry : meteringLabelRuleDB.entrySet()) {
+ NeutronVPNIPSECPolicy meteringLabelRule = entry.getValue();
+ allVPNIPSECPolicies.add(meteringLabelRule);
+ }
+ logger.debug("Exiting getAllVPNIPSECPolicies, Found {} OpenStackVPNIPSECPolicies", allVPNIPSECPolicies.size());
+ List<NeutronVPNIPSECPolicy> ans = new ArrayList<NeutronVPNIPSECPolicy>();
+ ans.addAll(allVPNIPSECPolicies);
+ return ans;
+ }
+
+ @Override
+ public boolean addNeutronVPNIPSECPolicy(NeutronVPNIPSECPolicy input) {
+ if (neutronVPNIPSECPolicyExists(input.getID())) {
+ return false;
+ }
+ meteringLabelRuleDB.putIfAbsent(input.getID(), input);
+ addMd(input);
+ //TODO: add code to find INeutronVPNIPSECPolicyAware services and call newtorkCreated on them
+ return true;
+ }
+
+ @Override
+ public boolean removeNeutronVPNIPSECPolicy(String uuid) {
+ if (!neutronVPNIPSECPolicyExists(uuid)) {
+ return false;
+ }
+ meteringLabelRuleDB.remove(uuid);
+ removeMd(toMd(uuid));
+ //TODO: add code to find INeutronVPNIPSECPolicyAware services and call newtorkDeleted on them
+ return true;
+ }
+
+ @Override
+ public boolean updateNeutronVPNIPSECPolicy(String uuid, NeutronVPNIPSECPolicy delta) {
+ if (!neutronVPNIPSECPolicyExists(uuid)) {
+ return false;
+ }
+ NeutronVPNIPSECPolicy target = meteringLabelRuleDB.get(uuid);
+ boolean rc = overwrite(target, delta);
+ if (rc) {
+ updateMd(meteringLabelRuleDB.get(uuid));
+ }
+ return rc;
+ }
+
+ @Override
+ public boolean neutronVPNIPSECPolicyInUse(String netUUID) {
+ if (!neutronVPNIPSECPolicyExists(netUUID)) {
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
+ protected IpsecPolicy toMd(NeutronVPNIPSECPolicy ipsecPolicy) {
+ IpsecPolicyBuilder ipsecPolicyBuilder = new IpsecPolicyBuilder();
+ if (ipsecPolicy.getName() != null) {
+ ipsecPolicyBuilder.setName(ipsecPolicy.getName());
+ }
+ if (ipsecPolicy.getTenantID() != null) {
+ ipsecPolicyBuilder.setTenantId(toUuid(ipsecPolicy.getTenantID()));
+ }
+ if (ipsecPolicy.getDescription() != null) {
+ ipsecPolicyBuilder.setDescr(ipsecPolicy.getDescription());
+ }
+ if (ipsecPolicy.getAuthAlgorithm() != null) {
+ ipsecPolicyBuilder.setAuthAlgorithm(ipsecPolicy.getAuthAlgorithm());
+ }
+ if (ipsecPolicy.getEncryptionAlgorithm() != null) {
+ ipsecPolicyBuilder.setEncryptionAlgorithm(ipsecPolicy.getEncryptionAlgorithm());
+ }
+ if (ipsecPolicy.getTransformProtocol() != null) {
+ ipsecPolicyBuilder.setTransformProtocol(ipsecPolicy.getTransformProtocol());
+ }
+ if (ipsecPolicy.getEncapsulationMode() != null) {
+ ipsecPolicyBuilder.setEncapsulationMode(ipsecPolicy.getEncapsulationMode());
+ }
+ if (ipsecPolicy.getPerfectForwardSecrecy() != null) {
+ ipsecPolicyBuilder.setPfs(ipsecPolicy.getPerfectForwardSecrecy());
+ }
+ if (ipsecPolicy.getLifetime() !=null) {
+ NeutronVPNLifetime vpnLifetime = ipsecPolicy.getLifetime();
+ LifetimeBuilder lifetimeBuilder = new LifetimeBuilder();
+ lifetimeBuilder.setUnits(vpnLifetime.getUnits());
+ lifetimeBuilder.setValue(vpnLifetime.getValue());
+ ipsecPolicyBuilder.setLifetime(lifetimeBuilder.build());
+ }
+ if (ipsecPolicy.getID() != null) {
+ ipsecPolicyBuilder.setUuid(toUuid(ipsecPolicy.getID()));
+ } else {
+ logger.warn("Attempting to write neutron vpnIPSECPolicy without UUID");
+ }
+ return ipsecPolicyBuilder.build();
+ }
+
+
+ @Override
+ protected InstanceIdentifier<IpsecPolicy> createInstanceIdentifier(IpsecPolicy ipsecPolicy) {
+ return InstanceIdentifier.create(IpsecPolicies.class).child(IpsecPolicy.class, ipsecPolicy.getKey());
+ }
+
+
+ @Override
+ protected IpsecPolicy toMd(String uuid) {
+ IpsecPolicyBuilder ipsecPolicyBuilder = new IpsecPolicyBuilder();
+ ipsecPolicyBuilder.setUuid(toUuid(uuid));
+ return ipsecPolicyBuilder.build();
+ }
+}