<artifactId>ovs-driver</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>unimgr-template-driver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>unimgr-features</artifactId>
<artifactId>ovs-driver</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>unimgr-template-driver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.unimgr</groupId>
<artifactId>edgeassure-1000</artifactId>
<bundle>mvn:org.opendaylight.unimgr/unimgr-cisco-xr-driver/{{VERSION}}</bundle>
</feature>
+ <feature name='odl-unimgr-template-driver' version='${project.version}' description='OpenDaylight :: UniMgr :: Template Driver'>
+ <feature version='${project.version}'>odl-unimgr</feature>
+ <bundle>mvn:org.opendaylight.unimgr/unimgr-template-driver/{{VERSION}}</bundle>
+ </feature>
+
+
+
<feature name="odl-unimgr-ovs-driver" version="${project.version}" description='OpenDaylight :: UniMgr :: OVSDB Driver'>
<feature version='${project.version}'>odl-unimgr</feature>
<feature version="${l2switch.version}">odl-l2switch-all</feature>
<type>xml</type>
<classifier>features</classifier>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>odl-unimgr-template-driver</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-unimgr</artifactId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2015 Cable Television Laboratories, Inc. 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>single-feature-parent</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+ <groupId>org.opendaylight.unimgr</groupId>
+ <artifactId>odl-unimgr-template-driver</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ODL :: unimgr :: ${project.artifactId}</name>
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <configfile.directory>etc/opendaylight/karaf</configfile.directory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.unimgr</groupId>
+ <artifactId>odl-unimgr</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.unimgr</groupId>
+ <artifactId>unimgr-template-driver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
<module>odl-unimgr-rest</module>
<module>odl-unimgr-ui</module>
<module>odl-unimgr-cisco-xr-driver</module>
- <module>odl-unimgr-ovs-driver</module>
- </modules>
+ <module>odl-unimgr-ovs-driver</module>
+ <module>odl-unimgr-template-driver</module>
+ </modules>
</project>
<module>netvirt</module>
<module>cisco-xr-driver</module>
<module>ovs-driver</module>
+ <module>template-driver</module>
<module>dlux</module>
<module>cli</module>
<module>karaf</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2017 Cisco Systems Inc and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.unimgr</groupId>
+ <artifactId>unimgr-template-driver</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ODL :: unimgr :: ${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- dependencies -->
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>unimgr-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- unit test dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>unimgr-impl</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems 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.unimgr.mef.nrp.template;
+
+/**
+ * @author bartosz.michalik@amartus.com
+ */
+public interface TemplateConstants {
+ String DRIVER_ID = "template-node";
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems 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.unimgr.mef.nrp.template.driver;
+
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivatorException;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp_interface.rev170227.NrpCreateConnectivityServiceAttrs;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.UniversalId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Example driver builder
+ * @author bartosz.michalik@amartus.com
+ */
+public class TemplateDriver implements ActivationDriverBuilder {
+ private static final Logger log = LoggerFactory.getLogger(TemplateDriver.class);
+ @Override
+ public Optional<ActivationDriver> driverFor(BuilderContext context) {
+ // build a stateful driver
+ // the API contract is following
+ // 1. initialize is called
+ // 2. activate or deactivate metod is called depending on NRP call (update will be supported soon)
+ // 3. if activation/deactivation succeeds for all drivers the commit metod is called
+ // 3a. if activation/deactivation fails for any driver rollback is called
+ return Optional.of(new ActivationDriver() {
+
+ public String serviceId;
+
+ @Override
+ public void commit() {
+ log.info("commit was triggered for {}", serviceId);
+ }
+
+ @Override
+ public void rollback() {
+ log.info("rollback was triggered for {}", serviceId);
+ }
+
+ @Override
+ public void initialize(List<EndPoint> endPoints, String serviceId, NrpCreateConnectivityServiceAttrs context) {
+ this.serviceId = serviceId;
+ }
+
+ @Override
+ public void activate() throws TransactionCommitFailedException, ResourceActivatorException {
+ // method can fail if you wish
+ log.info("activate was triggered for {}", serviceId);
+ }
+
+ @Override
+ public void deactivate() throws TransactionCommitFailedException, ResourceActivatorException {
+ // method can fail if you wish
+ log.info("adectivate was triggered for {}", serviceId);
+ }
+
+ @Override
+ public int priority() {
+ //if you would like to make your driver first on the list
+
+ return 0;
+ }
+ });
+ }
+
+ @Override
+ public UniversalId getNodeUuid() {
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems 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.unimgr.mef.nrp.template.tapi;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
+import org.opendaylight.unimgr.mef.nrp.template.TemplateConstants;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm_connectivity.rev170227.NaturalNumber;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp_interface.rev170227.LayerProtocol1;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp_interface.rev170227.LayerProtocol1Builder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp_interface.rev170227.nrp.layer.protocol.attrs.NrpCgEthUniSpecBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.*;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.context.attrs.ServiceInterfacePoint;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.context.attrs.ServiceInterfacePointBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.service._interface.point.LayerProtocol;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapicommon.rev170227.service._interface.point.LayerProtocolBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapitopology.rev170227.node.OwnedNodeEdgePoint;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapitopology.rev170227.node.OwnedNodeEdgePointBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @author bartosz.michalik@amartus.com
+ */
+public class TopologyDataHandler {
+ private static final Logger log = LoggerFactory.getLogger(TopologyDataHandler.class);
+ private DataBroker dataBroker;
+
+ public TopologyDataHandler(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
+ public void init() {
+ Objects.requireNonNull(dataBroker);
+ log.info("Starting topology handler");
+ // this is a static and simplistic topology push to the TAPI system topology
+
+ ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+
+ try {
+
+ // we have prepared an dao abstraction to make it easier to use some of the common interactions with
+ // MD-SAL but you can use tx.put tx.merge etc. by yourself if you prefere to
+ NrpDao nrpDao = new NrpDao(tx);
+ //we are creating a list of NodeEdgePoints for the node no sips are added to the system
+ List<OwnedNodeEdgePoint> someEndpoints = createSomeEndpoints(1, 2, 5, 7);
+ nrpDao.createSystemNode(TemplateConstants.DRIVER_ID, someEndpoints);
+ //add sip for one of these endpoints
+
+ //create sid and add it to model
+ ServiceInterfacePoint someSid = createSomeSid("some-sid-id");
+ nrpDao.addSip(someSid);
+
+ //update an existing nep wit mapping to sip
+ OwnedNodeEdgePoint updatedNep = new OwnedNodeEdgePointBuilder(someEndpoints.get(1))
+ .setMappedServiceInterfacePoint(Collections.singletonList(someSid.getUuid()))
+ .build();
+
+ nrpDao.updateNep(TemplateConstants.DRIVER_ID, updatedNep);
+
+
+ tx.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ log.error("Adding node to system topology has failed", e);
+ }
+
+ }
+
+ private ServiceInterfacePoint createSomeSid(String idx) {
+ return new ServiceInterfacePointBuilder()
+ .setUuid(new UniversalId("sip" + ":" + TemplateConstants.DRIVER_ID + ":" + idx))
+ .setLayerProtocol(layerProtocolWithUniAttributes())
+ .build();
+ }
+
+ private List<LayerProtocol> layerProtocolWithUniAttributes() {
+
+ LayerProtocol layerProtocol = new LayerProtocolBuilder()
+ .setLocalId("eth")
+ .setLayerProtocolName(LayerProtocolName.Eth)
+ .addAugmentation(LayerProtocol1.class, new LayerProtocol1Builder()
+ .setNrpCgEthUniSpec(
+ new NrpCgEthUniSpecBuilder()
+ .setMaxFrameSize(new NaturalNumber(new BigInteger("1703")))
+ .build()
+ ).build()
+ ).build();
+
+ return Collections.singletonList(layerProtocol);
+ }
+
+ private List<OwnedNodeEdgePoint> createSomeEndpoints(int... indexes) {
+
+ return Arrays.stream(indexes).mapToObj(idx -> new OwnedNodeEdgePointBuilder()
+ .setUuid(new UniversalId(TemplateConstants.DRIVER_ID + ":nep" + idx))
+ .setLayerProtocol(Collections.singletonList(
+ new org.opendaylight.yang.gen.v1.urn.mef.yang.tapitopology.rev170227.node.edge.point.LayerProtocolBuilder()
+ .setLocalId("eth")
+ .setLayerProtocolName(LayerProtocolName.Eth)
+ .build()))
+ .setLinkPortDirection(PortDirection.Bidirectional)
+ .setLinkPortRole(PortRole.Symmetric)
+ .setTerminationDirection(TerminationDirection.Bidirectional)
+ .build()).collect(Collectors.toList());
+ }
+
+ public void close() {
+ log.info("Closing topology handler");
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Cisco Systems 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" />
+
+ <service interface="org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder">
+ <bean class="org.opendaylight.unimgr.mef.nrp.template.driver.TemplateDriver">
+
+ </bean>
+ </service>
+ <bean id="topologyHandler" class="org.opendaylight.unimgr.mef.nrp.template.tapi.TopologyDataHandler" init-method="init" destroy-method="close">
+ <argument ref="dataBroker" />
+ </bean>
+</blueprint>
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems 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.unimgr.mef.nrp.template.tapi;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.unimgr.mef.nrp.api.TapiConstants;
+import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
+import org.opendaylight.unimgr.mef.nrp.impl.AbstractTestWithTopo;
+import org.opendaylight.unimgr.mef.nrp.template.TemplateConstants;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.tapitopology.rev170227.topology.context.Topology;
+
+import static org.junit.Assert.*;
+
+/**
+ * A simple integration test to look at the handler
+ * @author bartosz.michalik@amartus.com
+ */
+public class TopologyDataHandlerTest extends AbstractTestWithTopo {
+
+ private TopologyDataHandler topologyDataHandler;
+
+ @Before
+ public void testSetup() {
+ topologyDataHandler = new TopologyDataHandler(dataBroker);
+ }
+
+ @Test
+ public void init() throws Exception {
+ //having
+ topologyDataHandler.init();
+
+ //then
+ ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();
+ Topology t = new NrpDao(tx).getTopology(TapiConstants.PRESTO_SYSTEM_TOPO);
+ assertNotNull(t.getNode());
+ assertTrue(t.getNode().stream().anyMatch(n -> n.getUuid().getValue().equals(TemplateConstants.DRIVER_ID)));
+
+ }
+
+}
\ No newline at end of file