<properties>
<odl.karaf.base.version>1.6.0-SNAPSHOT</odl.karaf.base.version>
<mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
+ <mdsal.model.version>0.8.0-SNAPSHOT</mdsal.model.version>
+ <restconf.version>1.3.0-SNAPSHOT</restconf.version>
<neutron.version>0.6.0-SNAPSHOT</neutron.version>
<openflowplugin.version>0.2.0-SNAPSHOT</openflowplugin.version>
<yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>features-mdsal-model</artifactId>
+ <version>${mdsal.model.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>features-restconf</artifactId>
+ <version>${restconf.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
<!-- external dependencies -->
<!-- TODO clean up based on what is provided by odlparent -->
<dependency>
<type>xml</type>
<classifier>features</classifier>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netvirt-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hwgw</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hwvtepsouthbound-features</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<!-- DLUX dependency for the UI -->
<dependency>
<groupId>org.opendaylight.dlux</groupId>
<repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.ovsdb/library-features/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/hwvtepsouthbound-features/{{VERSION}}/xml/features</repository>
<feature name="odl-ovsdb-all" description="OpenDaylight :: OVSDB :: all"
version='${project.version}'>
<feature version="${dlux.version}">odl-dlux-core</feature>
<bundle>mvn:org.opendaylight.ovsdb/ovsdb-ui-bundle/{{VERSION}}</bundle>
</feature>
+ <feature name='odl-netvirt-api' version='${project.version}' description='OpenDaylight :: netvirt :: api'>
+ <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
+ <bundle>mvn:org.opendaylight.ovsdb/netvirt-api/{{VERSION}}</bundle>
+ </feature>
+ <feature name='odl-netvirt-rest' version='${project.version}' description='OpenDaylight :: netvirt :: REST'>
+ <feature version="${project.version}">odl-netvirt-api</feature>
+ <feature version="${restconf.version}">odl-restconf</feature>
+ </feature>
+ <feature name='odl-netvirt-ui' version='${project.version}' description='OpenDaylight :: netvirt :: UI'>
+ <feature version="${project.version}">odl-netvirt-rest</feature>
+ <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
+ <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
+ </feature>
+ <feature name='odl-netvirt-hwgw' version='${project.version}' description='OpenDaylight :: netvirt :: Hardware Gateway'>
+ <feature version="${project.version}">odl-netvirt-api</feature>
+ <feature version='${project.version}'>odl-ovsdb-hwvtepsouthbound</feature>
+ <bundle>mvn:org.opendaylight.ovsdb/hwgw/{{VERSION}}</bundle>
+ </feature>
+
</features>
namespace "urn:opendaylight:params:xml:ns:yang:netvirt";
prefix "netvirt";
- revision "2015-01-05" {
+ revision "2015-12-27" {
description "Initial revision of netvirt model";
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>netvirt-artifacts</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-features</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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 INTERNAL
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>features-parent</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>netvirt-features</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <modelVersion>4.0.0</modelVersion>
- <prerequisites>
- <maven>3.1.1</maven>
- </prerequisites>
-
- <properties>
- <configfile.directory>etc/opendaylight/karaf</configfile.directory>
- <mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
- <mdsal.model.version>0.8.0-SNAPSHOT</mdsal.model.version>
- <restconf.version>1.3.0-SNAPSHOT</restconf.version>
- <yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
- </properties>
- <dependencyManagement>
- <dependencies>
- <!-- project specific dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>${yangtools.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>${mdsal.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-artifacts</artifactId>
- <version>${restconf.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>features-yangtools</artifactId>
- <classifier>features</classifier>
- <version>${yangtools.version}</version>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>features-mdsal-model</artifactId>
- <version>${mdsal.model.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>features-restconf</artifactId>
- <classifier>features</classifier>
- <version>${restconf.version}</version>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-mdsal</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-impl</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2015 Red Hat, Inc.
-
-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
--->
-<features name="odl-netvirt-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
- <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
- <repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
- <feature name='odl-netvirt-api' version='${project.version}' description='OpenDaylight :: netvirt :: api'>
- <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
- <bundle>mvn:org.opendaylight.ovsdb/netvirt-api/{{VERSION}}</bundle>
- </feature>
- <feature name='odl-netvirt' version='${project.version}' description='OpenDaylight :: netvirt'>
- <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
- <feature version='${project.version}'>odl-netvirt-api</feature>
- <bundle>mvn:org.opendaylight.ovsdb/netvirt-impl/{{VERSION}}</bundle>
- <configfile finalname="${configfile.directory}/netvirt.xml">mvn:org.opendaylight.ovsdb/netvirt-impl/{{VERSION}}/xml/config</configfile>
- </feature>
- <feature name='odl-netvirt-rest' version='${project.version}' description='OpenDaylight :: netvirt :: REST'>
- <feature version="${project.version}">odl-netvirt</feature>
- <feature version="${restconf.version}">odl-restconf</feature>
- </feature>
- <feature name='odl-netvirt-ui' version='${project.version}' description='OpenDaylight :: netvirt :: UI'>
- <feature version="${project.version}">odl-netvirt-rest</feature>
- <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
- <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
- </feature>
-
-</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
-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 INTERNAL
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>netvirt-impl</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-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
--->
-<snapshot>
- <required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:netvirt:impl?module=netvirt-impl&revision=2014-12-10</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
- </required-capabilities>
- <configuration>
-
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:impl">prefix:netvirt</type>
- <name>netvirt-default</name>
- <broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <name>binding-osgi-broker</name>
- </broker>
- </module>
- </modules>
- </data>
- </configuration>
-</snapshot>
+++ /dev/null
-/*
- * 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");
- }
-
-}
+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
+++ /dev/null
-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;
- }
- }
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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 INTERNAL
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>karaf-parent</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>netvirt-karaf</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <prerequisites>
- <maven>3.1.1</maven>
- </prerequisites>
- <properties>
- <karaf.localFeature>odl-netvirt-ui</karaf.localFeature>
- </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <!-- scope is compile so all features (there is only one) are installed
- into startup.properties and the feature repo itself is not installed -->
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>framework</artifactId>
- <type>kar</type>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netvirt-features</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- <!-- DO NOT install or deploy the karaf artifact -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
</prerequisites>
<modules>
<module>api</module>
- <module>impl</module>
- <module>karaf</module>
- <module>features</module>
- <module>artifacts</module>
<module>renderers</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
-->
<snapshot>
<required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&revision=2014-12-10</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&revision=2015-12-27</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
</required-capabilities>
<configuration>
+++ /dev/null
-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();
- }
-
-}
+++ /dev/null
-/*
-* 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 {
-
-}
* 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);
}
*
* 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 {
}
description
"Service definition for hwgw project";
- revision "2014-12-10" {
+ revision "2015-12-27" {
description
"Initial revision";
}
* 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;
* 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;
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
</broker>
+ <clustering-entity-ownership-service>
+ <type xmlns:ns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">ns:entity-ownership-service</type>
+ <name>entity-ownership-service</name>
+ </clustering-entity-ownership-service>
</module>
</modules>
</data>
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() {
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
} 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);
+ }
}
}
}
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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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();
+ }
}
}
}
private void writeGroup(GroupBuilder groupBuilder, NodeBuilder nodeBuilder) {
- ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Group> 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<Void, TransactionCommitFailedException> 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<Group> 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<Void, TransactionCommitFailedException> 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<Group> 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<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+ if (NetvirtProvidersProvider.isMasterProviderInstance()) {
+ WriteTransaction modification = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<Group> 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<Void, TransactionCommitFailedException> 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<Flow> 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<Flow> 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<Void, TransactionCommitFailedException> 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<Void, TransactionCommitFailedException> 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);
+ }
}
}
@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;
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";
}
}
}
+ container clustering-entity-ownership-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity eos:entity-ownership-service;
+ }
+ }
+ }
}
}
}
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;
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;
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;
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));
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();
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;
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;
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;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Before;
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;
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;
}
@Before
- public void setUp() {
+ public void setUp() throws IllegalArgumentException, IllegalAccessException {
egressAclServiceSpy = PowerMockito.spy(egressAclService);
when(writeTransaction.submit()).thenReturn(commitFuture);
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));
+
}
/**
import static org.mockito.Mockito.when;
import java.net.InetAddress;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Test;
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;
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));
+
}
/**
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;
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;
//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));
+
}
/**
import static org.mockito.Mockito.when;
import java.net.InetAddress;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Test;
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;
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));
+
}
/**
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
</broker>
+ <clustering-entity-ownership-service>
+ <type xmlns:ns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">ns:entity-ownership-service</type>
+ <name>entity-ownership-service</name>
+ </clustering-entity-ownership-service>
</module>
</modules>
</data>
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;
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<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity);
+ return state.isPresent() && state.get().isOwner();
+ }
+ return false;
}
@Override
//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";
}
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;
*
* @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<DataChangeListener> registration;
}
try {
- List<OvsdbTerminationPointAugmentation> ports = southbound.getTerminationPointsOfBridge(node);
+ // Make sure to get fresh list of termination points, and not use the ones provided in node param!
+ List<OvsdbTerminationPointAugmentation> ports = southbound.readTerminationPointAugmentations(node);
+
for (OvsdbTerminationPointAugmentation port : ports) {
String ifaceId = southbound.getInterfaceExternalIdsValue(port, Constants.EXTERNAL_ID_INTERFACE_ID);
if (ifaceId != null && isInterfacePresentInTenantNetwork(ifaceId, networkId)) {
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;
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<DataChangeListener> registration;
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;
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<Class<? extends ProtocolBase>,String> PROTOCOL_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;
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<DataChangeListener> registration;
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;
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<Class<? extends NetworkTypeBase>,String> NETWORK_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;
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<DataChangeListener> registration;
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;
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<DataChangeListener> registration;
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;
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);
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;
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);
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;
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<Class<? extends IpVersionBase>,Integer> IPV_MAP
@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;
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";
}
}
}
+ container clustering-entity-ownership-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity eos:entity-ownership-service;
+ }
+ }
+ }
}
}
}
List<OvsdbTerminationPointAugmentation> 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));
}