Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
add Neutron (fully working & tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Oct 20, 2018
1 parent 8935f54 commit aa14397
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 47 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
<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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -40,6 +41,9 @@ protected void configure() {
// 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());

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/opendaylight/infrautils/web/WebWiring.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) -> { });
}
}
133 changes: 133 additions & 0 deletions src/main/java/org/opendaylight/neutron/simple/NeutronModule.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
19 changes: 0 additions & 19 deletions src/main/java/org/opendaylight/neutron/simple/NeutronWiring.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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);
}
}

This file was deleted.

0 comments on commit aa14397

Please sign in to comment.