add Neutron (fully working & tested)
authorMichael Vorburger <mike@vorburger.ch>
Fri, 12 Oct 2018 14:18:29 +0000 (16:18 +0200)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:37:31 +0000 (01:37 +0200)
Signed-off-by: Michael Vorburger <mike@vorburger.ch>
pom.xml
src/main/java/org/opendaylight/genius/simple/GeniusWiring.java
src/main/java/org/opendaylight/infrautils/web/WebWiring.java
src/main/java/org/opendaylight/neutron/simple/NeutronModule.java [new file with mode: 0644]
src/main/java/org/opendaylight/neutron/simple/NeutronWiring.java [deleted file]
src/test/java/org/opendaylight/neutron/simple/test/NeutronModuleTest.java [new file with mode: 0644]
src/test/java/org/opendaylight/neutron/simple/test/NeutronSimpleDistributionTest.java [deleted file]

diff --git a/pom.xml b/pom.xml
index 4e2141e6d35bef6e96c85400a8018ee147e87a14..0486da4ce080aaba205222a482d1cf74e3fe2c6b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <type>pom</type>
         <scope>import</scope>
       </dependency>
+      <dependency>
+        <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
+        <artifactId>jersey-guava</artifactId>
+        <!-- TODO Figure out and clean up why we need this.. without it, you hit:
+             java.lang.NoSuchMethodError: jersey.repackaged.com.google.common.collect.Iterables.concat(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/lang/Iterable; -->
+        <version>2.8</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
index 0b36c8e3f3705aad2955f27d71f4b1ce546485f3..0b6a4d4c4113e07180d1ae6419cf423ffc6e164b 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
 import org.opendaylight.infrautils.simple.InfraUtilsWiring;
 import org.opendaylight.mdsal.simple.MdsalWiring;
+import org.opendaylight.neutron.simple.NeutronModule;
 import org.opendaylight.openflowplugin.simple.OpenFlowPluginWiring;
 import org.opendaylight.serviceutils.simple.ServiceUtilsWiring;
 import org.ops4j.pax.cdi.api.OsgiService;
@@ -40,6 +41,9 @@ public class GeniusWiring extends AbstractModule {
         // TODO write real DaeximWiring, and replace this line with an install(new DaeximWiring());
         bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {});
 
+        // Neutron
+        install(new NeutronModule());
+
         // OpenFlowPlugin
         install(new OpenFlowPluginWiring());
 
index 2cac5beba35a1a6a3c2e9d1d5a8a768599c1673f..adaffada0e0f0a558191e19cc75a6a129aa21b78 100644 (file)
@@ -8,8 +8,11 @@
 package org.opendaylight.infrautils.web;
 
 import com.google.inject.AbstractModule;
+import org.opendaylight.aaa.web.WebContextSecurer;
 import org.opendaylight.aaa.web.WebServer;
 import org.opendaylight.aaa.web.jetty.JettyWebServer;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+import org.opendaylight.aaa.web.servlet.jersey2.JerseyServletSupport;
 
 /**
  * Wiring for a web server.
@@ -22,5 +25,11 @@ public class WebWiring extends AbstractModule {
     protected void configure() {
         // TODO read port from a -D parameter or configuration file instead of hard-coding
         bind(WebServer.class).toInstance(new JettyWebServer(8181));
+
+        // JSX-RS
+        bind(ServletSupport.class).to(JerseyServletSupport.class);
+
+        // TODO replace this NOOP WebContextSecurer with one with a fixed uid/pwd for HTTP BASIC (and ditch AAA)
+        bind(WebContextSecurer.class).toInstance((webContextBuilder, urlPatterns) -> { });
     }
 }
diff --git a/src/main/java/org/opendaylight/neutron/simple/NeutronModule.java b/src/main/java/org/opendaylight/neutron/simple/NeutronModule.java
new file mode 100644 (file)
index 0000000..b6ee3b2
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2017 Red Hat, Inc. 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.simple;
+
+import com.google.inject.AbstractModule;
+import org.opendaylight.neutron.northbound.api.WebInitializer;
+import org.opendaylight.neutron.spi.INeutronBgpvpnCRUD;
+import org.opendaylight.neutron.spi.INeutronFirewallCRUD;
+import org.opendaylight.neutron.spi.INeutronFirewallPolicyCRUD;
+import org.opendaylight.neutron.spi.INeutronFirewallRuleCRUD;
+import org.opendaylight.neutron.spi.INeutronFloatingIpCRUD;
+import org.opendaylight.neutron.spi.INeutronL2gatewayCRUD;
+import org.opendaylight.neutron.spi.INeutronL2gatewayConnectionCRUD;
+import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
+import org.opendaylight.neutron.spi.INeutronLoadBalancerHealthMonitorCRUD;
+import org.opendaylight.neutron.spi.INeutronLoadBalancerListenerCRUD;
+import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
+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.INeutronQosPolicyCRUD;
+import org.opendaylight.neutron.spi.INeutronRouterCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCPortChainCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCPortPairCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCPortPairGroupCRUD;
+import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
+import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
+import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
+import org.opendaylight.neutron.spi.INeutronTapFlowCRUD;
+import org.opendaylight.neutron.spi.INeutronTapServiceCRUD;
+import org.opendaylight.neutron.spi.INeutronTrunkCRUD;
+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.opendaylight.neutron.transcriber.NeutronBgpvpnInterface;
+import org.opendaylight.neutron.transcriber.NeutronFirewallInterface;
+import org.opendaylight.neutron.transcriber.NeutronFirewallPolicyInterface;
+import org.opendaylight.neutron.transcriber.NeutronFirewallRuleInterface;
+import org.opendaylight.neutron.transcriber.NeutronFloatingIpInterface;
+import org.opendaylight.neutron.transcriber.NeutronL2gatewayConnectionInterface;
+import org.opendaylight.neutron.transcriber.NeutronL2gatewayInterface;
+import org.opendaylight.neutron.transcriber.NeutronLoadBalancerHealthMonitorInterface;
+import org.opendaylight.neutron.transcriber.NeutronLoadBalancerInterface;
+import org.opendaylight.neutron.transcriber.NeutronLoadBalancerListenerInterface;
+import org.opendaylight.neutron.transcriber.NeutronLoadBalancerPoolInterface;
+import org.opendaylight.neutron.transcriber.NeutronMeteringLabelInterface;
+import org.opendaylight.neutron.transcriber.NeutronMeteringLabelRuleInterface;
+import org.opendaylight.neutron.transcriber.NeutronNetworkInterface;
+import org.opendaylight.neutron.transcriber.NeutronPortInterface;
+import org.opendaylight.neutron.transcriber.NeutronQosPolicyInterface;
+import org.opendaylight.neutron.transcriber.NeutronRouterInterface;
+import org.opendaylight.neutron.transcriber.NeutronSFCFlowClassifierInterface;
+import org.opendaylight.neutron.transcriber.NeutronSFCPortChainInterface;
+import org.opendaylight.neutron.transcriber.NeutronSFCPortPairGroupInterface;
+import org.opendaylight.neutron.transcriber.NeutronSFCPortPairInterface;
+import org.opendaylight.neutron.transcriber.NeutronSecurityGroupInterface;
+import org.opendaylight.neutron.transcriber.NeutronSecurityRuleInterface;
+import org.opendaylight.neutron.transcriber.NeutronSubnetInterface;
+import org.opendaylight.neutron.transcriber.NeutronTapFlowInterface;
+import org.opendaylight.neutron.transcriber.NeutronTapServiceInterface;
+import org.opendaylight.neutron.transcriber.NeutronTrunkInterface;
+import org.opendaylight.neutron.transcriber.NeutronVpnIkePolicyInterface;
+import org.opendaylight.neutron.transcriber.NeutronVpnIpSecPolicyInterface;
+import org.opendaylight.neutron.transcriber.NeutronVpnIpSecSiteConnectionsInterface;
+import org.opendaylight.neutron.transcriber.NeutronVpnServiceInterface;
+import org.ops4j.pax.cdi.api.OsgiService;
+
+/**
+ * Guice module for Neutron.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class NeutronModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(WebInitializer.class);
+
+        // The following is currently copy/pasted from
+        // org.opendaylight.neutron.e2etest.NeutronTestWiring
+        // but likely will get replaced with automated classpath scanning anyway later
+        // (strangely though it needs .annotatedWith(OsgiService.class) everywhere, only here)
+        bind(INeutronNetworkCRUD.class).annotatedWith(OsgiService.class).to(NeutronNetworkInterface.class);
+        bind(INeutronSubnetCRUD.class).annotatedWith(OsgiService.class).to(NeutronSubnetInterface.class);
+        bind(INeutronPortCRUD.class).annotatedWith(OsgiService.class).to(NeutronPortInterface.class);
+        bind(INeutronRouterCRUD.class).annotatedWith(OsgiService.class).to(NeutronRouterInterface.class);
+        bind(INeutronFloatingIpCRUD.class).annotatedWith(OsgiService.class).to(NeutronFloatingIpInterface.class);
+        bind(INeutronSecurityGroupCRUD.class).annotatedWith(OsgiService.class).to(NeutronSecurityGroupInterface.class);
+        bind(INeutronSecurityRuleCRUD.class).annotatedWith(OsgiService.class).to(NeutronSecurityRuleInterface.class);
+        bind(INeutronFirewallCRUD.class).annotatedWith(OsgiService.class).to(NeutronFirewallInterface.class);
+        bind(INeutronFirewallPolicyCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronFirewallPolicyInterface.class);
+        bind(INeutronFirewallRuleCRUD.class).annotatedWith(OsgiService.class).to(NeutronFirewallRuleInterface.class);
+        bind(INeutronLoadBalancerCRUD.class).annotatedWith(OsgiService.class).to(NeutronLoadBalancerInterface.class);
+        bind(INeutronLoadBalancerListenerCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronLoadBalancerListenerInterface.class);
+        bind(INeutronLoadBalancerPoolCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronLoadBalancerPoolInterface.class);
+        bind(INeutronBgpvpnCRUD.class).annotatedWith(OsgiService.class).to(NeutronBgpvpnInterface.class);
+        bind(INeutronL2gatewayCRUD.class).annotatedWith(OsgiService.class).to(NeutronL2gatewayInterface.class);
+        bind(INeutronL2gatewayConnectionCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronL2gatewayConnectionInterface.class);
+        bind(INeutronLoadBalancerHealthMonitorCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronLoadBalancerHealthMonitorInterface.class);
+        bind(INeutronMeteringLabelCRUD.class).annotatedWith(OsgiService.class).to(NeutronMeteringLabelInterface.class);
+        bind(INeutronMeteringLabelRuleCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronMeteringLabelRuleInterface.class);
+        bind(INeutronVpnServiceCRUD.class).annotatedWith(OsgiService.class).to(NeutronVpnServiceInterface.class);
+        bind(INeutronVpnIkePolicyCRUD.class).annotatedWith(OsgiService.class).to(NeutronVpnIkePolicyInterface.class);
+        bind(INeutronVpnIpSecPolicyCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronVpnIpSecPolicyInterface.class);
+        bind(INeutronSFCFlowClassifierCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronSFCFlowClassifierInterface.class);
+        bind(INeutronSFCPortChainCRUD.class).annotatedWith(OsgiService.class).to(NeutronSFCPortChainInterface.class);
+        bind(INeutronSFCPortPairGroupCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronSFCPortPairGroupInterface.class);
+        bind(INeutronSFCPortPairCRUD.class).annotatedWith(OsgiService.class).to(NeutronSFCPortPairInterface.class);
+        bind(INeutronQosPolicyCRUD.class).annotatedWith(OsgiService.class).to(NeutronQosPolicyInterface.class);
+        bind(INeutronTrunkCRUD.class).annotatedWith(OsgiService.class).to(NeutronTrunkInterface.class);
+        bind(INeutronTapServiceCRUD.class).annotatedWith(OsgiService.class).to(NeutronTapServiceInterface.class);
+        bind(INeutronTapFlowCRUD.class).annotatedWith(OsgiService.class).to(NeutronTapFlowInterface.class);
+        bind(INeutronVpnIpSecSiteConnectionsCRUD.class).annotatedWith(OsgiService.class)
+                .to(NeutronVpnIpSecSiteConnectionsInterface.class);
+    }
+}
diff --git a/src/main/java/org/opendaylight/neutron/simple/NeutronWiring.java b/src/main/java/org/opendaylight/neutron/simple/NeutronWiring.java
deleted file mode 100644 (file)
index 45b3f7e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.simple;
-
-import com.google.inject.AbstractModule;
-
-public class NeutronWiring extends AbstractModule {
-
-    // TODO re-integrate this with the latest Neutron code based on the new Web API now in AAA
-
-    @Override
-    protected void configure() {
-    }
-}
diff --git a/src/test/java/org/opendaylight/neutron/simple/test/NeutronModuleTest.java b/src/test/java/org/opendaylight/neutron/simple/test/NeutronModuleTest.java
new file mode 100644 (file)
index 0000000..3499a9e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 Red Hat, Inc. 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.simple.test;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.opendaylight.infrautils.testutils.TestHttpClient.Method.GET;
+
+import java.io.IOException;
+import javax.inject.Inject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.opendaylight.aaa.web.WebServer;
+import org.opendaylight.controller.simple.ControllerWiring;
+import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
+import org.opendaylight.infrautils.testutils.TestHttpClient;
+import org.opendaylight.infrautils.web.WebWiring;
+import org.opendaylight.neutron.simple.NeutronModule;
+
+/**
+ * Neutron component test.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class NeutronModuleTest extends AbstractSimpleDistributionTest {
+
+    public @Rule GuiceRule2 guice = new GuiceRule2(
+            NeutronModule.class, ControllerWiring.class, WebWiring.class, AnnotationsModule.class);
+
+    @Inject WebServer webServer;
+    @Inject TestHttpClient http;
+
+    @Test public void testNeutron() throws IOException {
+        assertThat(http.responseCode(GET, "/controller/nb/v2/neutron/networks")).isEqualTo(200);
+    }
+}
diff --git a/src/test/java/org/opendaylight/neutron/simple/test/NeutronSimpleDistributionTest.java b/src/test/java/org/opendaylight/neutron/simple/test/NeutronSimpleDistributionTest.java
deleted file mode 100644 (file)
index ae74322..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.simple.test;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
-import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
-import org.opendaylight.infrautils.simple.ReadyWiring;
-import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
-import org.opendaylight.neutron.simple.NeutronWiring;
-
-/**
- * Netvirt full distribution component test.
- *
- * @author Michael Vorburger.ch
- */
-@Ignore // TODO re-integrate this with the latest Neutron code based on the new Web API now in AAA
-public class NeutronSimpleDistributionTest extends AbstractSimpleDistributionTest {
-
-    public @Rule GuiceRule2 guice = new GuiceRule2(
-            NeutronWiring.class, ReadyWiring.class, AnnotationsModule.class);
-}