Initial NetVirt Neutron renderer.
authorAndre Fredette <afredette@redhat.com>
Tue, 8 Mar 2016 21:03:21 +0000 (16:03 -0500)
committerAndre Fredette <afredette@redhat.com>
Wed, 9 Mar 2016 15:19:22 +0000 (10:19 -0500)
Change-Id: Iba4827b733d68d8c15148a61583a75d3ed9cb3a1
Signed-off-by: Andre Fredette <afredette@redhat.com>
netvirt/renderers/neutron/pom.xml [new file with mode: 0644]
netvirt/renderers/neutron/src/main/config/default-config.xml [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/yang/neutron.yang [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java [new file with mode: 0644]
netvirt/renderers/pom.xml

diff --git a/netvirt/renderers/neutron/pom.xml b/netvirt/renderers/neutron/pom.xml
new file mode 100644 (file)
index 0000000..95e93bb
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2016 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.ovsdb</groupId>
+  <artifactId>neutron</artifactId>
+  <version>1.3.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/netvirt/renderers/neutron/src/main/config/default-config.xml b/netvirt/renderers/neutron/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..4d91221
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2016 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
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:netvirt:neutron?module=neutron&amp;revision=2016-03-08</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:neutron">prefix:neutron</type>
+          <name>neutron-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java
new file mode 100644 (file)
index 0000000..4ad26a0
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 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.ovsdb.netvirt.renderers.neutron;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronProvider implements BindingAwareProvider, AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NeutronProvider.class);
+
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        LOG.info("NeutronProvider Session Initiated");
+    }
+
+    @Override
+    public void close() throws Exception {
+        LOG.info("NeutronProvider Closed");
+    }
+
+}
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java
new file mode 100644 (file)
index 0000000..874803e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+public class NeutronModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModule {
+    public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.NeutronModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        NeutronProvider provider = new NeutronProvider();
+        getBrokerDependency().registerProvider(provider);
+        return provider;
+    }
+
+}
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java
new file mode 100644 (file)
index 0000000..98cd54a
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2016 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
+ */
+/*
+* Generated file
+*
+* Generated from: yang module name: neutron yang module local name: neutron
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+public class NeutronModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModuleFactory {
+
+}
diff --git a/netvirt/renderers/neutron/src/main/yang/neutron.yang b/netvirt/renderers/neutron/src/main/yang/neutron.yang
new file mode 100644 (file)
index 0000000..63c0cd2
--- /dev/null
@@ -0,0 +1,35 @@
+module neutron {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:netvirt:neutron";
+    prefix "neutron";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for NetVirt Neutron renderer";
+
+    revision "2016-03-08" {
+        description
+            "Initial revision";
+    }
+
+    identity neutron {
+        base config:module-type;
+        config:java-name-prefix Neutron;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case neutron {
+            when "/config:modules/config:module/config:type = 'neutron'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java
new file mode 100644 (file)
index 0000000..722664b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 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.ovsdb.netvirt.renderers.neutron;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+
+import static org.mockito.Mockito.mock;
+
+public class NeutronProviderTest {
+    @Test
+    public void testOnSessionInitiated() {
+        NeutronProvider provider = new NeutronProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class));
+    }
+
+    @Test
+    public void testClose() throws Exception {
+        NeutronProvider provider = new NeutronProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.close();
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java
new file mode 100644 (file)
index 0000000..76bf797
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2016 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+
+public class NeutronModuleFactoryTest {
+    @Test
+    public void testFactoryConstructor() {
+        // ensure no exceptions on construction
+        new NeutronModuleFactory();
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java
new file mode 100644 (file)
index 0000000..1e5ca5e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+import javax.management.ObjectName;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class NeutronModuleTest {
+    @Test
+    public void testCustomValidation() {
+        NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
+
+        // ensure no exceptions on validation
+        // currently this method is empty
+        module.customValidation();
+    }
+
+    @Test
+    public void testCreateInstance() throws Exception {
+        // configure mocks
+        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
+        BindingAwareBroker broker = mock(BindingAwareBroker.class);
+        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+
+        // create instance of module with injected mocks
+        NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), dependencyResolver);
+
+        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+        AutoCloseable closeable = module.getInstance();
+
+        // verify that the module registered the returned provider with the broker
+        verify(broker).registerProvider((NeutronProvider)closeable);
+
+        // ensure no exceptions on close
+        closeable.close();
+    }
+}
index ebaeb6ebba1ff347a06d927c0a1a413e43703e51..7fa0a20362323517d642f9c7d86f13b89e5a8775 100644 (file)
@@ -24,6 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   </prerequisites>
   <modules>
     <module>hwgw</module>
+    <module>neutron</module>
   </modules>
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
   <build>