From: Sam Hague Date: Sun, 10 Jan 2016 13:06:26 +0000 (+0000) Subject: Merge "Bug 4911 - unbreak a55db97e8ce43aec9e2f3a3fe70f6bec3272195b" X-Git-Tag: release/beryllium-sr2~155 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=189a0d01065fd05dfa9e7156e6d47af9adeb3a7b;hp=a42e4a33f842fc40a0ca81d7250abc8bbe152514;p=netvirt.git Merge "Bug 4911 - unbreak a55db97e8ce43aec9e2f3a3fe70f6bec3272195b" --- diff --git a/features/pom.xml b/features/pom.xml index d5ee2402e6..e85dcea575 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -47,6 +47,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 1.6.0-SNAPSHOT 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT + 1.3.0-SNAPSHOT 0.6.0-SNAPSHOT 0.2.0-SNAPSHOT 0.8.0-SNAPSHOT @@ -79,6 +81,22 @@ and is available at http://www.eclipse.org/legal/epl-v10.html xml features + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} + features + xml + runtime + + + org.opendaylight.netconf + features-restconf + ${restconf.version} + features + xml + runtime + @@ -283,6 +301,23 @@ and is available at http://www.eclipse.org/legal/epl-v10.html xml features + + ${project.groupId} + netvirt-api + ${project.version} + + + ${project.groupId} + hwgw + ${project.version} + + + ${project.groupId} + hwvtepsouthbound-features + ${project.version} + xml + features + org.opendaylight.dlux diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index f8949f542f..466fecd578 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -9,6 +9,9 @@ mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features mvn:org.opendaylight.ovsdb/library-features/{{VERSION}}/xml/features mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features + mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features + mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features + mvn:org.opendaylight.ovsdb/hwvtepsouthbound-features/{{VERSION}}/xml/features @@ -49,4 +52,23 @@ odl-dlux-core mvn:org.opendaylight.ovsdb/ovsdb-ui-bundle/{{VERSION}} + + odl-mdsal-models + mvn:org.opendaylight.ovsdb/netvirt-api/{{VERSION}} + + + odl-netvirt-api + odl-restconf + + + odl-netvirt-rest + odl-mdsal-apidocs + odl-mdsal-xsql + + + odl-netvirt-api + odl-ovsdb-hwvtepsouthbound + mvn:org.opendaylight.ovsdb/hwgw/{{VERSION}} + + diff --git a/netvirt/api/src/main/yang/netvirt.yang b/netvirt/api/src/main/yang/netvirt.yang index df52142899..1571d6f761 100644 --- a/netvirt/api/src/main/yang/netvirt.yang +++ b/netvirt/api/src/main/yang/netvirt.yang @@ -3,7 +3,7 @@ module netvirt { namespace "urn:opendaylight:params:xml:ns:yang:netvirt"; prefix "netvirt"; - revision "2015-01-05" { + revision "2015-12-27" { description "Initial revision of netvirt model"; } } diff --git a/netvirt/artifacts/pom.xml b/netvirt/artifacts/pom.xml deleted file mode 100644 index 6017493f0f..0000000000 --- a/netvirt/artifacts/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - 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 deleted file mode 100644 index 1e2f8612be..0000000000 --- a/netvirt/features/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - 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 deleted file mode 100644 index 2d095e8f67..0000000000 --- a/netvirt/features/src/main/features/features.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - 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 deleted file mode 100644 index 34376badb1..0000000000 --- a/netvirt/impl/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 530a184e7f..0000000000 --- a/netvirt/impl/src/main/config/default-config.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 33dffcd762..0000000000 --- a/netvirt/impl/src/main/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 deleted file mode 100644 index ba8e18eaaf..0000000000 --- a/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModule.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 deleted file mode 100644 index af411a16a9..0000000000 --- a/netvirt/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7fc17aeb58..0000000000 --- a/netvirt/impl/src/main/yang/netvirt-impl.yang +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 0d2be07216..0000000000 --- a/netvirt/impl/src/test/java/org/opendaylight/ovsdb/netvirt/impl/NetvirtProviderTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 deleted file mode 100644 index c46ffdf108..0000000000 --- a/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleFactoryTest.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 deleted file mode 100644 index cec1710f1c..0000000000 --- a/netvirt/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev141210/NetvirtModuleTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 deleted file mode 100644 index f5d90d4cfb..0000000000 --- a/netvirt/karaf/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - 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 index d0c5e1cb63..b3411fc7aa 100644 --- a/netvirt/pom.xml +++ b/netvirt/pom.xml @@ -25,10 +25,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL api - impl - karaf - features - artifacts renderers diff --git a/netvirt/renderers/hwgw/src/main/config/default-config.xml b/netvirt/renderers/hwgw/src/main/config/default-config.xml index daf2badb71..09926d96a8 100644 --- a/netvirt/renderers/hwgw/src/main/config/default-config.xml +++ b/netvirt/renderers/hwgw/src/main/config/default-config.xml @@ -9,7 +9,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html --> - urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&revision=2014-12-10 + urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&revision=2015-12-27 urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 diff --git a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModule.java b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModule.java deleted file mode 100644 index eedab4a060..0000000000 --- a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModule.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev141210; -public class HwgwModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev141210.AbstractHwgwModule { - public HwgwModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public HwgwModule(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.hwgw.rev141210.HwgwModule 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() { - // TODO:implement - throw new java.lang.UnsupportedOperationException(); - } - -} diff --git a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModuleFactory.java b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModuleFactory.java deleted file mode 100644 index df2b6d4cc9..0000000000 --- a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev141210/HwgwModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: hwgw yang module local name: hwgw -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Tue Dec 22 22:54:15 EST 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.hwgw.rev141210; -public class HwgwModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev141210.AbstractHwgwModuleFactory { - -} diff --git a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModule.java b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModule.java similarity index 85% rename from netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModule.java rename to netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModule.java index 296b9f64b0..6834db2c73 100644 --- a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModule.java +++ b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModule.java @@ -5,16 +5,16 @@ * 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.hwgw.rev141210; +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227; import org.opendaylight.ovsdb.netvirt.renderers.hwgw.HwgwProvider; -public class HwgwModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev141210.AbstractHwgwModule { +public class HwgwModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227.AbstractHwgwModule { public HwgwModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public HwgwModule(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.hwgw.rev141210.HwgwModule oldModule, java.lang.AutoCloseable oldInstance) { + public HwgwModule(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.hwgw.rev151227.HwgwModule oldModule, java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } diff --git a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactory.java b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactory.java similarity index 88% rename from netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactory.java rename to netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactory.java index 93903e2978..fa1e856f70 100644 --- a/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactory.java +++ b/netvirt/renderers/hwgw/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactory.java @@ -14,7 +14,7 @@ * * 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.hwgw.rev141210; -public class HwgwModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev141210.AbstractHwgwModuleFactory { +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227; +public class HwgwModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227.AbstractHwgwModuleFactory { } diff --git a/netvirt/renderers/hwgw/src/main/yang/hwgw.yang b/netvirt/renderers/hwgw/src/main/yang/hwgw.yang index 41d098b260..22b2f503e3 100644 --- a/netvirt/renderers/hwgw/src/main/yang/hwgw.yang +++ b/netvirt/renderers/hwgw/src/main/yang/hwgw.yang @@ -9,7 +9,7 @@ module hwgw { description "Service definition for hwgw project"; - revision "2014-12-10" { + revision "2015-12-27" { description "Initial revision"; } diff --git a/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactoryTest.java b/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactoryTest.java similarity index 94% rename from netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactoryTest.java rename to netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactoryTest.java index 455852da9a..09e4f71020 100644 --- a/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleFactoryTest.java +++ b/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleFactoryTest.java @@ -5,7 +5,7 @@ * 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.hwgw.rev141210; +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227; import org.junit.Test; diff --git a/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleTest.java b/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleTest.java similarity index 98% rename from netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleTest.java rename to netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleTest.java index 0f76203dc6..ddce57b10f 100644 --- a/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwgw/rev141210/HwgwModuleTest.java +++ b/netvirt/renderers/hwgw/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/hwgw/rev151227/HwgwModuleTest.java @@ -5,7 +5,7 @@ * 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.hwgw.rev141210; +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.hwgw.rev151227; import org.junit.Test; import org.opendaylight.controller.config.api.DependencyResolver; diff --git a/openstack/net-virt-providers/src/main/config/default-config.xml b/openstack/net-virt-providers/src/main/config/default-config.xml index f748ee76a4..cdbbec28ac 100644 --- a/openstack/net-virt-providers/src/main/config/default-config.xml +++ b/openstack/net-virt-providers/src/main/config/default-config.xml @@ -17,6 +17,10 @@ binding:binding-broker-osgi-registry binding-osgi-broker + + ns:entity-ownership-service + entity-ownership-service + diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/NetvirtProvidersProvider.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/NetvirtProvidersProvider.java index e6037c09aa..86556f6d48 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/NetvirtProvidersProvider.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/NetvirtProvidersProvider.java @@ -8,26 +8,42 @@ package org.opendaylight.ovsdb.openstack.netvirt.providers; +import org.opendaylight.ovsdb.openstack.netvirt.api.Constants; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.common.api.clustering.Entity; +import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.atomic.AtomicBoolean; + /** * @author Sam Hague (shague@redhat.com) */ public class NetvirtProvidersProvider implements BindingAwareProvider, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NetvirtProvidersProvider.class); + private BundleContext bundleContext = null; private static DataBroker dataBroker = null; private ConfigActivator activator; private static ProviderContext providerContext = null; + private static EntityOwnershipService entityOwnershipService; + private ProviderEntityListener providerEntityListener = null; + private static AtomicBoolean hasProviderEntityOwnership = new AtomicBoolean(false); - public NetvirtProvidersProvider(BundleContext bundleContext) { + public NetvirtProvidersProvider(BundleContext bundleContext, EntityOwnershipService eos) { LOG.info("NetvirtProvidersProvider: bundleContext: {}", bundleContext); this.bundleContext = bundleContext; + entityOwnershipService = eos; } public static DataBroker getDataBroker() { @@ -38,10 +54,15 @@ public class NetvirtProvidersProvider implements BindingAwareProvider, AutoClose return providerContext; } + public static boolean isMasterProviderInstance() { + return hasProviderEntityOwnership.get(); + } + @Override public void close() throws Exception { LOG.info("NetvirtProvidersProvider closed"); activator.stop(bundleContext); + providerEntityListener.close(); } @Override @@ -55,5 +76,49 @@ public class NetvirtProvidersProvider implements BindingAwareProvider, AutoClose } catch (Exception e) { LOG.warn("Failed to start Netvirt: ", e); } + providerEntityListener = new ProviderEntityListener(this, entityOwnershipService); + } + + private void handleOwnershipChange(EntityOwnershipChange ownershipChange) { + if (ownershipChange.isOwner()) { + LOG.info("*This* instance of OVSDB netvirt provider is a MASTER instance"); + hasProviderEntityOwnership.set(true); + } else { + LOG.info("*This* instance of OVSDB netvirt provider is a SLAVE instance"); + hasProviderEntityOwnership.set(false); + } + } + + private class ProviderEntityListener implements EntityOwnershipListener { + private NetvirtProvidersProvider provider; + private EntityOwnershipListenerRegistration listenerRegistration; + private EntityOwnershipCandidateRegistration candidateRegistration; + + ProviderEntityListener(NetvirtProvidersProvider provider, + EntityOwnershipService entityOwnershipService) { + this.provider = provider; + this.listenerRegistration = + entityOwnershipService.registerListener(Constants.NETVIRT_OWNER_ENTITY_TYPE, this); + + //register instance entity to get the ownership of the netvirt provider + Entity instanceEntity = new Entity( + Constants.NETVIRT_OWNER_ENTITY_TYPE, Constants.NETVIRT_OWNER_ENTITY_TYPE); + try { + this.candidateRegistration = entityOwnershipService.registerCandidate(instanceEntity); + } catch (CandidateAlreadyRegisteredException e) { + LOG.warn("OVSDB Netvirt Provider instance entity {} was already " + + "registered for ownership", instanceEntity, e); + } + } + + public void close() { + this.listenerRegistration.close(); + this.candidateRegistration.close(); + } + + @Override + public void ownershipChanged(EntityOwnershipChange ownershipChange) { + provider.handleOwnershipChange(ownershipChange); + } } } diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java index 5a94eb972b..0727f3e0bf 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstance.java @@ -139,39 +139,43 @@ public abstract class AbstractServiceInstance { } protected void writeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) { - LOG.debug("writeFlow 3: flowBuilder: {}, nodeBuilder: {}", - flowBuilder.build(), nodeBuilder.build()); - WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); - LOG.debug("writeFlow: about to put nodePath for Flow {}, nodePath: {}", - flowBuilder.getFlowName(), createNodePath(nodeBuilder)); - modification.put(LogicalDatastoreType.CONFIGURATION, createNodePath(nodeBuilder), - nodeBuilder.build(), true /*createMissingParents*/); - LOG.debug("writeFlow: about to put Flow {}", flowBuilder.getFlowName()); - modification.put(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder), - flowBuilder.build(), true /*createMissingParents*/); - LOG.debug("writeFlow: about to submit Flow {}", flowBuilder.getFlowName()); - CheckedFuture commitFuture = modification.submit(); - LOG.debug("writeFlow: checking status of Flow {}", flowBuilder.getFlowName()); - try { - commitFuture.checkedGet(); // TODO: Make it async (See bug 1362) - LOG.debug("Transaction success for write of Flow {}", flowBuilder.getFlowName()); - } catch (Exception e) { - LOG.error(e.getMessage(), e); - modification.cancel(); + if (NetvirtProvidersProvider.isMasterProviderInstance()) { + LOG.debug("writeFlow 3: flowBuilder: {}, nodeBuilder: {}", + flowBuilder.build(), nodeBuilder.build()); + WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); + LOG.debug("writeFlow: about to put nodePath for Flow {}, nodePath: {}", + flowBuilder.getFlowName(), createNodePath(nodeBuilder)); + modification.put(LogicalDatastoreType.CONFIGURATION, createNodePath(nodeBuilder), + nodeBuilder.build(), true /*createMissingParents*/); + LOG.debug("writeFlow: about to put Flow {}", flowBuilder.getFlowName()); + modification.put(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder), + flowBuilder.build(), true /*createMissingParents*/); + LOG.debug("writeFlow: about to submit Flow {}", flowBuilder.getFlowName()); + CheckedFuture commitFuture = modification.submit(); + LOG.debug("writeFlow: checking status of Flow {}", flowBuilder.getFlowName()); + try { + commitFuture.checkedGet(); // TODO: Make it async (See bug 1362) + LOG.debug("Transaction success for write of Flow {}", flowBuilder.getFlowName()); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + modification.cancel(); + } } } protected void removeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) { - WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); - modification.delete(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder)); - - CheckedFuture commitFuture = modification.submit(); - try { - commitFuture.get(); // TODO: Make it async (See bug 1362) - LOG.debug("Transaction success for deletion of Flow {}", flowBuilder.getFlowName()); - } catch (Exception e) { - LOG.error(e.getMessage(), e); - modification.cancel(); + if (NetvirtProvidersProvider.isMasterProviderInstance()) { + WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); + modification.delete(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder)); + + CheckedFuture commitFuture = modification.submit(); + try { + commitFuture.get(); // TODO: Make it async (See bug 1362) + LOG.debug("Transaction success for deletion of Flow {}", flowBuilder.getFlowName()); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + modification.cancel(); + } } } diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java index 596ad714d1..c46211f46c 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java @@ -1559,56 +1559,62 @@ public class OF13Provider implements ConfigInterface, NetworkingProvider { } private void writeGroup(GroupBuilder groupBuilder, NodeBuilder nodeBuilder) { - ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); - InstanceIdentifier path1 = InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory - .rev130819.nodes.Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Group.class, - new GroupKey(groupBuilder.getGroupId())).build(); - modification.put(LogicalDatastoreType.CONFIGURATION, path1, groupBuilder.build(), true /*createMissingParents*/); - - CheckedFuture commitFuture = modification.submit(); - try { - commitFuture.get(); // TODO: Make it async (See bug 1362) - LOG.debug("Transaction success for write of Group " + groupBuilder.getGroupName()); - } catch (InterruptedException|ExecutionException e) { - LOG.error(e.getMessage(), e); + if (NetvirtProvidersProvider.isMasterProviderInstance()) { + ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); + InstanceIdentifier path1 = InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory + .rev130819.nodes.Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Group.class, + new GroupKey(groupBuilder.getGroupId())).build(); + modification.put(LogicalDatastoreType.CONFIGURATION, path1, groupBuilder.build(), true /*createMissingParents*/); + + CheckedFuture commitFuture = modification.submit(); + try { + commitFuture.get(); // TODO: Make it async (See bug 1362) + LOG.debug("Transaction success for write of Group " + groupBuilder.getGroupName()); + } catch (InterruptedException|ExecutionException e) { + LOG.error(e.getMessage(), e); + } } } private void removeGroup(GroupBuilder groupBuilder, NodeBuilder nodeBuilder) { - WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); - InstanceIdentifier path1 = InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory - .rev130819.nodes.Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Group.class, - new GroupKey(groupBuilder.getGroupId())).build(); - modification.delete(LogicalDatastoreType.CONFIGURATION, path1); - CheckedFuture commitFuture = modification.submit(); + if (NetvirtProvidersProvider.isMasterProviderInstance()) { + WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); + InstanceIdentifier path1 = InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory + .rev130819.nodes.Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Group.class, + new GroupKey(groupBuilder.getGroupId())).build(); + modification.delete(LogicalDatastoreType.CONFIGURATION, path1); + CheckedFuture commitFuture = modification.submit(); - try { - commitFuture.get(); // TODO: Make it async (See bug 1362) - LOG.debug("Transaction success for deletion of Group " + groupBuilder.getGroupName()); - } catch (InterruptedException|ExecutionException e) { - LOG.error(e.getMessage(), e); + try { + commitFuture.get(); // TODO: Make it async (See bug 1362) + LOG.debug("Transaction success for deletion of Group " + groupBuilder.getGroupName()); + } catch (InterruptedException|ExecutionException e) { + LOG.error(e.getMessage(), e); + } } } private void writeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) { - ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); - InstanceIdentifier path1 = - InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory - .rev130819.nodes.Node.class, - nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, - new TableKey(flowBuilder.getTableId())).child(Flow.class, flowBuilder.getKey()).build(); + if (NetvirtProvidersProvider.isMasterProviderInstance()){ + ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); + InstanceIdentifier path1 = + InstanceIdentifier.builder(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory + .rev130819.nodes.Node.class, + nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, + new TableKey(flowBuilder.getTableId())).child(Flow.class, flowBuilder.getKey()).build(); - //modification.put(LogicalDatastoreType.OPERATIONAL, path1, flowBuilder.build()); - modification.put(LogicalDatastoreType.CONFIGURATION, path1, flowBuilder.build(), - true);//createMissingParents + //modification.put(LogicalDatastoreType.OPERATIONAL, path1, flowBuilder.build()); + modification.put(LogicalDatastoreType.CONFIGURATION, path1, flowBuilder.build(), + true);//createMissingParents - CheckedFuture commitFuture = modification.submit(); - try { - commitFuture.get(); // TODO: Make it async (See bug 1362) - LOG.debug("Transaction success for write of Flow " + flowBuilder.getFlowName()); - } catch (InterruptedException|ExecutionException e) { - LOG.error(e.getMessage(), e); + CheckedFuture commitFuture = modification.submit(); + try { + commitFuture.get(); // TODO: Make it async (See bug 1362) + LOG.debug("Transaction success for write of Flow " + flowBuilder.getFlowName()); + } catch (InterruptedException|ExecutionException e) { + LOG.error(e.getMessage(), e); + } } } diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/providers/impl/rev150513/NetvirtProvidersImplModule.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/providers/impl/rev150513/NetvirtProvidersImplModule.java index 51dfd624fa..eaed95c249 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/providers/impl/rev150513/NetvirtProvidersImplModule.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/providers/impl/rev150513/NetvirtProvidersImplModule.java @@ -22,7 +22,7 @@ public class NetvirtProvidersImplModule extends org.opendaylight.yang.gen.v1.urn @Override public java.lang.AutoCloseable createInstance() { - NetvirtProvidersProvider provider = new NetvirtProvidersProvider(bundleContext); + NetvirtProvidersProvider provider = new NetvirtProvidersProvider(bundleContext, getClusteringEntityOwnershipServiceDependency()); BindingAwareBroker localBroker = getBrokerDependency(); localBroker.registerProvider(provider); return provider; diff --git a/openstack/net-virt-providers/src/main/yang/netvirt-providers-impl.yang b/openstack/net-virt-providers/src/main/yang/netvirt-providers-impl.yang index 7ae4b17cef..a784a4b6f1 100644 --- a/openstack/net-virt-providers/src/main/yang/netvirt-providers-impl.yang +++ b/openstack/net-virt-providers/src/main/yang/netvirt-providers-impl.yang @@ -5,6 +5,7 @@ module netvirt-providers-impl { import config { prefix config; revision-date 2013-04-05; } import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} + import opendaylight-entity-ownership-service {prefix eos; revision-date 2015-08-10;} description "Service definition for netvirt providers project"; @@ -30,6 +31,14 @@ module netvirt-providers-impl { } } } + container clustering-entity-ownership-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity eos:entity-ownership-service; + } + } + } } } } diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstanceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstanceTest.java index 9d9c97f604..50727a188e 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstanceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/AbstractServiceInstanceTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.lang.reflect.Field; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,8 +32,10 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.ovsdb.openstack.netvirt.NetvirtProvider; import org.opendaylight.ovsdb.openstack.netvirt.api.Constants; import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; @@ -46,6 +49,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.osgi.framework.ServiceReference; import org.powermock.api.mockito.PowerMockito; +import org.powermock.api.support.membermodification.MemberModifier; import org.powermock.modules.junit4.PowerMockRunner; import com.google.common.base.Optional; @@ -140,6 +144,9 @@ public class AbstractServiceInstanceTest { FlowBuilder flowBuilder = mock(FlowBuilder.class); when(flowBuilder.getKey()).thenReturn(mock(FlowKey.class)); + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + abstractServiceInstance.writeFlow(flowBuilder, nodeBuilder); //verify(transaction, times(1)).put(eq(LogicalDatastoreType.CONFIGURATION), any(InstanceIdentifier.class), any(DataObject.class), eq(true)); @@ -163,6 +170,9 @@ public class AbstractServiceInstanceTest { FlowBuilder flowBuilder = mock(FlowBuilder.class); when(flowBuilder.getKey()).thenReturn(mock(FlowKey.class)); + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + abstractServiceInstance.removeFlow(flowBuilder, nodeBuilder); verify(transaction, times(1)).delete(eq(LogicalDatastoreType.CONFIGURATION), any(InstanceIdentifier.class)); verify(commitFuture, times(1)).get(); diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ArpResponderServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ArpResponderServiceTest.java index 4206a01751..fbbd6e63d6 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ArpResponderServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ArpResponderServiceTest.java @@ -17,6 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.net.InetAddress; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,6 +31,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile import org.opendaylight.ovsdb.openstack.netvirt.api.Action; import org.opendaylight.ovsdb.openstack.netvirt.api.Status; import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey; @@ -37,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.powermock.api.support.membermodification.MemberModifier; import com.google.common.util.concurrent.CheckedFuture; diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java index c21b60fa0b..3f8bdb188f 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Assert; import org.junit.Before; @@ -36,6 +37,7 @@ import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule; import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs; import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityGroupCacheManger; import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; @@ -48,6 +50,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.powermock.api.mockito.PowerMockito; +import org.powermock.api.support.membermodification.MemberModifier; import org.powermock.modules.junit4.PowerMockRunner; import com.google.common.util.concurrent.CheckedFuture; @@ -108,7 +111,7 @@ public class EgressAclServiceTest { } @Before - public void setUp() { + public void setUp() throws IllegalArgumentException, IllegalAccessException { egressAclServiceSpy = PowerMockito.spy(egressAclService); when(writeTransaction.submit()).thenReturn(commitFuture); @@ -139,6 +142,10 @@ public class EgressAclServiceTest { when(securityGroup.getSecurityRules()).thenReturn(portSecurityList); when(securityServices.getVmListForSecurityGroup(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList); + + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + } /** diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/InboundNatServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/InboundNatServiceTest.java index bcd5bb69c1..891394ff18 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/InboundNatServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/InboundNatServiceTest.java @@ -17,6 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.net.InetAddress; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; @@ -31,10 +32,12 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile import org.opendaylight.ovsdb.openstack.netvirt.api.Action; import org.opendaylight.ovsdb.openstack.netvirt.api.Status; import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.powermock.api.support.membermodification.MemberModifier; import com.google.common.util.concurrent.CheckedFuture; @@ -57,12 +60,16 @@ public class InboundNatServiceTest { private static final String HOST_ADDRESS_PREFIX = "127.0.0.1/32"; @Before - public void setUp() { + public void setUp() throws IllegalArgumentException, IllegalAccessException { when(writeTransaction.submit()).thenReturn(commitFuture); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER); + + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + } /** diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L2FowardingServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L2FowardingServiceTest.java index 34e5658eae..f928918060 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L2FowardingServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L2FowardingServiceTest.java @@ -15,6 +15,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.concurrent.atomic.AtomicBoolean; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,11 +28,13 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.powermock.api.support.membermodification.MemberModifier; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; @@ -74,6 +78,10 @@ public class L2FowardingServiceTest { //when(mdsalConsumer.getDataBroker()).thenReturn(dataBroker); when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER); + + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + } /** diff --git a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L3FowardingServiceTest.java b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L3FowardingServiceTest.java index 66a0681936..bd5453e55f 100644 --- a/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L3FowardingServiceTest.java +++ b/openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L3FowardingServiceTest.java @@ -17,6 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.net.InetAddress; +import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; @@ -31,10 +32,12 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile import org.opendaylight.ovsdb.openstack.netvirt.api.Action; import org.opendaylight.ovsdb.openstack.netvirt.api.Status; import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode; +import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.powermock.api.support.membermodification.MemberModifier; import com.google.common.util.concurrent.CheckedFuture; @@ -64,6 +67,10 @@ public class L3FowardingServiceTest { when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER); + + NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class); + MemberModifier.field(NetvirtProvidersProvider.class, "hasProviderEntityOwnership").set(netvirtProvider, new AtomicBoolean(true)); + } /** diff --git a/openstack/net-virt/src/main/config/default-config.xml b/openstack/net-virt/src/main/config/default-config.xml index 7b3ffd38bf..e99fbca132 100644 --- a/openstack/net-virt/src/main/config/default-config.xml +++ b/openstack/net-virt/src/main/config/default-config.xml @@ -16,6 +16,10 @@ binding:binding-broker-osgi-registry binding-osgi-broker + + ns:entity-ownership-service + entity-ownership-service + diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/NetvirtProvider.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/NetvirtProvider.java index 43c637c880..a6367872f8 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/NetvirtProvider.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/NetvirtProvider.java @@ -8,7 +8,12 @@ package org.opendaylight.ovsdb.openstack.netvirt; +import com.google.common.base.Optional; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; +import org.opendaylight.ovsdb.openstack.netvirt.api.Constants; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.common.api.clustering.Entity; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.osgi.framework.BundleContext; @@ -23,10 +28,22 @@ public class NetvirtProvider implements BindingAwareProvider, AutoCloseable { private BundleContext bundleContext = null; private static DataBroker dataBroker = null; private ConfigActivator activator; + private static EntityOwnershipService entityOwnershipService; + private static final Entity ownerInstanceEntity = new Entity( + Constants.NETVIRT_OWNER_ENTITY_TYPE, Constants.NETVIRT_OWNER_ENTITY_TYPE); - public NetvirtProvider(BundleContext bundleContext) { + public NetvirtProvider(BundleContext bundleContext, EntityOwnershipService eos) { LOG.info("NetvirtProvider: bundleContext: {}", bundleContext); this.bundleContext = bundleContext; + entityOwnershipService = eos; + } + + public static boolean isMasterProviderInstance() { + if (entityOwnershipService != null) { + Optional state = entityOwnershipService.getOwnershipState(ownerInstanceEntity); + return state.isPresent() && state.get().isOwner(); + } + return false; } @Override diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Constants.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Constants.java index e43145565b..2c9858f2ca 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Constants.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Constants.java @@ -102,4 +102,9 @@ public final class Constants { //6653 is official openflow port. public static short OPENFLOW_PORT = 6653; public static String OPENFLOW_CONNECTION_PROTOCOL = "tcp"; + + /* + * Clustering + */ + public static final String NETVIRT_OWNER_ENTITY_TYPE = "ovsdb-netvirt-provider"; } diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/OvsdbDataChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/OvsdbDataChangeListener.java index 1daad3154e..825eabc35b 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/OvsdbDataChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/OvsdbDataChangeListener.java @@ -12,6 +12,7 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory; * * @author Sam Hague (shague@redhat.com) */ -public class OvsdbDataChangeListener implements DataChangeListener, AutoCloseable { +public class OvsdbDataChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(OvsdbDataChangeListener.class); private DataBroker dataBroker = null; private ListenerRegistration registration; diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImpl.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImpl.java index 6cb1f144fc..e9ac3fe0ab 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImpl.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImpl.java @@ -76,7 +76,9 @@ public class TenantNetworkManagerImpl implements ConfigInterface, TenantNetworkM } try { - List ports = southbound.getTerminationPointsOfBridge(node); + // Make sure to get fresh list of termination points, and not use the ones provided in node param! + List ports = southbound.readTerminationPointAugmentations(node); + for (OvsdbTerminationPointAugmentation port : ports) { String ifaceId = southbound.getInterfaceExternalIdsValue(port, Constants.EXTERNAL_ID_INTERFACE_ID); if (ifaceId != null && isInterfacePresentInTenantNetwork(ifaceId, networkId)) { diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronFloatingIPChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronFloatingIPChangeListener.java index 44adae86ac..6156e64f06 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronFloatingIPChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronFloatingIPChangeListener.java @@ -9,6 +9,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -25,7 +26,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NeutronFloatingIPChangeListener implements DataChangeListener, AutoCloseable{ +public class NeutronFloatingIPChangeListener implements ClusteredDataChangeListener, AutoCloseable{ private static final Logger LOG = LoggerFactory.getLogger(NeutronFloatingIPChangeListener.class); private ListenerRegistration registration; diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolChangeListener.java index faaaa83523..c173bd7ce9 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolChangeListener.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; @@ -40,7 +41,7 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ImmutableBiMap; -public class NeutronLoadBalancerPoolChangeListener implements DataChangeListener, AutoCloseable { +public class NeutronLoadBalancerPoolChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NeutronLoadBalancerPoolChangeListener.class); private static final ImmutableBiMap,String> PROTOCOL_MAP diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolMemberChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolMemberChangeListener.java index 357e263eee..03313aaf9f 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolMemberChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolMemberChangeListener.java @@ -10,6 +10,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; @@ -30,7 +31,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NeutronLoadBalancerPoolMemberChangeListener implements DataChangeListener, AutoCloseable { +public class NeutronLoadBalancerPoolMemberChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NeutronLoadBalancerPoolMemberChangeListener.class); private ListenerRegistration registration; diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronNetworkChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronNetworkChangeListener.java index a9227a2bb2..161ba5d198 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronNetworkChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronNetworkChangeListener.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; @@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ImmutableBiMap; -public class NeutronNetworkChangeListener implements DataChangeListener, AutoCloseable { +public class NeutronNetworkChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NeutronNetworkChangeListener.class); private static final ImmutableBiMap,String> NETWORK_MAP diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronPortChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronPortChangeListener.java index d998c86f1b..d404196d1c 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronPortChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronPortChangeListener.java @@ -15,6 +15,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -44,7 +45,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NeutronPortChangeListener implements DataChangeListener, AutoCloseable{ +public class NeutronPortChangeListener implements ClusteredDataChangeListener, AutoCloseable{ private static final Logger LOG = LoggerFactory.getLogger(NeutronPortChangeListener.class); private ListenerRegistration registration; diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronRouterChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronRouterChangeListener.java index 256b438e1b..b28576ca34 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronRouterChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronRouterChangeListener.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -34,7 +35,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NeutronRouterChangeListener implements DataChangeListener, AutoCloseable{ +public class NeutronRouterChangeListener implements ClusteredDataChangeListener, AutoCloseable{ private static final Logger LOG = LoggerFactory.getLogger(NeutronRouterChangeListener.class); private ListenerRegistration registration; diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityGroupDataChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityGroupDataChangeListener.java index 335de4f04f..6c1f099869 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityGroupDataChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityGroupDataChangeListener.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -31,8 +32,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NeutronSecurityGroupDataChangeListener implements - DataChangeListener, AutoCloseable { +public class NeutronSecurityGroupDataChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory .getLogger(NeutronSecurityGroupDataChangeListener.class); diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java index 6f09a7fa5c..cd474608c1 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java @@ -9,6 +9,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.impl; import java.util.Map.Entry; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ImmutableBiMap; -public class NeutronSecurityRuleDataChangeListener implements DataChangeListener, AutoCloseable { +public class NeutronSecurityRuleDataChangeListener implements ClusteredDataChangeListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleDataChangeListener.class); diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSubnetChangeListener.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSubnetChangeListener.java index 50b1336d15..1b8d10e72d 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSubnetChangeListener.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSubnetChangeListener.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; +import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -46,7 +47,7 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ImmutableBiMap; -public class NeutronSubnetChangeListener implements DataChangeListener, AutoCloseable{ +public class NeutronSubnetChangeListener implements ClusteredDataChangeListener, AutoCloseable{ private static final Logger LOG = LoggerFactory.getLogger(NeutronSubnetChangeListener.class); private static final ImmutableBiMap,Integer> IPV_MAP diff --git a/openstack/net-virt/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev150513/NetvirtImplModule.java b/openstack/net-virt/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev150513/NetvirtImplModule.java index 2b3f8cc527..8a43c9c859 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev150513/NetvirtImplModule.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/impl/rev150513/NetvirtImplModule.java @@ -22,7 +22,7 @@ public class NetvirtImplModule extends org.opendaylight.yang.gen.v1.urn.opendayl @Override public java.lang.AutoCloseable createInstance() { - NetvirtProvider provider = new NetvirtProvider(bundleContext); + NetvirtProvider provider = new NetvirtProvider(bundleContext, getClusteringEntityOwnershipServiceDependency()); BindingAwareBroker localBroker = getBrokerDependency(); localBroker.registerProvider(provider); return provider; diff --git a/openstack/net-virt/src/main/yang/netvirt-impl.yang b/openstack/net-virt/src/main/yang/netvirt-impl.yang index 0c0e783e42..73042641c2 100644 --- a/openstack/net-virt/src/main/yang/netvirt-impl.yang +++ b/openstack/net-virt/src/main/yang/netvirt-impl.yang @@ -5,6 +5,7 @@ module 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;} + import opendaylight-entity-ownership-service {prefix eos; revision-date 2015-08-10;} description "Service definition for netvirt project"; @@ -30,6 +31,14 @@ module netvirt-impl { } } } + container clustering-entity-ownership-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity eos:entity-ownership-service; + } + } + } } } } diff --git a/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImplTest.java b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImplTest.java index 92e92ea7d4..6c6df3e47a 100644 --- a/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImplTest.java +++ b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/TenantNetworkManagerImplTest.java @@ -117,7 +117,7 @@ public class TenantNetworkManagerImplTest { List ports = new ArrayList<>(); ports.add(mock(OvsdbTerminationPointAugmentation.class)); - when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports); + when(southbound.readTerminationPointAugmentations(any(Node.class))).thenReturn(ports); assertTrue("Error, did not return correct boolean for isTenantNetworkPresentInNode", tenantNetworkManagerImpl.isTenantNetworkPresentInNode(mock(Node.class), SEG_ID)); }