Adding named augmentation + prepare naked application. 86/186/2
authorJozef Gloncak <jgloncak@cisco.com>
Tue, 2 Feb 2016 07:35:12 +0000 (08:35 +0100)
committerJozef Gloncak <jgloncak@cisco.com>
Tue, 2 Feb 2016 12:16:31 +0000 (13:16 +0100)
Named augmentation of node topology-types was added for
better readibility of generated code.

Running application was created. It is possible to start via
installing feature odl-vbd-rest.

Change-Id: I2d919cd20d962ff9b28143794f6984137331c51a
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
13 files changed:
vbd/api/src/main/yang/vbridge-topology.yang
vbd/artifacts/pom.xml
vbd/features/pom.xml
vbd/features/src/main/features/features.xml
vbd/impl/pom.xml
vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java
vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/TopologyMonitor.java
vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/VirtualBridgeDomainManager.java
vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModule.java [new file with mode: 0644]
vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModuleFactory.java [new file with mode: 0644]
vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdProvider.java [new file with mode: 0644]
vbd/impl/src/main/resources/config/vbd.xml [new file with mode: 0644]
vbd/impl/src/main/yang/vbd-impl.yang [new file with mode: 0644]

index 36e50ae..f105b5e 100644 (file)
@@ -37,6 +37,7 @@ module vbridge-topology {
     import network-topology { prefix nt; revision-date 2013-10-21; }
     import odl-external-reference { prefix extref; }
     import v3po { prefix "v3po"; }
+    import yang-ext { prefix ext; revision-date "2013-07-09"; }
 
     identity tunnel-type {
         description "Type of tunneling technology";
@@ -56,12 +57,14 @@ module vbridge-topology {
     }
 
     augment "/nt:network-topology/nt:topology/nt:topology-types" {
+        ext:augment-identifier "topology-types-vbridge-augment";
         container vbridge-topology {
             presence "Indicates a virtual bridge domain topology";
         }
     }
 
     augment "/nt:network-topology/nt:topology" {
+        ext:augment-identifier "topology-vbridge-augment";
         when "./nt:topology-types/vbridge-topology";
 
         // Pointer to the NETCONF topology which supports this bridge domain
index b52fa71..6b926a4 100644 (file)
         <artifactId>vbd-impl</artifactId>
         <version>1.0.0-SNAPSHOT</version>
       </dependency>
+      <dependency>
+          <groupId>${project.groupId}</groupId>
+          <artifactId>vbd-impl</artifactId>
+          <type>xml</type>
+          <classifier>config</classifier>
+          <version>1.0.0-SNAPSHOT</version>
+      </dependency>
       <dependency>
         <groupId>${project.groupId}</groupId>
         <artifactId>vbd-features</artifactId>
index 0640372..ec852ba 100644 (file)
       <groupId>${project.groupId}</groupId>
       <artifactId>vbd-impl</artifactId>
     </dependency>
-    <!--dependency>
+
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>vbd-impl</artifactId>
       <type>xml</type>
       <classifier>config</classifier>
-    </dependency-->
+    </dependency>
+
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>vbd-api</artifactId>
index b352902..b47ee1b 100644 (file)
     <feature version='${project.version}'>odl-vbd-api</feature>
     <feature version='${netconf.version}'>odl-netconf-connector-ssh</feature>
     <feature version='${netconf.mdsal.version}'>odl-netconf-mdsal</feature>
-    <!--bundle>mvn:io.fd.honeycomb.vbd/vbd-impl/{{VERSION}}</bundle-->
-    <!--configfile finalname="${configfile.directory}/vbd.xml">mvn:io.fd.honeycomb.vbd/vbd-impl/{{VERSION}}/xml/config</configfile-->
+    <bundle>mvn:io.fd.honeycomb.vbd/vbd-impl/{{VERSION}}</bundle>
+    <configfile finalname="${configfile.directory}/vbd.xml">mvn:io.fd.honeycomb.vbd/vbd-impl/{{VERSION}}/xml/config</configfile>
   </feature>
 
-  <!--feature name='odl-vbd-rest' version='${project.version}' description='OpenDaylight :: vbd :: REST'>
+  <feature name='odl-vbd-rest' version='${project.version}' description='OpenDaylight :: vbd :: REST'>
     <feature version="${project.version}">odl-vbd</feature>
     <feature version="${restconf.version}">odl-restconf</feature>
   </feature>
 
-  <feature name='odl-vbd-ui' version='${project.version}' description='OpenDaylight :: vbd :: UI'>
+  <!--feature name='odl-vbd-ui' version='${project.version}' description='OpenDaylight :: vbd :: UI'>
     <feature version="${project.version}">odl-vbd-rest</feature>
     <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
     <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
index 3d6d55a..d4ac30d 100644 (file)
   <version>1.0.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
+    <properties>
+       <config.file>src/main/config/vbd.xml</config.file>
+    </properties>
+
   <dependencyManagement>
     <dependencies>
       <dependency>
       <scope>test</scope>
     </dependency>
   </dependencies>
+
+
+    <!--TODO: remove direct calling of builder-helper-maven-plugin. should be supported via profile in parent-->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/classes/config/vbd.xml</file>
+                                    <type>xml</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>
index aff03b2..9cea658 100644 (file)
@@ -18,9 +18,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.Mod
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.Topology1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyVbridgeAugment;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
@@ -41,19 +42,21 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> {
     @GuardedBy("this")
     private final BindingTransactionChain chain;
     private final ListenerRegistration<?> reg;
-    private Topology1 config;
+    private final MountPointService mountService;
+    private TopologyVbridgeAugment config;
 
-    private BridgeDomain(final DataBroker dataBroker, final KeyedInstanceIdentifier<Topology, TopologyKey> topology,
+    private BridgeDomain(final DataBroker dataBroker, final MountPointService mountService, final KeyedInstanceIdentifier<Topology, TopologyKey> topology,
             final BindingTransactionChain chain) {
         this.topology = Preconditions.checkNotNull(topology);
         this.chain = Preconditions.checkNotNull(chain);
+        this.mountService = mountService;
 
         reg = dataBroker.registerDataTreeChangeListener(
             new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, topology), this);
     }
 
     static BridgeDomain create(final DataBroker dataBroker,
-            final KeyedInstanceIdentifier<Topology, TopologyKey> topology, final BindingTransactionChain chain) {
+                               MountPointService mountService, final KeyedInstanceIdentifier<Topology, TopologyKey> topology, final BindingTransactionChain chain) {
 
         LOG.debug("Wiping operational state of {}", topology);
 
@@ -61,7 +64,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> {
         tx.delete(LogicalDatastoreType.OPERATIONAL, topology);
         tx.submit();
 
-        return new BridgeDomain(dataBroker, topology, chain);
+        return new BridgeDomain(dataBroker, mountService, topology, chain);
     }
 
     synchronized void forceStop() {
@@ -92,7 +95,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> {
                     break;
                 case SUBTREE_MODIFIED:
                     // First check if the configuration has changed
-                    final DataObjectModification<Topology1> newConfig = mod.getModifiedAugmentation(Topology1.class);
+                    final DataObjectModification<TopologyVbridgeAugment> newConfig = mod.getModifiedAugmentation(TopologyVbridgeAugment.class);
                     if (newConfig != null) {
                         if (newConfig.getModificationType() != ModificationType.DELETE) {
                             LOG.debug("Topology {} modified configuration {}", topology, newConfig);
@@ -116,7 +119,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> {
                     final Topology data = mod.getDataAfter();
 
                     // Read configuration
-                    final Topology1 config = data.getAugmentation(Topology1.class);
+                    final TopologyVbridgeAugment config = data.getAugmentation(TopologyVbridgeAugment.class);
                     if (config != null) {
                         setConfiguration(config);
                     } else {
@@ -153,14 +156,14 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> {
         }
     }
 
-    private void setConfiguration(final Topology1 config) {
+    private void setConfiguration(final TopologyVbridgeAugment config) {
         LOG.debug("Topology {} configuration set to {}", topology, config);
 
         this.config = config;
     }
 
     @GuardedBy("this")
-    private void updateConfiguration(final DataObjectModification<Topology1> mod) {
+    private void updateConfiguration(final DataObjectModification<TopologyVbridgeAugment> mod) {
         LOG.debug("Topology {} configuration changed", topology);
 
         // FIXME: do something smarter
index b2e52c3..213ff66 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
@@ -39,9 +40,11 @@ final class TopologyMonitor implements DataTreeChangeListener<VbridgeTopology>,
     @GuardedBy("this")
     private final Map<TopologyKey, BridgeDomain> domains = new HashMap<>();
     private final DataBroker dataBroker;
+    private final MountPointService mountService;
 
-    TopologyMonitor(final DataBroker dataBroker) {
+    public TopologyMonitor(DataBroker dataBroker, MountPointService mountService) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
+        this.mountService = Preconditions.checkNotNull(mountService);
     }
 
     @Override
@@ -115,7 +118,7 @@ final class TopologyMonitor implements DataTreeChangeListener<VbridgeTopology>,
             }
         });
 
-        final BridgeDomain domain = BridgeDomain.create(dataBroker, topology, chain);
+        final BridgeDomain domain = BridgeDomain.create(dataBroker, mountService, topology, chain);
         domains.put(topology.getKey(), domain);
 
         LOG.debug("Bridge domain {} for {} started", domain, topology);
index 37da731..0c1d08f 100644 (file)
@@ -12,8 +12,9 @@ import com.google.common.base.Preconditions;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyTypesVbridgeAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.network.topology.topology.topology.types.VbridgeTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@@ -32,7 +33,7 @@ public final class VirtualBridgeDomainManager implements AutoCloseable {
     private static final DataTreeIdentifier<VbridgeTopology> LISTEN_TREE =
             new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
                     InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class).child(TopologyTypes.class)
-                    .augmentation(TopologyTypes1.class).child(VbridgeTopology.class).build());
+                    .augmentation(TopologyTypesVbridgeAugment.class).child(VbridgeTopology.class).build());
 
     private final ListenerRegistration<TopologyMonitor> reg;
     private boolean closed;
@@ -41,9 +42,9 @@ public final class VirtualBridgeDomainManager implements AutoCloseable {
         this.reg = Preconditions.checkNotNull(reg);
     }
 
-    public static VirtualBridgeDomainManager create(@Nonnull final DataBroker dataBroker) {
+    public static VirtualBridgeDomainManager create(@Nonnull final DataBroker dataBroker,@Nonnull MountPointService mountService) {
         final ListenerRegistration<TopologyMonitor> reg =
-                dataBroker.registerDataTreeChangeListener(LISTEN_TREE, new TopologyMonitor(dataBroker));
+                dataBroker.registerDataTreeChangeListener(LISTEN_TREE, new TopologyMonitor(dataBroker, mountService));
 
         return new VirtualBridgeDomainManager(reg);
     }
diff --git a/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModule.java b/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModule.java
new file mode 100644 (file)
index 0000000..6157320
--- /dev/null
@@ -0,0 +1,32 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbd.impl.rev160202;
+
+import io.fd.honeycomb.vbd.impl.VirtualBridgeDomainManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+
+public class VbdModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbd.impl.rev160202.AbstractVbdModule {
+    public VbdModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public VbdModule(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.vbd.impl.rev160202.VbdModule 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() {
+        final BindingAwareBroker brokerDependency = getBrokerDependency();
+        BindingAwareBroker.ProviderContext session = brokerDependency.registerProvider(new VbdProvider());
+
+        DataBroker dataBroker = session.getSALService(DataBroker.class);
+        MountPointService mountService = session.getSALService(MountPointService.class);
+        return VirtualBridgeDomainManager.create(dataBroker, mountService);
+    }
+
+}
diff --git a/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModuleFactory.java b/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdModuleFactory.java
new file mode 100644 (file)
index 0000000..4f87fe6
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: vbd-impl yang module local name: vbd
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Feb 02 10:45:40 CET 2016
+*
+* 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.vbd.impl.rev160202;
+public class VbdModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbd.impl.rev160202.AbstractVbdModuleFactory {
+
+}
diff --git a/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdProvider.java b/vbd/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vbd/impl/rev160202/VbdProvider.java
new file mode 100644 (file)
index 0000000..a27aa1e
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ * <p>
+ * 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.vbd.impl.rev160202;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+
+/**
+ * Created by joe on 2.2.2016.
+ */
+public class VbdProvider implements BindingAwareProvider {
+
+    @Override
+    public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
+        // Intentional NOOP
+    }
+}
diff --git a/vbd/impl/src/main/resources/config/vbd.xml b/vbd/impl/src/main/resources/config/vbd.xml
new file mode 100644 (file)
index 0000000..c3f4c66
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2015 Cisco and/or its affiliates.
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at:
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:vbd:impl?module=vbd-impl&amp;revision=2016-02-02</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:vbd:impl">prefix:vbd</type>
+          <name>vbd-name</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/vbd/impl/src/main/yang/vbd-impl.yang b/vbd/impl/src/main/yang/vbd-impl.yang
new file mode 100644 (file)
index 0000000..d0c2595
--- /dev/null
@@ -0,0 +1,35 @@
+module vbd-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:vbd:impl";
+    prefix "vbd-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 vbd project";
+
+    revision "2016-02-02" {
+        description
+            "Initial revision";
+    }
+
+    identity vbd {
+        base config:module-type;
+        config:java-name-prefix Vbd;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case vbd {
+            when "/config:modules/config:module/config:type = 'vbd'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}