This patch also fixes all package names to start with org.opendaylight.unimgr and
cleans up many reported checkstyle errors in unimgr-impl.
Change-Id: I83d48fd9c8b7bcf64ea27456ece7b362f60b8d2b
Signed-off-by: Donald Hunter <donaldh@cisco.com>
+++ /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
--->
-<snapshot>
- <required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:unimgr:impl?module=unimgr-impl&revision=2015-10-12</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:unimgr:cisco-xr-driver:impl?module=unimgr-cisco-xr-driver-impl&revision=2016-05-18</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:unimgr:cisco-xr-driver:impl">prefix:unimgr-cisco-xr-driver</type>
- <name>unimgr-cisco-xr-driver-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>
- <data-broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
- <name>binding-data-broker</name>
- </data-broker>
- </module>
- </modules>
- </data>
- </configuration>
-</snapshot>
+++ /dev/null
-/*
- * Copyright (c) 2016 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.mef.nrp.cisco.xr;
-
-import org.mef.nrp.impl.ActivationDriverRepoService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-
-public class CiscoXRDriverProvider implements BindingAwareProvider, AutoCloseable {
-
- public CiscoXRDriverProvider() {
- }
-
- @Override
- public void onSessionInitiated(ProviderContext session) {
-
- final BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- ServiceReference<ActivationDriverRepoService> serviceRef =
- context.getServiceReference(ActivationDriverRepoService.class);
- ActivationDriverRepoService driverRepo = context.getService(serviceRef);
-
- L2vpnXconnectDriverBuilder l2vpnXconnectDriverBuilder = new L2vpnXconnectDriverBuilder();
- l2vpnXconnectDriverBuilder.onSessionInitialized(session);
- driverRepo.bindBuilder(l2vpnXconnectDriverBuilder);
-
- L2vpnBridgeDriverBuilder l2vpnBridgeDriverBuilder = new L2vpnBridgeDriverBuilder();
- l2vpnBridgeDriverBuilder.onSessionInitialized(session);
- driverRepo.bindBuilder(l2vpnBridgeDriverBuilder);
- }
-
- @Override
- public void close() throws Exception {
- // TODO Auto-generated method stub
- }
-}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr;
import java.util.LinkedList;
import java.util.List;
-import org.mef.nrp.impl.MountPointHelper;
-import org.mef.nrp.impl.ResourceActivator;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.MountPointHelper;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivator;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceActive;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurations;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurationsBuilder;
p2pXconnectsBuilder.setP2pXconnect(p2pXconnects);
XconnectGroupBuilder xconnectGroupBuilder = new XconnectGroupBuilder();
- xconnectGroupBuilder.setKey(new XconnectGroupKey(new CiscoIosXrString("local")));
- xconnectGroupBuilder.setName(new CiscoIosXrString("local")).setP2pXconnects(p2pXconnectsBuilder.build());
+ xconnectGroupBuilder.setKey(new XconnectGroupKey(new CiscoIosXrString(outerName)));
+ xconnectGroupBuilder.setName(new CiscoIosXrString(outerName)).setP2pXconnects(p2pXconnectsBuilder.build());
List<XconnectGroup> xconnectGroups = new LinkedList<>();
xconnectGroups.add(xconnectGroupBuilder.build());
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr;
import java.util.Optional;
-import org.mef.nrp.impl.ActivationDriver;
-import org.mef.nrp.impl.ActivationDriverBuilder;
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;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
* Provides drivers for binding two ports on the same node.
* @author bartosz.michalik@amartus.com
*/
-public class L2vpnBridgeDriverBuilder implements ActivationDriverBuilder, BindingAwareConsumer {
+public class L2vpnBridgeDriverBuilder implements ActivationDriverBuilder {
private L2vpnBridgeActivator activator;
- @Override
- public void onSessionInitialized(BindingAwareBroker.ConsumerContext session) {
- DataBroker dataBroker = session.getSALService(DataBroker.class);
- MountPointService mountService = session.getSALService(MountPointService.class);
- activator = new L2vpnBridgeActivator(dataBroker, mountService);
+ private static final String GROUP_NAME = "local";
+
+ public L2vpnBridgeDriverBuilder(DataBroker dataBroker, MountPointService mountPointService) {
+ activator = new L2vpnBridgeActivator(dataBroker, mountPointService);
}
@Override
protected ActivationDriver getDriver() {
final ActivationDriver driver = new ActivationDriver() {
- public GForwardingConstruct ctx;
public GFcPort aEnd;
public GFcPort zEnd;
public void initialize(GFcPort from, GFcPort to, GForwardingConstruct ctx) {
this.zEnd = to;
this.aEnd = from;
- this.ctx = ctx;
}
@Override
public void activate() {
- String id = ctx.getUuid();
long mtu = 1500;
- String outerName = "outer";
- String innerName = "inner";
String aEndNodeName = aEnd.getLtpRefList().get(0).getValue().split(":")[0];
- activator.activate(aEndNodeName, outerName, innerName, aEnd, zEnd, mtu);
+ activator.activate(aEndNodeName, GROUP_NAME, GROUP_NAME, aEnd, zEnd, mtu);
}
@Override
public void deactivate() {
- String id = ctx.getUuid();
long mtu = 1500;
- String outerName = "outer";
- String innerName = "inner";
String aEndNodeName = aEnd.getLtpRefList().get(0).getValue().split(":")[0];
- activator.deactivate(aEndNodeName, outerName, innerName, aEnd, zEnd, mtu);
+ activator.deactivate(aEndNodeName, GROUP_NAME, GROUP_NAME, aEnd, zEnd, mtu);
}
@Override
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
-import org.mef.nrp.impl.MountPointHelper;
-import org.mef.nrp.impl.ResourceActivator;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.MountPointHelper;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivator;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceActive;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurations;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurationsBuilder;
neighborLoopback = "127.0.0.1";
}
- Ipv4AddressNoZone neighborAddress = new Ipv4AddressNoZone(neighborLoopback);
InterfaceActive intActive = new InterfaceActive("act");
InstanceIdentifier<P2pXconnect> p2pId = InstanceIdentifier.builder(L2vpn.class).child(Database.class)
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr;
import java.util.Optional;
-import org.mef.nrp.impl.ActivationDriver;
-import org.mef.nrp.impl.ActivationDriverBuilder;
-import org.mef.nrp.impl.FixedServiceNaming;
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;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.common.FixedServiceNaming;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
* Xconnect builder (FIXME no decision logic yet)
* @author bartosz.michalik@amartus.com
*/
-public class L2vpnXconnectDriverBuilder implements ActivationDriverBuilder, BindingAwareConsumer {
+public class L2vpnXconnectDriverBuilder implements ActivationDriverBuilder {
private final FixedServiceNaming namingProvider;
private L2vpnXconnectActivator xconnectActivator;
- private static DataBroker dataBroker;
- private static MountPointService mountService;
- @Override
- public void onSessionInitialized(BindingAwareBroker.ConsumerContext session) {
- dataBroker = session.getSALService(DataBroker.class);
- mountService = session.getSALService(MountPointService.class);
- xconnectActivator = new L2vpnXconnectActivator(dataBroker, mountService);
- }
-
- public L2vpnXconnectDriverBuilder() {
- this.namingProvider = new FixedServiceNaming();
+ public L2vpnXconnectDriverBuilder(DataBroker dataBroker, MountPointService mountPointService) {
+ xconnectActivator = new L2vpnXconnectActivator(dataBroker, mountPointService);
+ namingProvider = new FixedServiceNaming();
}
@Override
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.cisco.xr.driver.impl.rev160518;
-
-import org.mef.nrp.cisco.xr.CiscoXRDriverProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-
-public class UnimgrXRDriverModule extends
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.cisco.xr.driver.impl.rev160518.AbstractUnimgrXRDriverModule {
-
- public UnimgrXRDriverModule(
- org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public UnimgrXRDriverModule(
- 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.unimgr.cisco.xr.driver.impl.rev160518.UnimgrXRDriverModule 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 CiscoXRDriverProvider provider = new CiscoXRDriverProvider();
-
- BindingAwareBroker broker = getBrokerDependency();
- broker.registerProvider(provider);
-
- return provider;
- }
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: unimgr-cisco-xr-driver-impl yang module local name: unimgr-cisco-xr-driver
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed May 18 16:03:22 BST 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.unimgr.cisco.xr.driver.impl.rev160518;
-public class UnimgrXRDriverModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.cisco.xr.driver.impl.rev160518.AbstractUnimgrXRDriverModuleFactory {
-
-}
--- /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" />
+ <reference id="mountPointService" interface="org.opendaylight.controller.md.sal.binding.api.MountPointService" />
+
+ <service id="bridgeDriverService" interface="org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder">
+ <bean class="org.opendaylight.unimgr.mef.nrp.cisco.xr.L2vpnBridgeDriverBuilder">
+ <argument ref="dataBroker" />
+ <argument ref="mountPointService" />
+ </bean>
+ </service>
+
+ <service id="xconnectDriverService" interface="org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder">
+ <bean class="org.opendaylight.unimgr.mef.nrp.cisco.xr.L2vpnXconnectDriverBuilder">
+ <argument ref="dataBroker" />
+ <argument ref="mountPointService" />
+ </bean>
+ </service>
+
+</blueprint>
+++ /dev/null
-/*
- * 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
- */
-module unimgr-cisco-xr-driver-impl {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:unimgr:cisco-xr-driver:impl";
- prefix "unimgr-cisco-xr-driver-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 unimgr project";
-
- revision "2016-05-18" {
- description
- "Updated revision.";
- }
-
- identity unimgr-cisco-xr-driver {
- base config:module-type;
- config:java-name-prefix UnimgrXRDriver;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case unimgr-cisco-xr-driver {
- when "/config:modules/config:module/config:type = 'unimgr-cisco-xr-driver'";
- container broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity md-sal-binding:binding-broker-osgi-registry;
- }
- }
- }
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity md-sal-binding:binding-async-data-broker;
- }
- }
- }
- }
- }
-}
<version>0.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
+ <properties>
+ <checkstyle.skip>true</checkstyle.skip>
+ </properties>
+
<dependencies>
+
+ <dependency>
+ <groupId>org.opendaylight.unimgr</groupId>
+ <artifactId>unimgr-impl</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-inet-types-2013-07-15</artifactId>
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.edgeassure;
import java.util.LinkedList;
import java.util.List;
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.unimgr.mef.nrp.common.MountPointHelper;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivator;
import org.opendaylight.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev160229.Identifier45;
import org.opendaylight.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev160317.MefServices;
import org.opendaylight.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service.rev160317.mef.services.Uni;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.edgeassure;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.common.FixedServiceNaming;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
<artifactId>unimgr-cisco-xr-driver</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>unimgr-cisco-xr-driver</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
<dependency>
<groupId>org.opendaylight.unimgr</groupId>
<artifactId>cisco-xrmodels</artifactId>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${ovsdb.version}'>odl-ovsdb-southbound-impl</feature>
<feature version='${project.version}'>odl-unimgr-api</feature>
+ <!-- TODO these features should be dependencies of drivers not unimgr itself -->
<feature version='${netconf.version}'>odl-netconf-connector</feature>
<feature version='${netconf.version}'>odl-netconf-connector-ssh</feature>
- <bundle>mvn:org.opendaylight.unimgr/edgeassure-1000/{{VERSION}}</bundle>
+ <!-- FIXME deliver as a separate bundle/feature -->
+ <!-- <bundle>mvn:org.opendaylight.unimgr/edgeassure-1000/{{VERSION}}</bundle> -->
<bundle>mvn:org.opendaylight.unimgr/unimgr-impl/{{VERSION}}</bundle>
<configfile finalname="${configfile.directory}/unimgr.xml">mvn:org.opendaylight.unimgr/unimgr-impl/{{VERSION}}/xml/config</configfile>
</feature>
<feature version='${project.version}'>odl-unimgr</feature>
<bundle>mvn:org.opendaylight.unimgr/cisco-xrmodels/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.unimgr/unimgr-cisco-xr-driver/{{VERSION}}</bundle>
- <configfile finalname="${configfile.directory}/unimgr-cisco-xr-driver.xml">mvn:org.opendaylight.unimgr/unimgr-cisco-xr-driver/{{VERSION}}/xml/config</configfile>
</feature>
</features>
<configuration>
<instructions>
<Import-Package>*</Import-Package>
- <Export-Package>org.mef.nrp.impl, org.opendaylight.unimgr.api
+ <Export-Package>
+ org.opendaylight.unimgr.mef.nrp.common,
+ org.opendaylight.unimgr.mef.nrp.api,
+ org.opendaylight.unimgr.api
</Export-Package>
</instructions>
</configuration>
<version>${ovsdb.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.unimgr</groupId>
- <artifactId>edgeassure-1000</artifactId>
- <version>${project.version}</version>
- </dependency>
-
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-topology</artifactId>
and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
-->
<snapshot>
- <required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:unimgr:impl?module=unimgr-impl&revision=2015-10-12</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>
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:unimgr:impl?module=unimgr-impl&revision=2016-05-25</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:unimgr:impl">prefix:unimgr</type>
- <name>unimgr-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>
+ <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:unimgr:impl">prefix:unimgr</type>
+ <name>unimgr-default</name>
+ </module>
+ </modules>
+ </data>
+ </configuration>
</snapshot>
+++ /dev/null
-/*
- * Copyright (c) 2016 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.mef.nrp.impl;
-
-import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
-
-/**
- * Device facing SPI for activating or deactivating a fragment of an NRP ForwardingConstruct on a single device.
- */
-public interface ResourceActivator {
-
- /**
- * Activate a service fragment on the node identified by nodeName.
- *
- * @param nodeName the name of node in network topology
- * @param outerName name of outer activation construct
- * @param innerName name of inner activation construct
- * @param flowPoint the fc-port to be activated
- * @param neighbor the neighbor fc-port
- * @param mtu the desired MTU for this forwarding construct
- */
- public void activate(String nodeName, String outerName, String innerName, GFcPort flowPoint, GFcPort neighbor, long mtu);
-
- /**
- * Deactivate a service fragment on the node identified by nodeName.
- *
- * @param nodeName the name of node in network topology
- * @param outerName name of outer deactivation construct
- * @param innerName name of inner deactivation construct
- * @param flowPoint the fc-port to be deactivated
- * @param neighbor the neighbor fc-port
- * @param mtu the desired MTU for this forwarding construct
- */
- public void deactivate(String nodeName, String outerName, String innerName, GFcPort flowPoint, GFcPort neighbor, long mtu);
-}
protected DataTreeModification<D> dataObject;
/**
- * Abstract command basic constructor
+ * Abstract command basic constructor.
* @param dataBroker
* @param dataObject
*/
}
/**
- * Abstract execute method
+ * Abstract execute method.
*/
public abstract void execute();
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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
* @author mohamed el-serngawy
* @param <D> extended data object
*/
-public abstract class UnimgrDataTreeChangeListener<D extends DataObject> implements DataTreeChangeListener<D>, AutoCloseable {
+public abstract class UnimgrDataTreeChangeListener<D extends DataObject>
+ implements DataTreeChangeListener<D>, AutoCloseable {
protected DataBroker dataBroker;
case DELETE:
remove(change);
break;
+ default:
+ break;
}
}
}
/**
- * method should implements the added data object command
- * @param newDataObject
+ * Method should implements the added data object command.
+ * @param newDataObject newly added object
*/
public abstract void add(DataTreeModification<D> newDataObject);
/**
- * method should implements the removed data object command
- * @param removedDataObject
+ * Method should implements the removed data object command.
+ * @param removedDataObject existing object being removed
*/
public abstract void remove(DataTreeModification<D> removedDataObject);
/**
- * method should implements the updated data object command
- * @param modifiedDataObject
+ * Method should implements the updated data object command.
+ * @param modifiedDataObject existing object being modified
*/
public abstract void update(DataTreeModification<D> modifiedDataObject);
}
import javax.annotation.Nonnull;
-import org.mef.nrp.impl.ActivationDriver;
-import org.mef.nrp.impl.ActivationDriverAmbiguousException;
-import org.mef.nrp.impl.ActivationDriverBuilder;
-import org.mef.nrp.impl.ActivationDriverNotFoundException;
-import org.mef.nrp.impl.ActivationDriverRepoService;
-import org.mef.nrp.impl.ActivationTransaction;
-import org.mef.nrp.impl.ForwardingConstructHelper;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverAmbiguousException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverNotFoundException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverRepoService;
+import org.opendaylight.unimgr.mef.nrp.impl.ActivationTransaction;
+import org.opendaylight.unimgr.mef.nrp.impl.ForwardingConstructHelper;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.fcroutelist.FcRoute;
public class FcRouteActivatorService {
private static final Logger LOG = LoggerFactory.getLogger(FcRouteActivatorService.class);
private ActivationDriverRepoService activationRepoService;
- final private ReentrantReadWriteLock lock;
+ private final ReentrantReadWriteLock lock;
- public FcRouteActivatorService() {
+ public FcRouteActivatorService(ActivationDriverRepoService activationRepoService) {
+ this.activationRepoService = activationRepoService;
lock = new ReentrantReadWriteLock();
}
+ /**
+ * Activate a MEF FcRoute.
+ * @param route the new route to activate
+ */
public void activate(@Nonnull FcRoute route) {
- for(GForwardingConstruct fwdC : route.getForwardingConstruct()) {
+ for (GForwardingConstruct fwdC : route.getForwardingConstruct()) {
Optional<ActivationTransaction> tx = prepareTransaction(fwdC);
if (tx.isPresent()) {
tx.get().activate();
}
}
+ /**
+ * Deactivate a MEF FcRoute.
+ * @param route the existing route to deactivate
+ */
public void deactivate(@Nonnull FcRoute route) {
- for(GForwardingConstruct fwdC : route.getForwardingConstruct()) {
+ for (GForwardingConstruct fwdC : route.getForwardingConstruct()) {
Optional<ActivationTransaction> tx = prepareTransaction(fwdC);
if (tx.isPresent()) {
tx.get().deactivate();
final GFcPort a = list.get(0);
final GFcPort z = list.get(1);
- return ForwardingConstructHelper.isTheSameNode(fwdC) ? getTxForNode(a,z, fwdC) :
- getTxForMultiNode(a,z, fwdC);
+ return ForwardingConstructHelper.isTheSameNode(fwdC)
+ ? getTxForNode(a,z, fwdC) : getTxForMultiNode(a,z, fwdC);
}
- private Optional<ActivationTransaction> getTxForMultiNode(GFcPort a, GFcPort z, GForwardingConstruct fwdC) {
+ private Optional<ActivationTransaction> getTxForNode(GFcPort portA, GFcPort portZ, GForwardingConstruct fwdC) {
lock.readLock().lock();
try {
final ActivationDriverBuilder.BuilderContext ctx = new ActivationDriverBuilder.BuilderContext();
- ActivationDriver activator = activationRepoService.getDriver(a, z, ctx);
+ ActivationDriver activator = activationRepoService.getDriver(portA, portZ, ctx);
- activator.initialize(a, z, fwdC);
+ activator.initialize(portA, portZ, fwdC);
ActivationTransaction tx = new ActivationTransaction();
tx.addDriver(activator);
return Optional.of(tx);
- } catch(ActivationDriverNotFoundException e) {
- LOG.warn("No unique activation driver found for {} <-> {}", a, z);
+ } catch (ActivationDriverNotFoundException e) {
+ LOG.warn("No unique activation driver found for {} <-> {}", portA, portZ);
return Optional.empty();
- } catch(ActivationDriverAmbiguousException e) {
- LOG.warn("Multiple activation driver found for {} <-> {}", z, a);
+ } catch (ActivationDriverAmbiguousException e) {
+ LOG.warn("Multiple activation driver found for {} <-> {}", portZ, portA);
return Optional.empty();
} catch (Exception e) {
LOG.error("driver initialization exception", e);
}
}
- private Optional<ActivationTransaction> getTxForNode(GFcPort a, GFcPort z, GForwardingConstruct fwdC) {
+ private Optional<ActivationTransaction> getTxForMultiNode(GFcPort portA, GFcPort portZ, GForwardingConstruct fwdC) {
//1. find and initialize drivers
- Optional<ActivationDriver> aActivator;
- Optional<ActivationDriver> zActivator;
lock.readLock().lock();
try {
final ActivationDriverBuilder.BuilderContext ctx = new ActivationDriverBuilder.BuilderContext();
ctx.put(GForwardingConstruct.class.getName(), fwdC);
- aActivator = findDriver(a, ctx);
- zActivator = findDriver(z, ctx);
+ Optional<ActivationDriver> aendActivator = findDriver(portA, ctx);
+ Optional<ActivationDriver> zendActivator = findDriver(portZ, ctx);
+
+ if (aendActivator.isPresent() && zendActivator.isPresent()) {
+ aendActivator.get().initialize(portA, portZ, fwdC);
+ zendActivator.get().initialize(portZ, portA, fwdC);
+
+ final ActivationTransaction tx = new ActivationTransaction();
+ tx.addDriver(aendActivator.get());
+ tx.addDriver(zendActivator.get());
- if (aActivator.isPresent() && zActivator.isPresent()) {
- aActivator.get().initialize(a, z, fwdC);
- zActivator.get().initialize(z, a, fwdC);
+ return Optional.of(tx);
} else {
// ??? TODO improve comment for better traceability
LOG.error("drivers for both ends needed");
} finally {
lock.readLock().unlock();
}
-
- final ActivationTransaction tx = new ActivationTransaction();
- tx.addDriver(aActivator.get());
- tx.addDriver(zActivator.get());
-
- return Optional.of(tx);
}
protected Optional<ActivationDriver> findDriver(GFcPort port, ActivationDriverBuilder.BuilderContext fwdC) {
- if(activationRepoService == null) {
+ if (activationRepoService == null) {
LOG.warn("Activation Driver repo is not initialized");
return Optional.empty();
}
try {
return Optional.ofNullable(activationRepoService.getDriver(port, fwdC));
- } catch(ActivationDriverNotFoundException e) {
- LOG.warn("No unique activation driver found for {}", port);
+ } catch (ActivationDriverNotFoundException e) {
+ LOG.warn("No activation driver found for {}", port);
return Optional.empty();
- } catch(ActivationDriverAmbiguousException e) {
+ } catch (ActivationDriverAmbiguousException e) {
LOG.warn("Multiple activation driver found for {}", port);
return Optional.empty();
}
}
+ /**
+ * Set the activation driver repository service.
+ * @param activationRepoService service to use
+ */
public void setActivationRepoService(ActivationDriverRepoService activationRepoService) {
lock.writeLock().lock();
this.activationRepoService = activationRepoService;
lock.writeLock().unlock();
}
+ /**
+ * Unset the activation driver repository service.
+ */
public void unsetActivationRepoService() {
lock.writeLock().lock();
this.activationRepoService = null;
}
static final class Context {
- final GFcPort a;
- final GFcPort z;
+ final GFcPort portA;
+ final GFcPort portZ;
final GForwardingConstruct fwC;
- public Context(GFcPort a, GFcPort z, GForwardingConstruct fwC) {
- this.a = a;
- this.z = z;
+ public Context(GFcPort portA, GFcPort portZ, GForwardingConstruct fwC) {
+ this.portA = portA;
+ this.portZ = portZ;
this.fwC = fwC;
}
}
import java.util.Collection;
-import org.mef.nrp.impl.ActivationDriverRepoService;
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.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverRepoService;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.FcRouteList;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.fcroutelist.FcRoute;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
* NRP top level change model listener
* @author bartosz.michalik@amartus.com
*/
-public class FCRouteChangeListener implements DataTreeChangeListener<FcRoute>, AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(FCRouteChangeListener.class);
- private final ListenerRegistration<FCRouteChangeListener> listener;
+public class FcRouteChangeListener implements DataTreeChangeListener<FcRoute>, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(FcRouteChangeListener.class);
+ private final ListenerRegistration<FcRouteChangeListener> listener;
private final FcRouteActivatorService routeActivator;
- private volatile ActivationDriverRepoService activationRepoService;
+ private final ActivationDriverRepoService activationRepoService;
+
+ public FcRouteChangeListener(DataBroker dataBroker, ActivationDriverRepoService activationRepoService) {
+ this.activationRepoService = activationRepoService;
+ routeActivator = new FcRouteActivatorService(activationRepoService);
- public FCRouteChangeListener(DataBroker dataBroker) {
final InstanceIdentifier<FcRoute> fwPath = getFwConstructsPath();
- final DataTreeIdentifier<FcRoute> dataTreeIid = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, fwPath);
+ final DataTreeIdentifier<FcRoute> dataTreeIid =
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, fwPath);
listener = dataBroker.registerDataTreeChangeListener(dataTreeIid, this);
- this.routeActivator = new FcRouteActivatorService();
- LOG.info("FCRouteChangeListener created and registered");
+ LOG.info("FcRouteChangeListener created and registered");
}
/**
@Override
public void onDataTreeChanged(Collection<DataTreeModification<FcRoute>> collection) {
//TODO add lock for concurrency support
- if(activationRepoService == null) {
- //TODO improve comment
+ if (activationRepoService == null) {
LOG.warn("ActivationDriverRepoService is not ready yet - ignoring request");
return;
}
//TO overcome whole subtree change event
boolean update = change.getRootNode().getDataBefore() != null;
- if(update) {
+ if (update) {
update(change);
} else {
add(change);
case DELETE:
remove(change);
break;
+ default:
+ break;
}
}
}
- public void add(DataTreeModification<FcRoute> newDataObject) {
+ protected void add(DataTreeModification<FcRoute> newDataObject) {
//TODO: Refine the logged addition
LOG.debug("FcRoute add event received {}", newDataObject);
routeActivator.activate(newDataObject.getRootNode().getDataAfter());
}
- public void remove(DataTreeModification<FcRoute> removedDataObject) {
+ protected void remove(DataTreeModification<FcRoute> removedDataObject) {
//TODO: Refine the logged removal
LOG.debug("FcRoute remove event received {}", removedDataObject);
routeActivator.deactivate(removedDataObject.getRootNode().getDataBefore());
}
- public void update(DataTreeModification<FcRoute> modifiedDataObject) {
+ protected void update(DataTreeModification<FcRoute> modifiedDataObject) {
//TODO: Refine the logged modification
LOG.debug("FcRoute update event received {}", modifiedDataObject);
return path;
}
-
- public void setActivationDriverRepoService(ActivationDriverRepoService service) {
- this.activationRepoService = service;
- routeActivator.setActivationRepoService(service);
- }
-
- public void unsetActivationDriverRepoService() {
- this.activationRepoService = null;
- routeActivator.unsetActivationRepoService();
- }
}
import java.util.List;
-import org.mef.nrp.impl.ActivationDriverRepoService;
-import org.mef.nrp.impl.ActivationDriverRepoServiceImpl;
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.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private EvcDataTreeChangeListener evcListener;
private OvsNodeDataTreeChangeListener ovsListener;
private UniDataTreeChangeListener uniListener;
- private ServiceRegistration<IUnimgrConsoleProvider> unimgrConsoleRegistration;
- private FCRouteChangeListener fwConstructListener;
- public UnimgrProvider() {
+ public UnimgrProvider(DataBroker dataBroker) {
LOG.info("Unimgr provider initialized");
+ this.dataBroker = dataBroker;
}
@Override
return UniUtils.createUniNode(dataBroker, uniAug);
}
- @Override
- public void close() throws Exception {
- LOG.info("UnimgrProvider Closed");
- unimgrConsoleRegistration.unregister();
- uniListener.close();
- evcListener.close();
- ovsListener.close();
- fwConstructListener.close();
- }
-
@Override
public Evc getEvc(final String uuid) {
// TODO Auto-generated method stub
}
@Override
- public void onSessionInitiated(final ProviderContext session) {
- LOG.info("UnimgrProvider Session Initiated");
+ public void onSessionInitiated(ProviderContext providerContext) {
+ //not called as provider is not registered in ODL context
+ }
- // Retrieve the data broker to create transactions
- dataBroker = session.getSALService(DataBroker.class);
- // Register the unimgr OSGi CLI
- final BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class, this, null);
+ /**
+ * Initialization method for UnimgrProvider, used by blueprint.
+ */
+ public void init() {
+ LOG.info("UnimgrProvider Session Initiated");
// Register the data trees change listener
uniListener = new UniDataTreeChangeListener(dataBroker);
evcListener = new EvcDataTreeChangeListener(dataBroker);
ovsListener = new OvsNodeDataTreeChangeListener(dataBroker);
- ActivationDriverRepoService activationDriverRepoService = new ActivationDriverRepoServiceImpl();
- context.registerService(ActivationDriverRepoService.class, activationDriverRepoService, null);
-
- fwConstructListener = new FCRouteChangeListener(dataBroker);
- fwConstructListener.setActivationDriverRepoService(activationDriverRepoService);
-
// Initialize operational and default config data in MD-SAL data store
initDatastore(LogicalDatastoreType.CONFIGURATION,
UnimgrConstants.UNI_TOPOLOGY_ID);
UnimgrConstants.EVC_TOPOLOGY_ID);
}
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("UnimgrProvider Closed");
+ uniListener.close();
+ evcListener.close();
+ ovsListener.close();
+ }
+
@Override
public boolean removeEvc(final String uuid) {
// TODO Auto-generated method stub
@Override
public boolean removeUni(final IpAddress ipAddress) {
- final InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
+ final InstanceIdentifier<Node> iidUni =
+ UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
if (iidUni == null) {
return false;
}
}
@Override
- public boolean updateEvc(final InstanceIdentifier<Link> evcKey, final EvcAugmentation evc, final UniSource uniSource,
- final UniDest uniDest) {
+ public boolean updateEvc(final InstanceIdentifier<Link> evcKey, final EvcAugmentation evc,
+ final UniSource uniSource, final UniDest uniDest) {
final InstanceIdentifier<?> sourceUniIid = uniSource.getUni();
final InstanceIdentifier<?> destinationUniIid = uniDest.getUni();
return EvcUtils.updateEvcNode(LogicalDatastoreType.CONFIGURATION, evcKey, evc, sourceUniIid,
* 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.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.api;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
public interface ActivationDriver {
/**
- * Called in case all drivers in the transaction has succeeded
+ * Called in case all drivers in the transaction has succeeded.
*/
void commit();
/**
- * Called in case any of drivers in the transaction has failed
+ * Called in case any of drivers in the transaction has failed.
*/
void rollback();
/**
- * Set state for the driver
+ * Set state for the driver for a (de)activation transaction.
* @param from near end
* @param to far end
* @param context context
void initialize(GFcPort from, GFcPort to, GForwardingConstruct context);
/**
- * Activates the port from
+ * Performs the activation action.
*/
void activate();
/**
- * Deactivates the port from
+ * Performs the deactivation action.
*/
void deactivate();
/**
- * Influences the order in which drivers are called within the transaction
+ * Influences the order in which drivers are called within the transaction.
* @return int priority of this driver when resoving ambiguity
*/
int priority();
-
-
-
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.api;
/**
* This exception indicates that multiple activation drivers are candidates for activating a service. The service
* will not be activated because the system failed to select a single driver candidate.
*/
public class ActivationDriverAmbiguousException extends RuntimeException {
+ private static final long serialVersionUID = 3299218135930759678L;
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.api;
import java.util.HashSet;
import java.util.Map;
/**
* Get driver for two ports.
- * @param aPort a-end port
- * @param zPort z-end port
+ * @param portA a-end port
+ * @param portZ z-end port
* @param context blackboard for recording state during driver selection
* @return {@link Optional#empty()} in case it cannot be instantiated for a port, driver otherwise
*/
- Optional<ActivationDriver> driverFor(GFcPort aPort, GFcPort zPort, BuilderContext context);
+ Optional<ActivationDriver> driverFor(GFcPort portA, GFcPort portZ, BuilderContext context);
- /***
- * Blackboard pattern that allows for passing the context information between {@link ActivationDriverBuilder}s taking part in transaction
+ /**
+ * Blackboard pattern that allows for passing the context information between
+ * {@link ActivationDriverBuilder}s taking part in transaction.
*/
class BuilderContext {
private Map<String, Object> ctx = new ConcurrentHashMap<>();
/**
* Put value to blackboard.
- * @param k key
+ * @param key key
* @param value value object
*/
- public void put(String k, Object value) {
- ctx.put(k, value);
+ public void put(String key, Object value) {
+ ctx.put(key, value);
}
/**
* Remove value from blackboard.
- * @param k key
+ * @param key key
*/
- public void remove(String k) {
- ctx.remove(k);
+ public void remove(String key) {
+ ctx.remove(key);
}
/**
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.api;
/**
* his exception indicates that no activation drivers was found for activating a service. The service
* will not be activated because the system failed to identify any driver candidate.
*/
public class ActivationDriverNotFoundException extends RuntimeException {
+ private static final long serialVersionUID = 8093501625481543532L;
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.api;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
*/
public interface ActivationDriverRepoService {
- void bindBuilder(ActivationDriverBuilder builder);
-
- void unbindBuilder(ActivationDriverBuilder builder);
-
/**
* Get driver for a port.
* @param port to
/**
* Get driver for two ports on a single device.
- * @param aPort from port
- * @param zPort to port
+ * @param portA from port
+ * @param portZ to port
* @param context blackboard for recording state during driver selection
* @return activation driver
* @throws ActivationDriverAmbiguousException when multiple drivers declare they can configure ports
* @throws ActivationDriverNotFoundException when no driver found for ports
*/
- ActivationDriver getDriver(GFcPort aPort, GFcPort zPort, ActivationDriverBuilder.BuilderContext context);
+ ActivationDriver getDriver(GFcPort portA, GFcPort portZ, ActivationDriverBuilder.BuilderContext context);
}
\ No newline at end of file
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.common;
/**
* This is a placeholder class for implementing service naming when activating and deactivating MEF services.
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.common;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPoint;
public class MountPointHelper {
- /*
+ /**
* Find a node's NETCONF mount point and then retrieve its DataBroker.
- *
* e.g.
* http://localhost:8080/restconf/config/network-topology:network-topology/
- * topology/topology-netconf/node/<nodeName>/yang-ext:mount/
+ * topology/topology-netconf/node/{nodeName}/yang-ext:mount/
*/
public static Optional<DataBroker> getDataBroker(MountPointService mountService, String nodeName) {
NodeId nodeId = new NodeId(nodeName);
--- /dev/null
+/*
+ * Copyright (c) 2016 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.common;
+
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
+
+/**
+ * Device facing SPI for activating or deactivating a fragment of an NRP
+ * ForwardingConstruct on a single device.
+ */
+public interface ResourceActivator {
+
+ /**
+ * Activate a service fragment on the node identified by nodeName.
+ *
+ * @param nodeName
+ * the name of node in network topology
+ * @param outerName
+ * name of outer activation construct
+ * @param innerName
+ * name of inner activation construct
+ * @param flowPoint
+ * the fc-port to be activated
+ * @param neighbor
+ * the neighbor fc-port
+ * @param mtu
+ * the desired MTU for this forwarding construct
+ */
+ public void activate(String nodeName, String outerName, String innerName, GFcPort flowPoint, GFcPort neighbor,
+ long mtu);
+
+ /**
+ * Deactivate a service fragment on the node identified by nodeName.
+ *
+ * @param nodeName
+ * the name of node in network topology
+ * @param outerName
+ * name of outer deactivation construct
+ * @param innerName
+ * name of inner deactivation construct
+ * @param flowPoint
+ * the fc-port to be deactivated
+ * @param neighbor
+ * the neighbor fc-port
+ * @param mtu
+ * the desired MTU for this forwarding construct
+ */
+ public void deactivate(String nodeName, String outerName, String innerName, GFcPort flowPoint, GFcPort neighbor,
+ long mtu);
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.common;
/**
* This SPI is used to create resource names when constructing device configuration.
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.impl;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverAmbiguousException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverNotFoundException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverRepoService;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * Default application repo that is populated with the application driver builders registered as OSGi services.
+ *
* @author alex.feigin@hpe.com
+ * @author bartosz.michalik@amartus.com [modifications]
*/
public class ActivationDriverRepoServiceImpl implements ActivationDriverRepoService {
private static final Logger LOG = LoggerFactory.getLogger(ActivationDriverRepoServiceImpl.class);
- private Collection<ActivationDriverBuilder> builders = ConcurrentHashMap.newKeySet();
-
+ private final Collection<ActivationDriverBuilder> builders;
- /* (non-Javadoc)
- * @see org.mef.nrp.impl.ActivationDriverRepoService#bindBuilder(org.mef.nrp.impl.ActivationDriverBuilder)
- */
- @Override
- public void bindBuilder(ActivationDriverBuilder builder) {
- if (builder == null) {
- return;
- }
- LOG.info("ActivationDriverRepoService.bindBuilder got [{}] instance", builder.getClass().getSimpleName());
- builders.add(builder);
+ public ActivationDriverRepoServiceImpl() {
+ this.builders = Collections.emptyList();
}
- /* (non-Javadoc)
- * @see org.mef.nrp.impl.ActivationDriverRepoService#unbindBuilder(org.mef.nrp.impl.ActivationDriverBuilder)
- */
- @Override
- public void unbindBuilder(ActivationDriverBuilder builder) {
- if (builder == null) {
- return;
- }
- LOG.info("ActivationDriverRepoService.unbindBuilder got [{}] instance", builder.getClass().getSimpleName());
- builders.remove(builder);
+ public ActivationDriverRepoServiceImpl(List<ActivationDriverBuilder> builders) {
+ LOG.debug("Activation drivers initialized");
+ this.builders = builders;
}
protected ActivationDriver getDriver(Function<ActivationDriverBuilder, Optional<ActivationDriver>> driver) {
return drivers.get(0);
}
- public ActivationDriver getDriver(GFcPort aPort, GFcPort zPort, ActivationDriverBuilder.BuilderContext context) {
- return getDriver(x -> x.driverFor(aPort, zPort, context));
+ public ActivationDriver getDriver(GFcPort portA, GFcPort portZ, ActivationDriverBuilder.BuilderContext context) {
+ return getDriver(x -> x.driverFor(portA, portZ, context));
}
public ActivationDriver getDriver(GFcPort port, ActivationDriverBuilder.BuilderContext context) {
return getDriver(x -> x.driverFor(port, context));
}
+
+ public void bind(ActivationDriverBuilder builder) {
+ LOG.debug("builder {} bound", builder);
+ }
+
+ public void unbind(ActivationDriverBuilder builder) {
+ LOG.debug("builder {} unbound", builder);
+ }
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.opendaylight.unimgr.mef.nrp.impl;
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Runs activation over multiple @ drivers.
*
drivers.add(driver);
}
+ /**
+ * Activate the contents of this transaction.
+ */
public void activate() {
sortDrivers();
try {
- for(ActivationDriver d: drivers) { d.activate(); }
+ for (ActivationDriver d: drivers) {
+ d.activate();
+ }
commit();
LOG.info("Activate transaction successful");
} catch (Exception e) {
}
}
-
+ /**
+ * Deactivate the contents of this transaction.
+ */
public void deactivate() {
sortDrivers();
try {
- for(ActivationDriver d: drivers) { d.deactivate(); }
+ for (ActivationDriver d: drivers) {
+ d.deactivate();
+ }
LOG.info("Deactivate transaction successful");
commit();
} catch (Exception e) {
}
private void sortDrivers() {
- drivers.sort((a,b) -> a.priority() - b.priority());
+ drivers.sort((driverA, driverB) -> driverA.priority() - driverB.priority());
}
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.impl;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
public void deactivate() {}
@Override
- public int priority() {return Integer.MIN_VALUE;}
+ public int priority() {
+ return Integer.MIN_VALUE;
+ }
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.mef.nrp.impl;
+package org.opendaylight.unimgr.mef.nrp.impl;
+
+import java.util.Objects;
import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
public class ForwardingConstructHelper {
+ /**
+ * Test to see if both ends of a ForwardingConstruct are on the same node.
+ * @param forwardingConstruct the ForwardingConstruct to test
+ * @return true if both ends are on same node
+ */
public static boolean isTheSameNode(GForwardingConstruct forwardingConstruct) {
- String aHost = host(ltp(forwardingConstruct, 0));
- String zHost = host(ltp(forwardingConstruct, 1));
+ String hostA = host(ltp(forwardingConstruct, 0));
+ String hostZ = host(ltp(forwardingConstruct, 1));
- return aHost != null && zHost != null && aHost.equals(zHost);
+ return Objects.equals(hostA, hostZ);
}
public static String ltp(GForwardingConstruct fc, int port) {
}
/**
- * Creates and submit an UNI Node by using the Data contained in the UniAugmentation
+ * Creates and submit an UNI Node by using the Data contained in the UniAugmentation.
* @param dataBroker The instance of the DataBroker to create transactions
* @param uni The UNI's data
* @return true if uni created
}
/**
- * Search the Operation DataStore for a specific UNI
+ * Search the Operation DataStore for a specific UNI.
* @param dataBroker The dataBroker instance to create transactions
* @param ipAddress The IP address of the UNI
* @return An Optional UNI Node
}
/**
- * Retrieve a list of Uni Nodes from the Configuration DataStore
+ * Retrieve a list of Uni Nodes from the Configuration DataStore.
* @param dataBroker The dataBroker instance to create transactions
* @return A list of Uni Nodes from the Config dataStore
*/
if ((topology != null) && (topology.getNode() != null)) {
for (final Node node : topology.getNode()) {
final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
- if ((uniAugmentation != null) && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(ipAddress.getIpv4Address().getValue())) {
+ if ((uniAugmentation != null)
+ && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(
+ ipAddress.getIpv4Address().getValue())) {
return uniAugmentation;
}
}
}
/**
- * Updates a specific Uni Node on a specific DataStore type
+ * Updates a specific Uni Node on a specific DataStore type.
* @param dataStore The datastore type
* @param uniIID The UNI InstanceIdentifier
* @param uni The Uni's data
}
/**
- * Update a specific UNI node on a specific datastore type
+ * Update a specific UNI node on a specific datastore type.
* @param dataStore The datastore type
* @param uniKey The UNI key
* @param uni The Uni's data
return false;
}
+ /**
+ * Convert Speed to string.
+ * @param speedObject schema defined speed object
+ * @return string representation
+ */
public static String getSpeed(Speed speedObject) {
String speed = null;
if (speedObject instanceof Speed10M) {
// map to 10MB
speed = "10000000";
- }
- else if (speedObject instanceof Speed100M) {
+ } else if (speedObject instanceof Speed100M) {
// map to 20MB
speed = "20000000";
- }
- else if (speedObject instanceof Speed1G) {
+ } else if (speedObject instanceof Speed1G) {
// map to 30MB
speed = "30000000";
- }
- else if (speedObject instanceof Speed10G) {
+ } else if (speedObject instanceof Speed10G) {
// map to 40MB
speed = "40000000";
}
return speed;
}
+ /**
+ * Convert string to Speed.
+ * @param speed string representation of speed
+ * @return schema defined speed object
+ */
public static Speed getSpeed(final String speed) {
Speed speedObject = null;
if (speed.equals("10M")) {
speedObject = new Speed10MBuilder().setSpeed10M(true)
.build();
- }
- else if (speed.equals("100M")) {
+ } else if (speed.equals("100M")) {
speedObject = new Speed100MBuilder().setSpeed100M(true)
.build();
- }
- else if (speed.equals("1G")) {
+ } else if (speed.equals("1G")) {
speedObject = new Speed1GBuilder().setSpeed1G(true)
.build();
- }
- else if (speed.equals("10G")) {
+ } else if (speed.equals("10G")) {
speedObject = new Speed10GBuilder().setSpeed10G(true)
.build();
}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.impl.rev151012;
-
-import org.opendaylight.unimgr.impl.UnimgrProvider;
-
-public class UnimgrModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.impl.rev151012.AbstractUnimgrModule {
-
- public UnimgrModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public UnimgrModule(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.unimgr.impl.rev151012.UnimgrModule 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 UnimgrProvider unimgrProvider = new UnimgrProvider();
- getBrokerDependency().registerProvider(unimgrProvider);
- return unimgrProvider;
- }
-
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: unimgr-impl yang module local name: unimgr
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Oct 28 09:02:35 EDT 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.unimgr.impl.rev151012;
-public class UnimgrModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.impl.rev151012.AbstractUnimgrModuleFactory{
-
-}
--- /dev/null
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.impl.rev160525;
+
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
+import org.osgi.framework.BundleContext;
+
+public class UnimgrModule extends AbstractUnimgrModule {
+
+ private BundleContext ctx;
+
+ public UnimgrModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public UnimgrModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, UnimgrModule oldModule, AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ final WaitingServiceTracker<IUnimgrConsoleProvider> tracker = WaitingServiceTracker.create(
+ IUnimgrConsoleProvider.class, ctx);
+ final IUnimgrConsoleProvider provider = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+ return provider;
+ }
+
+ @Override
+ public boolean canReuseInstance(AbstractUnimgrModule oldModule) {
+ return true;
+ }
+
+ public void setBundleContext(BundleContext ctx) {
+ this.ctx = ctx;
+ }
+}
--- /dev/null
+/*
+* Generated file
+*
+* Generated from: yang module name: unimgr-impl yang module local name: unimgr
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Oct 28 09:02:35 EDT 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.unimgr.impl.rev160525;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+public class UnimgrModuleFactory extends AbstractUnimgrModuleFactory {
+
+ @Override
+ public UnimgrModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, UnimgrModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+ final UnimgrModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule, oldInstance, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+
+ @Override
+ public UnimgrModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+ final UnimgrModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+}
+++ /dev/null
-<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
-</blueprint>
\ No newline at end of file
--- /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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true">
+
+ <bean id="unimgrProvider" class="org.opendaylight.unimgr.impl.UnimgrProvider" init-method="init" destroy-method="close">
+ <argument index="0" ref="dataBroker" />
+ <!-- TODO [bmi] extract listeners configuration & registration -->
+ </bean>
+
+ <service id="unimgrProviderService" interface="org.opendaylight.unimgr.api.IUnimgrConsoleProvider" ref="unimgrProvider" odl:type="default" />
+
+ <bean id="activationDriver" class="org.opendaylight.unimgr.mef.nrp.impl.ActivationDriverRepoServiceImpl">
+ <argument ref="driverBuilders" />
+ </bean>
+
+ <bean id="fcRouteListener" class="org.opendaylight.unimgr.impl.FcRouteChangeListener">
+ <argument ref="dataBroker" />
+ <argument ref="activationDriver" />
+ </bean>
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+ <reference-list id="driverBuilders" interface="org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder" availability="optional">
+ <reference-listener bind-method="bind" unbind-method="unbind" ref="activationDriver" />
+ </reference-list>
+</blueprint>
\ No newline at end of file
prefix "unimgr-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 unimgr project";
- revision "2015-10-12" {
+ revision "2016-05-25" {
description
"Updated revision.";
}
augment "/config:modules/config:module/config:configuration" {
case unimgr {
when "/config:modules/config:module/config:type = 'unimgr'";
- container broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity md-sal-binding:binding-broker-osgi-registry;
- }
- }
- }
}
}
}
private Link link;
private DataBroker dataBroker;
- @SuppressWarnings("unchecked")
@Before
public void setUp(){
PowerMockito.mockStatic(MdsalUtils.class);
private DataTreeModification<Link> evcLink;
private DataBroker dataBroker;
- @SuppressWarnings("unchecked")
@Before
public void setUp(){
PowerMockito.mockStatic(UniUtils.class);
private DataBroker dataBroker;
private Node uniNode;
- @SuppressWarnings("unchecked")
@Before
public void setUp(){
PowerMockito.mockStatic(UniUtils.class);
private DataBroker dataBroker;
private Node uniNode;
- @SuppressWarnings("unchecked")
@Before
public void setUp(){
PowerMockito.mockStatic(UniUtils.class);
--- /dev/null
+package org.opendaylight.unimgr.impl;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Consumer;
+
+import org.junit.Test;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.unimgr.mef.nrp.impl.ActivationDriverRepoServiceImpl;
+import org.opendaylight.unimgr.utils.ActivationDriverMocks;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corefoundationmodule.superclassesandcommonpackages.rev160413.UniversalId;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GForwardingConstruct;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.fcroutelist.FcRoute;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.fcroutelist.FcRouteBuilder;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.g_fcroute.ForwardingConstruct;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.g_fcroute.ForwardingConstructBuilder;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.g_forwardingconstruct.FcPort;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.g_forwardingconstruct.FcPortBuilder;
+
+/**
+ * @author bartosz.michalik@amartus.com
+ */
+public class FcRouteActivatorServiceTest {
+
+ public FcRouteActivatorService createService(List<ActivationDriverBuilder> builders) {
+ return new FcRouteActivatorService(new ActivationDriverRepoServiceImpl(builders));
+ }
+
+ @Test
+ public void testActivateSingleNode() throws Exception {
+
+ //having
+ final ActivationDriver d1 = mock(ActivationDriver.class);
+
+ FcRouteActivatorService service = createService(Arrays.asList(
+ ActivationDriverMocks.prepareDriver((port1, port2) -> "a".equals(port1.getId()) ? d1 : null),
+ ActivationDriverMocks.prepareDriver((port1, port2) -> null)
+ ));
+
+ //when
+ service.activate(buildFor(singleNode()));
+
+ //then
+ verify(d1).activate();
+ verify(d1).commit();
+ }
+
+ @Test
+ public void testActivateTwoNodesSingleVendor() throws Exception {
+ //having
+ final ActivationDriver d1 = mock(ActivationDriver.class);
+
+ FcRouteActivatorService service = createService(Collections.singletonList(
+ ActivationDriverMocks.prepareDriver(port -> d1)
+ ));
+
+ //when
+ service.activate(buildFor(twoNodes()));
+
+ //then
+ verify(d1, times(2)).activate();
+ verify(d1, times(2)).commit();
+ }
+
+ @Test
+ public void testActivateTwoNodesMultiVendor() throws Exception {
+
+ //having
+ final ActivationDriver d1 = mock(ActivationDriver.class);
+ final ActivationDriver d2 = mock(ActivationDriver.class);
+
+ FcRouteActivatorService service = createService(Arrays.asList(
+ ActivationDriverMocks.prepareDriver(port -> "a".equals(port.getId()) ? d1 : null),
+ ActivationDriverMocks.prepareDriver(port -> "z".equals(port.getId()) ? d2 : null)
+ ));
+
+ //when
+ service.activate(buildFor(twoNodes()));
+
+ //then
+ verify(d1).activate();
+ verify(d1).commit();
+ verify(d2).activate();
+ verify(d2).commit();
+ }
+
+ @Test
+ public void testActivateSingleNodeFailure() throws Exception {
+
+ //having
+ final ActivationDriver d1 = spy(new FailingActivationDriver(p -> { if(p.getId().equals("a")) throw new NullPointerException();}));
+
+ FcRouteActivatorService service = createService(Collections.singletonList(
+ ActivationDriverMocks.prepareDriver((p1,p2) -> d1)
+ ));
+
+ //when
+ service.activate(buildFor(singleNode()));
+
+ //then
+ verify(d1, times(1)).rollback();
+ }
+
+ @Test
+ public void testActivateMultiNodeFailure() throws Exception {
+
+ //having
+ final ActivationDriver d1 = spy(new FailingActivationDriver(p -> { if(p.getId().equals("a")) throw new NullPointerException();}));
+
+ FcRouteActivatorService service = createService(Collections.singletonList(
+ ActivationDriverMocks.prepareDriver(p1 -> d1)
+ ));
+
+ //when
+ service.activate(buildFor(twoNodes()));
+
+ //then
+ verify(d1, times(1)).activate();
+ verify(d1, times(2)).rollback();
+ }
+
+ @Test
+ public void testDeactivateSingleNodeFailure() throws Exception {
+
+ //having
+ final ActivationDriver d1 = spy(new FailingActivationDriver(p -> { if(p.getId().equals("a")) throw new NullPointerException();}));
+
+ FcRouteActivatorService service = createService(Arrays.asList(
+ ActivationDriverMocks.prepareDriver((p1,p2) -> null),
+ ActivationDriverMocks.prepareDriver((p1,p2) -> d1)
+ ));
+
+ //when
+ service.deactivate(buildFor(singleNode()));
+
+ //then
+ verify(d1, times(1)).deactivate();
+ verify(d1, times(1)).rollback();
+ }
+
+ @Test
+ public void testDeactivateTwoNodesSingleVendor() throws Exception {
+ //having
+ final ActivationDriver d1 = mock(ActivationDriver.class);
+
+ FcRouteActivatorService service = createService(Collections.singletonList(
+ ActivationDriverMocks.prepareDriver(port -> d1)
+ ));
+
+ //when
+ service.deactivate(buildFor(twoNodes()));
+
+ //then
+ verify(d1, times(2)).deactivate();
+ verify(d1, times(2)).commit();
+ }
+
+ private ForwardingConstruct singleNode() {
+ return fc(
+ port("a", "localhost", "80"),
+ port("z", "localhost", "8080")
+ );
+ }
+
+ private ForwardingConstruct twoNodes() {
+ return fc(
+ port("a", "192.168.1.1", "80"),
+ port("z", "192.168.1.2", "80")
+ );
+ }
+
+ private ForwardingConstruct fc(FcPort... ports) {
+ return new ForwardingConstructBuilder()
+ .setFcPort(Arrays.asList(ports))
+ .build();
+ }
+
+ private FcRoute buildFor(ForwardingConstruct fc) {
+ return new FcRouteBuilder()
+ .setForwardingConstruct(Collections.singletonList(fc))
+ .build();
+ }
+
+ FcPort port(String id, String host, String port) {
+ return new FcPortBuilder()
+ .setId(id)
+ .setLtpRefList(Arrays.asList(new UniversalId(host + ":" + port)))
+ .build();
+ }
+
+ private static class FailingActivationDriver implements ActivationDriver {
+
+ private final Consumer<GFcPort> consumer;
+ private GFcPort from;
+
+ FailingActivationDriver(Consumer<GFcPort> portConsumer) {
+ this.consumer = portConsumer;
+ }
+
+ @Override
+ public void commit() {
+
+ }
+
+ @Override
+ public void rollback() {
+
+ }
+
+ @Override
+ public void initialize(GFcPort from, GFcPort to, GForwardingConstruct context) {
+ if(this.from == null)
+ this.from = from;
+ }
+
+ @Override
+ public void activate() {
+ consumer.accept(from);
+ }
+
+ @Override
+ public void deactivate() {
+ consumer.accept(from);
+ }
+
+ @Override
+ public int priority() {
+ return 0;
+ }
+ }
+}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Dictionary;
import java.util.List;
import org.junit.Before;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
import org.opendaylight.unimgr.utils.MdsalUtils;
import org.opendaylight.unimgr.utils.OvsdbUtils;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceRegistration;
import org.powermock.api.mockito.PowerMockito;
unimgrProvider.listUnis(any(LogicalDatastoreType.class)));
}
- @SuppressWarnings("unchecked")
@Test
- public void testOnSessionInitiated() throws Exception {
- final ProviderContext session = mock(ProviderContext.class);
- when(session.getSALService(DataBroker.class)).thenReturn(dataBroker);
- final BundleContext context = mock(BundleContext.class);
- PowerMockito.mockStatic(FrameworkUtil.class);
- final Bundle bundle = mock(Bundle.class);
- when(bundle.getBundleContext()).thenReturn(context);
- PowerMockito.when(FrameworkUtil.getBundle(unimgrProvider.getClass())).thenReturn(bundle);
- mockUnimgrConsoleRegistration = mock(ServiceRegistration.class);
- when(context.registerService(eq(IUnimgrConsoleProvider.class),
- any(IUnimgrConsoleProvider.class),
- isNull(Dictionary.class))).thenReturn(mockUnimgrConsoleRegistration);
+ public void testInit() throws Exception {
PowerMockito.whenNew(UniDataTreeChangeListener.class).withArguments(any(DataBroker.class)).thenReturn(uniListener);
PowerMockito.whenNew(EvcDataTreeChangeListener.class).withArguments(any(DataBroker.class)).thenReturn(evcListener);
PowerMockito.whenNew(OvsNodeDataTreeChangeListener.class).withArguments(any(DataBroker.class)).thenReturn(ovsListener);
MemberModifier.suppress(MemberMatcher.method(UnimgrProvider.class, "initDatastore"));
- unimgrProvider.onSessionInitiated(session);
+ unimgrProvider.init();
verify(unimgrProvider, atLeast(4)).initDatastore(any(LogicalDatastoreType.class), any(TopologyId.class));
}
--- /dev/null
+package org.opendaylight.unimgr.mef.nrp.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.opendaylight.unimgr.utils.ActivationDriverMocks.prepareDriver;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.junit.Test;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverAmbiguousException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverNotFoundException;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverRepoService;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.FcPort;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.FcPortBuilder;
+
+/**
+ * @author bartosz.michalik@amartus.com
+ */
+public class ActivationDriverRepoServiceImplTest {
+
+ @Test(expected = ActivationDriverNotFoundException.class)
+ public void testEmpty() throws Exception {
+
+ ActivationDriverRepoService driverRepo = new ActivationDriverRepoServiceImpl(Collections.emptyList());
+ final FcPort port = new FcPortBuilder().setId("a").build();
+ driverRepo.getDriver(port, null);
+ }
+
+
+ @Test(expected = ActivationDriverAmbiguousException.class)
+ public void testConflict() throws Exception {
+
+ final ActivationDriver driver = mock(ActivationDriver.class);
+
+ ActivationDriverRepoService driverRepo = new ActivationDriverRepoServiceImpl(Arrays.asList(
+ prepareDriver(p -> driver), prepareDriver(p -> driver)
+ ));
+
+ final FcPort port = new FcPortBuilder().setId("a").build();
+ driverRepo.getDriver(port, null);
+ }
+
+ @Test
+ public void testMatching() throws Exception {
+
+ final ActivationDriver driver = mock(ActivationDriver.class);
+
+ ActivationDriverRepoService driverRepo = new ActivationDriverRepoServiceImpl(Collections.singletonList(
+ prepareDriver(p -> driver)
+ ));
+
+ final FcPort port = new FcPortBuilder().setId("a").build();
+ final ActivationDriver driverFromRepo = driverRepo.getDriver(port, null);
+ assertEquals(driver, driverFromRepo);
+ }
+}
--- /dev/null
+package org.opendaylight.unimgr.utils;
+
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
+import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
+import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160413.GFcPort;
+
+import java.util.Optional;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+
+/**
+ * @author bartosz.michalik@amartus.com
+ */
+public class ActivationDriverMocks {
+ public static ActivationDriverBuilder prepareDriver(Function<GFcPort, ActivationDriver> producer) {
+ final ActivationDriverBuilder mock = mock(ActivationDriverBuilder.class);
+
+ doAnswer(inv -> {
+ GFcPort port = (GFcPort) inv.getArguments()[0];
+ return Optional.ofNullable(producer.apply(port));
+ }).when(mock).driverFor(any(GFcPort.class), any(ActivationDriverBuilder.BuilderContext.class));
+ return mock;
+ }
+
+ public static ActivationDriverBuilder prepareDriver(BiFunction<GFcPort, GFcPort, ActivationDriver> producer) {
+ final ActivationDriverBuilder mock = mock(ActivationDriverBuilder.class);
+
+ doAnswer(inv -> {
+ GFcPort port1 = (GFcPort) inv.getArguments()[0];
+ GFcPort port2 = (GFcPort) inv.getArguments()[1];
+ return Optional.ofNullable(producer.apply(port1, port2));
+ }).when(mock).driverFor(any(GFcPort.class), any(GFcPort.class), any(ActivationDriverBuilder.BuilderContext.class));
+ return mock;
+ }
+}
@Test
public void createAndDeleteUNITest() {
LOG.info("Test for create and delete UNI");
- UniAugmentation uni = new UniAugmentationBuilder()
- .setMacAddress(new MacAddress(MAC_ADDRESS_1))
- .setMacLayer(MAC_LAYER)
- .setMode(MODE)
- .setMtuSize(BigInteger.valueOf(Long.valueOf(MTU_SIZE)))
- .setPhysicalMedium(PHY_MEDIUM)
- .setSpeed(null)
- .setType(TYPE)
- .setIpAddress(new IpAddress(IP_1.toCharArray()))
- .build();
InstanceIdentifier<Node> nodePath = createUniNode(MAC_ADDRESS_1, IP_1);
Assert.assertNotNull(nodePath);
:node = asr-101
:addr = 50.196.141.39
:deviceusername = <username>
-"devicepassword = <password>
+:devicepassword = <password>
:host = http://localhost:8181
:basic-auth := (format "Basic %s" (base64-encode-string (format "%s:%s" "admin" "admin")))