From 97c4ee9c9c2984724cb36f8c99fe9a080de7c137 Mon Sep 17 00:00:00 2001 From: Andre Fredette Date: Mon, 21 Dec 2015 16:53:10 -0500 Subject: [PATCH] Framework for netvirt model (Part 1). The structure planned is as follows: /ovsdb/netvirt /ovsdb/netvirt/api /ovsdb/netvirt/artifacts /ovsdb/netvirt/features /ovsdb/netvirt/impl /ovsdb/netvirt/karaf /ovsdb/netvirt/it /ovsdb/netvirt/renderers /ovsdb/netvirt/renderers/hwgw /ovsdb/netvirt/renderers/neutron /ovsdb/netvirt/renderers/ovs This patch contains the "netvirt" directory. Change-Id: I03ba77273f6193566df63795230db7bd4e20b2e7 Signed-off-by: Andre Fredette --- netvirt/api/pom.xml | 23 ++++ netvirt/api/src/main/yang/netvirt.yang | 9 ++ netvirt/artifacts/pom.xml | 46 ++++++++ netvirt/features/pom.xml | 107 ++++++++++++++++++ .../features/src/main/features/features.xml | 36 ++++++ netvirt/impl/pom.xml | 43 +++++++ .../impl/src/main/config/default-config.xml | 30 +++++ .../ovsdb/netvirt/impl/NetvirtProvider.java | 29 +++++ .../netvirt/impl/rev141210/NetvirtModule.java | 33 ++++++ .../impl/rev141210/NetvirtModuleFactory.java | 20 ++++ netvirt/impl/src/main/yang/netvirt-impl.yang | 35 ++++++ .../netvirt/impl/NetvirtProviderTest.java | 33 ++++++ .../rev141210/NetvirtModuleFactoryTest.java | 18 +++ .../impl/rev141210/NetvirtModuleTest.java | 54 +++++++++ netvirt/karaf/pom.xml | 73 ++++++++++++ netvirt/pom.xml | 59 ++++++++++ pom.xml | 3 +- 17 files changed, 650 insertions(+), 1 deletion(-) create mode 100644 netvirt/api/pom.xml create mode 100644 netvirt/api/src/main/yang/netvirt.yang create mode 100644 netvirt/artifacts/pom.xml create mode 100644 netvirt/features/pom.xml create mode 100644 netvirt/features/src/main/features/features.xml create mode 100644 netvirt/impl/pom.xml create mode 100644 netvirt/impl/src/main/config/default-config.xml create mode 100644 netvirt/impl/src/main/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProvider.java create mode 100644 netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModule.java create mode 100644 netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactory.java create mode 100644 netvirt/impl/src/main/yang/netvirt-impl.yang create mode 100644 netvirt/impl/src/test/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProviderTest.java create mode 100644 netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactoryTest.java create mode 100644 netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleTest.java create mode 100644 netvirt/karaf/pom.xml create mode 100644 netvirt/pom.xml diff --git a/netvirt/api/pom.xml b/netvirt/api/pom.xml new file mode 100644 index 000000000..a5388fcb6 --- /dev/null +++ b/netvirt/api/pom.xml @@ -0,0 +1,23 @@ + + + + + org.opendaylight.mdsal + binding-parent + 0.8.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.ovsdb + netvirt-api + 1.2.1-SNAPSHOT + bundle + + diff --git a/netvirt/api/src/main/yang/netvirt.yang b/netvirt/api/src/main/yang/netvirt.yang new file mode 100644 index 000000000..df5214289 --- /dev/null +++ b/netvirt/api/src/main/yang/netvirt.yang @@ -0,0 +1,9 @@ +module netvirt { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:netvirt"; + prefix "netvirt"; + + revision "2015-01-05" { + description "Initial revision of netvirt model"; + } +} diff --git a/netvirt/artifacts/pom.xml b/netvirt/artifacts/pom.xml new file mode 100644 index 000000000..6017493f0 --- /dev/null +++ b/netvirt/artifacts/pom.xml @@ -0,0 +1,46 @@ + + + + + + + org.opendaylight.odlparent + odlparent-lite + 1.6.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.ovsdb + netvirt-artifacts + 1.2.1-SNAPSHOT + pom + + + + + ${project.groupId} + netvirt-api + ${project.version} + + + ${project.groupId} + netvirt-impl + ${project.version} + + + ${project.groupId} + netvirt-features + ${project.version} + features + xml + + + + diff --git a/netvirt/features/pom.xml b/netvirt/features/pom.xml new file mode 100644 index 000000000..1e2f8612b --- /dev/null +++ b/netvirt/features/pom.xml @@ -0,0 +1,107 @@ + + + + + org.opendaylight.odlparent + features-parent + 1.6.0-SNAPSHOT + + + + org.opendaylight.ovsdb + netvirt-features + 1.2.1-SNAPSHOT + ${project.artifactId} + 4.0.0 + + 3.1.1 + + + + etc/opendaylight/karaf + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT + + + + + + org.opendaylight.yangtools + yangtools-artifacts + ${yangtools.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + pom + import + + + org.opendaylight.netconf + restconf-artifacts + ${restconf.version} + pom + import + + + + + + org.opendaylight.yangtools + features-yangtools + features + ${yangtools.version} + xml + runtime + + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} + features + xml + runtime + + + org.opendaylight.netconf + features-restconf + features + ${restconf.version} + xml + runtime + + + org.opendaylight.controller + features-mdsal + features + xml + + + ${project.groupId} + netvirt-impl + ${project.version} + + + ${project.groupId} + netvirt-impl + ${project.version} + xml + config + + + ${project.groupId} + netvirt-api + ${project.version} + + + diff --git a/netvirt/features/src/main/features/features.xml b/netvirt/features/src/main/features/features.xml new file mode 100644 index 000000000..2d095e8f6 --- /dev/null +++ b/netvirt/features/src/main/features/features.xml @@ -0,0 +1,36 @@ + + + + + mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features + mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features + mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features + + odl-mdsal-models + mvn:org.opendaylight.ovsdb/netvirt-api/{{VERSION}} + + + odl-mdsal-broker + odl-netvirt-api + mvn:org.opendaylight.ovsdb/netvirt-impl/{{VERSION}} + mvn:org.opendaylight.ovsdb/netvirt-impl/{{VERSION}}/xml/config + + + odl-netvirt + odl-restconf + + + odl-netvirt-rest + odl-mdsal-apidocs + odl-mdsal-xsql + + + diff --git a/netvirt/impl/pom.xml b/netvirt/impl/pom.xml new file mode 100644 index 000000000..34376badb --- /dev/null +++ b/netvirt/impl/pom.xml @@ -0,0 +1,43 @@ + + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.ovsdb + netvirt-impl + 1.2.1-SNAPSHOT + bundle + + + ${project.groupId} + netvirt-api + ${project.version} + + + + + junit + junit + test + + + + org.mockito + mockito-all + test + + + + diff --git a/netvirt/impl/src/main/config/default-config.xml b/netvirt/impl/src/main/config/default-config.xml new file mode 100644 index 000000000..530a184e7 --- /dev/null +++ b/netvirt/impl/src/main/config/default-config.xml @@ -0,0 +1,30 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:netvirt:impl?module=netvirt-impl&revision=2014-12-10 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 + + + + + + + prefix:netvirt + netvirt-default + + binding:binding-broker-osgi-registry + binding-osgi-broker + + + + + + diff --git a/netvirt/impl/src/main/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProvider.java b/netvirt/impl/src/main/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProvider.java new file mode 100644 index 000000000..33dffcd76 --- /dev/null +++ b/netvirt/impl/src/main/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProvider.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 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.impl; + +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 NetvirtProvider implements BindingAwareProvider, AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(NetvirtProvider.class); + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("NetvirtProvider Session Initiated"); + } + + @Override + public void close() throws Exception { + LOG.info("NetvirtProvider Closed"); + } + +} diff --git a/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModule.java b/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModule.java new file mode 100644 index 000000000..ba8e18eaa --- /dev/null +++ b/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModule.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 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.impl.rev141210; + +import org.opendaylight.ovsdb.netvirt.impl.NetvirtProvider; + +public class NetvirtModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.impl.rev141210.AbstractNetvirtModule { + public NetvirtModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NetvirtModule(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.impl.rev141210.NetvirtModule 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() { + NetvirtProvider provider = new NetvirtProvider(); + getBrokerDependency().registerProvider(provider); + return provider; + } + +} diff --git a/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactory.java b/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactory.java new file mode 100644 index 000000000..af411a16a --- /dev/null +++ b/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactory.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2015 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: netvirt yang module local name: netvirt +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Jan 02 13:49:24 CST 2015 +* +* 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.impl.rev141210; +public class NetvirtModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.impl.rev141210.AbstractNetvirtModuleFactory { + +} diff --git a/netvirt/impl/src/main/yang/netvirt-impl.yang b/netvirt/impl/src/main/yang/netvirt-impl.yang new file mode 100644 index 000000000..7fc17aeb5 --- /dev/null +++ b/netvirt/impl/src/main/yang/netvirt-impl.yang @@ -0,0 +1,35 @@ +module netvirt-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:netvirt:impl"; + prefix "netvirt-impl"; + + 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 project"; + + revision "2014-12-10" { + description + "Initial revision"; + } + + identity netvirt { + base config:module-type; + config:java-name-prefix Netvirt; + } + + augment "/config:modules/config:module/config:configuration" { + case netvirt { + when "/config:modules/config:module/config:type = 'netvirt'"; + container broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-broker-osgi-registry; + } + } + } + } + } +} diff --git a/netvirt/impl/src/test/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProviderTest.java b/netvirt/impl/src/test/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProviderTest.java new file mode 100644 index 000000000..0d2be0721 --- /dev/null +++ b/netvirt/impl/src/test/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProviderTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 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.impl; + +import org.junit.Test; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; + +import static org.mockito.Mockito.mock; + +public class NetvirtProviderTest { + @Test + public void testOnSessionInitiated() { + NetvirtProvider provider = new NetvirtProvider(); + + // ensure no exceptions + // currently this method is empty + provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class)); + } + + @Test + public void testClose() throws Exception { + NetvirtProvider provider = new NetvirtProvider(); + + // ensure no exceptions + // currently this method is empty + provider.close(); + } +} diff --git a/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactoryTest.java b/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactoryTest.java new file mode 100644 index 000000000..c46ffdf10 --- /dev/null +++ b/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactoryTest.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2015 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.impl.rev141210; + +import org.junit.Test; + +public class NetvirtModuleFactoryTest { + @Test + public void testFactoryConstructor() { + // ensure no exceptions on construction + new NetvirtModuleFactory(); + } +} diff --git a/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleTest.java b/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleTest.java new file mode 100644 index 000000000..cec1710f1 --- /dev/null +++ b/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015 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.impl.rev141210; + +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.impl.NetvirtProvider; + +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 NetvirtModuleTest { + @Test + public void testCustomValidation() { + NetvirtModule module = new NetvirtModule(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 + NetvirtModule module = new NetvirtModule(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((NetvirtProvider)closeable); + + // ensure no exceptions on close + closeable.close(); + } +} diff --git a/netvirt/karaf/pom.xml b/netvirt/karaf/pom.xml new file mode 100644 index 000000000..f5d90d4cf --- /dev/null +++ b/netvirt/karaf/pom.xml @@ -0,0 +1,73 @@ + + + + + org.opendaylight.controller + karaf-parent + 1.6.0-SNAPSHOT + + + 4.0.0 + org.opendaylight.ovsdb + netvirt-karaf + 1.2.1-SNAPSHOT + ${project.artifactId} + + 3.1.1 + + + odl-netvirt-ui + + + + + ${project.groupId} + netvirt-artifacts + ${project.version} + pom + import + + + + + + + org.apache.karaf.features + framework + kar + + + + ${project.groupId} + netvirt-features + features + xml + runtime + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + diff --git a/netvirt/pom.xml b/netvirt/pom.xml new file mode 100644 index 000000000..ca352e165 --- /dev/null +++ b/netvirt/pom.xml @@ -0,0 +1,59 @@ + + + + + + org.opendaylight.odlparent + odlparent-lite + 1.6.0-SNAPSHOT + + + + org.opendaylight.ovsdb + netvirt-aggregator + 1.2.1-SNAPSHOT + netvirt + pom + 4.0.0 + + 3.1.1 + + + api + impl + karaf + features + artifacts + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + + + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + HEAD + https://wiki.opendaylight.org/view/OVSDB_Integration:Main + + diff --git a/pom.xml b/pom.xml index d86f738dd..24bffdc9d 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html utils ovsdb-ui hwvtepsouthbound + netvirt @@ -86,4 +87,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - + \ No newline at end of file -- 2.36.6