Migrate to using blueprints for unimgr initialisation. 45/39845/2
authorDonald Hunter <donaldh@cisco.com>
Thu, 2 Jun 2016 15:37:10 +0000 (16:37 +0100)
committerDonald Hunter <donaldh@cisco.com>
Fri, 3 Jun 2016 16:59:13 +0000 (17:59 +0100)
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>
54 files changed:
cisco-xr-driver/src/main/config/default-config.xml [deleted file]
cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/CiscoXRDriverProvider.java [deleted file]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeActivator.java [moved from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnBridgeActivator.java with 97% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java [moved from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java with 67% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectActivator.java [moved from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnXconnectActivator.java with 98% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java [moved from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java with 78% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModule.java [deleted file]
cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModuleFactory.java [deleted file]
cisco-xr-driver/src/main/resources/org/opendaylight/blueprint/cisco-xr-driver.xml [new file with mode: 0644]
cisco-xr-driver/src/main/yang/unimgr-cisco-xr-driver-impl.yang [deleted file]
edgeassure-1000/pom.xml
edgeassure-1000/src/main/java/org/opendaylight/unimgr/mef/nrp/edgeassure/EdgeAssureActivator.java [moved from impl/src/main/java/org/mef/nrp/impl/EdgeAssureActivator.java with 95% similarity]
edgeassure-1000/src/main/java/org/opendaylight/unimgr/mef/nrp/edgeassure/EdgeAssureDriverBuilder.java [moved from impl/src/main/java/org/mef/nrp/impl/EdgeAssureDriverBuilder.java with 92% similarity]
features/pom.xml
features/src/main/features/features.xml
impl/pom.xml
impl/src/main/config/default-config.xml [changed mode: 0755->0644]
impl/src/main/java/org/mef/nrp/impl/ResourceActivator.java [deleted file]
impl/src/main/java/org/opendaylight/unimgr/api/AbstractCommand.java
impl/src/main/java/org/opendaylight/unimgr/api/UnimgrDataTreeChangeListener.java
impl/src/main/java/org/opendaylight/unimgr/impl/FcRouteActivatorService.java
impl/src/main/java/org/opendaylight/unimgr/impl/FcRouteChangeListener.java [moved from impl/src/main/java/org/opendaylight/unimgr/impl/FCRouteChangeListener.java with 75% similarity]
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrProvider.java
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriver.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriver.java with 88% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverAmbiguousException.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriverAmbiguousException.java with 83% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverBuilder.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriverBuilder.java with 81% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverNotFoundException.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriverNotFoundException.java with 83% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverRepoService.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriverRepoService.java with 84% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/FixedServiceNaming.java [moved from impl/src/main/java/org/mef/nrp/impl/FixedServiceNaming.java with 93% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/MountPointHelper.java [moved from impl/src/main/java/org/mef/nrp/impl/MountPointHelper.java with 95% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/ResourceActivator.java [new file with mode: 0644]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/ServiceNaming.java [moved from impl/src/main/java/org/mef/nrp/impl/ServiceNaming.java with 94% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationDriverRepoServiceImpl.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationDriverRepoServiceImpl.java with 54% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationTransaction.java [moved from impl/src/main/java/org/mef/nrp/impl/ActivationTransaction.java with 76% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/DummyActivationDriver.java [moved from impl/src/main/java/org/mef/nrp/impl/DummyActivationDriver.java with 85% similarity]
impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ForwardingConstructHelper.java [moved from impl/src/main/java/org/mef/nrp/impl/ForwardingConstructHelper.java with 64% similarity]
impl/src/main/java/org/opendaylight/unimgr/utils/UniUtils.java
impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModule.java [deleted file]
impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModuleFactory.java [deleted file]
impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModule.java [new file with mode: 0644]
impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModuleFactory.java [new file with mode: 0644]
impl/src/main/resources/OSGI-INF/blueprint/blueprint.xml [deleted file]
impl/src/main/resources/org/opendaylight/blueprint/unimgr.xml [new file with mode: 0644]
impl/src/main/yang/unimgr-impl.yang
impl/src/test/java/org/opendaylight/unimgr/command/EvcRemoveCommandTest.java
impl/src/test/java/org/opendaylight/unimgr/command/EvcUpdateCommandTest.java
impl/src/test/java/org/opendaylight/unimgr/command/UniRemoveCommandTest.java
impl/src/test/java/org/opendaylight/unimgr/command/UniUpdateCommandTest.java
impl/src/test/java/org/opendaylight/unimgr/impl/FcRouteActivatorServiceTest.java [new file with mode: 0644]
impl/src/test/java/org/opendaylight/unimgr/impl/UnimgrProviderTest.java
impl/src/test/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationDriverRepoServiceImplTest.java [new file with mode: 0644]
impl/src/test/java/org/opendaylight/unimgr/utils/ActivationDriverMocks.java [new file with mode: 0644]
it/src/test/java/org/opendaylight/unimgr/it/UnimgrIT.java
restclient/cisco-xr-lab-device.txt

diff --git a/cisco-xr-driver/src/main/config/default-config.xml b/cisco-xr-driver/src/main/config/default-config.xml
deleted file mode 100755 (executable)
index 5a90f2a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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&amp;revision=2015-10-12</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:unimgr:cisco-xr-driver:impl?module=unimgr-cisco-xr-driver-impl&amp;revision=2016-05-18</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
-  </required-capabilities>
-  <configuration>
-
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang: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>
diff --git a/cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/CiscoXRDriverProvider.java b/cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/CiscoXRDriverProvider.java
deleted file mode 100644 (file)
index 80ad4ef..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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
-    }
-}
similarity index 97%
rename from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnBridgeActivator.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeActivator.java
index be75a2b488ef79e445232effbfb635296b98e140..8c8bc8b7604fcb2f120aa641bcb0bc449ffe84a0 100644 (file)
@@ -6,18 +6,18 @@
  * 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;
@@ -119,8 +119,8 @@ public class L2vpnBridgeActivator implements ResourceActivator {
         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());
similarity index 67%
rename from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java
index 2e64db4095aca4562630939a673b7ec6fefc0ded..854217eb8321150319298387f115686194561a00 100644 (file)
@@ -6,16 +6,14 @@
  * 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;
 
@@ -23,15 +21,14 @@ import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectcl
  * 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
@@ -46,7 +43,6 @@ public class L2vpnBridgeDriverBuilder implements ActivationDriverBuilder, Bindin
 
     protected ActivationDriver getDriver() {
         final ActivationDriver driver = new ActivationDriver() {
-            public GForwardingConstruct ctx;
             public GFcPort aEnd;
             public GFcPort zEnd;
 
@@ -64,29 +60,22 @@ public class L2vpnBridgeDriverBuilder implements ActivationDriverBuilder, Bindin
             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
similarity index 98%
rename from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnXconnectActivator.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectActivator.java
index df61d8f3813958bedbdfacef2d0c8811ff6bd44d..44156a954f1a2d7a4155afc635614cbff4d7bdfe 100644 (file)
@@ -6,20 +6,20 @@
  * 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;
@@ -217,7 +217,6 @@ public class L2vpnXconnectActivator implements ResourceActivator {
             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)
similarity index 78%
rename from cisco-xr-driver/src/main/java/org/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java
index d5467c1f903c0234ebb0a21d12d5d8520f6d1dcf..322ffbe0066ff17706a5a052701bae2f8d990534 100644 (file)
@@ -6,17 +6,15 @@
  * 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;
 
@@ -24,22 +22,14 @@ import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectcl
  * 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
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModule.java b/cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModule.java
deleted file mode 100644 (file)
index 0b5375e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-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;
-    }
-}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModuleFactory.java b/cisco-xr-driver/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/cisco/xr/driver/impl/rev160518/UnimgrXRDriverModuleFactory.java
deleted file mode 100644 (file)
index 1d4d562..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* 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 {
-
-}
diff --git a/cisco-xr-driver/src/main/resources/org/opendaylight/blueprint/cisco-xr-driver.xml b/cisco-xr-driver/src/main/resources/org/opendaylight/blueprint/cisco-xr-driver.xml
new file mode 100644 (file)
index 0000000..61bb09a
--- /dev/null
@@ -0,0 +1,29 @@
+<?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>
diff --git a/cisco-xr-driver/src/main/yang/unimgr-cisco-xr-driver-impl.yang b/cisco-xr-driver/src/main/yang/unimgr-cisco-xr-driver-impl.yang
deleted file mode 100755 (executable)
index 83e15f1..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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;
-                    }
-                }
-            }
-        }
-    }
-}
index e3dd72ac9fe118b9f9b0d013ac6589d8bccba889..db1e593e6a8fdc5cc981691220ccdee53e5f2f26 100644 (file)
@@ -21,7 +21,17 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <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>
similarity index 95%
rename from impl/src/main/java/org/mef/nrp/impl/EdgeAssureActivator.java
rename to edgeassure-1000/src/main/java/org/opendaylight/unimgr/mef/nrp/edgeassure/EdgeAssureActivator.java
index daece2bbac221f7a436cbed3914c125222abd578..01bc00d1e906799cef9218c901b81e08ca787584 100644 (file)
@@ -6,7 +6,7 @@
  * 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;
@@ -15,6 +15,8 @@ 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.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;
similarity index 92%
rename from impl/src/main/java/org/mef/nrp/impl/EdgeAssureDriverBuilder.java
rename to edgeassure-1000/src/main/java/org/opendaylight/unimgr/mef/nrp/edgeassure/EdgeAssureDriverBuilder.java
index 704972e61f6d15fd18048377517bde1ede156eee..dea2b5fa98b519fe6f91c179f8f4c25e263b5ad9 100644 (file)
@@ -6,10 +6,13 @@
  * 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;
 
index d90c354188e8d7855c5b8ccb7da0075634defa9d..f4b56e8dc9ff4f53857e85d57d1300ab2cd55efa 100644 (file)
@@ -142,13 +142,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <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>
index c13815253c717a67584dbf08d741ed82fd4e8446..dfa0fdd5bca984fedcaab2482a9ba42d065ff784 100755 (executable)
@@ -28,9 +28,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <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>
@@ -57,7 +59,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <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>
index 12b0f5dd17981ccbf7adb513d5c42766d6091904..2faed65e2d11f0358b4d732b27e9b41e4c322447 100644 (file)
@@ -41,7 +41,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
                 <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>
@@ -63,12 +66,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
             <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>
old mode 100755 (executable)
new mode 100644 (file)
index 1538f4f..a9e2578
@@ -7,23 +7,19 @@ 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&amp;revision=2015-10-12</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
-  </required-capabilities>
-  <configuration>
+    <required-capabilities>
+        <capability>urn:opendaylight:params:xml:ns:yang:unimgr:impl?module=unimgr-impl&amp;revision=2016-05-25</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+    </required-capabilities>
+    <configuration>
 
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang: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>
diff --git a/impl/src/main/java/org/mef/nrp/impl/ResourceActivator.java b/impl/src/main/java/org/mef/nrp/impl/ResourceActivator.java
deleted file mode 100644 (file)
index 939b909..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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);
-}
index 0b40579bda500af8ad6e9d6cf91452dde4ee0fed..645f868e9304cb80eb62dc6dc9a37401876d8506 100644 (file)
@@ -18,7 +18,7 @@ public abstract class AbstractCommand<D extends DataObject> {
     protected DataTreeModification<D> dataObject;
 
     /**
-     * Abstract command basic constructor
+     * Abstract command basic constructor.
      * @param dataBroker
      * @param dataObject
      */
@@ -28,7 +28,7 @@ public abstract class AbstractCommand<D extends DataObject> {
     }
 
     /**
-     * Abstract execute method
+     * Abstract execute method.
      */
     public abstract void execute();
 
index d273e7c78b0c678d815db71ad0310555d570662d..8703d59557d93e4da46b72f580335f00b70682b9 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
@@ -21,7 +20,8 @@ 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;
 
@@ -47,25 +47,27 @@ public abstract class UnimgrDataTreeChangeListener<D extends DataObject> impleme
                 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);
 }
index 8fa239be405489ac40b1f3b0b3b520adf01d2d5a..61bea41b59345c087797b6f83965132d6747755e 100644 (file)
@@ -14,13 +14,13 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 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;
@@ -34,14 +34,19 @@ import org.slf4j.LoggerFactory;
 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();
@@ -51,8 +56,12 @@ public class FcRouteActivatorService {
         }
     }
 
+    /**
+     * 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();
@@ -68,25 +77,25 @@ public class FcRouteActivatorService {
         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);
@@ -96,22 +105,26 @@ public class FcRouteActivatorService {
         }
     }
 
-    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");
@@ -124,25 +137,19 @@ public class FcRouteActivatorService {
         } 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();
         }
@@ -150,12 +157,19 @@ public class FcRouteActivatorService {
 
     }
 
+    /**
+     * 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;
@@ -163,13 +177,13 @@ public class FcRouteActivatorService {
     }
 
     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;
         }
     }
similarity index 75%
rename from impl/src/main/java/org/opendaylight/unimgr/impl/FCRouteChangeListener.java
rename to impl/src/main/java/org/opendaylight/unimgr/impl/FcRouteChangeListener.java
index 32b9decb5e746e8f5aa784c24c739c3987015a22..8785cc250f5c54159f648bf8db7c39b6664ede34 100644 (file)
@@ -9,13 +9,13 @@ package org.opendaylight.unimgr.impl;
 
 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;
@@ -27,20 +27,23 @@ import org.slf4j.LoggerFactory;
  * 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");
     }
 
     /**
@@ -50,8 +53,7 @@ public class FCRouteChangeListener implements DataTreeChangeListener<FcRoute>, A
     @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;
         }
@@ -65,7 +67,7 @@ public class FCRouteChangeListener implements DataTreeChangeListener<FcRoute>, A
                     //TO overcome whole subtree change event
                     boolean update = change.getRootNode().getDataBefore() != null;
 
-                    if(update) {
+                    if (update) {
                         update(change);
                     } else {
                         add(change);
@@ -75,25 +77,27 @@ public class FCRouteChangeListener implements DataTreeChangeListener<FcRoute>, A
                 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);
 
@@ -114,14 +118,4 @@ public class FCRouteChangeListener implements DataTreeChangeListener<FcRoute>, A
 
         return path;
     }
-
-    public void setActivationDriverRepoService(ActivationDriverRepoService service) {
-        this.activationRepoService = service;
-        routeActivator.setActivationRepoService(service);
-    }
-
-    public void unsetActivationDriverRepoService() {
-        this.activationRepoService = null;
-        routeActivator.unsetActivationRepoService();
-    }
 }
index fe0619dd9ec8f86d10b9c94950ed85d4a79e8002..91a5554ef1dbc79712914ca00baa8e5d56736927 100755 (executable)
@@ -9,8 +9,6 @@ package org.opendaylight.unimgr.impl;
 
 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;
@@ -38,9 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 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;
 
@@ -54,11 +49,10 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
     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
@@ -75,16 +69,6 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
         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
@@ -143,26 +127,21 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
     }
 
     @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);
@@ -174,6 +153,15 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
                 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
@@ -182,7 +170,8 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @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;
         }
@@ -190,8 +179,8 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
     }
 
     @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,
similarity index 88%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriver.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriver.java
index 92b43cb945b14bee158f41ee18cc8e8af7fb3935..06f777405cbd6970e29116414809efc2c600ac53 100644 (file)
@@ -5,8 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
-package org.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;
@@ -26,17 +25,17 @@ import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectcl
 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
@@ -44,22 +43,19 @@ public interface ActivationDriver {
     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();
-
-
-
 }
similarity index 83%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriverAmbiguousException.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverAmbiguousException.java
index c71ead9291921b99db98e575210e0547a1a249e6..e772ae21ec36bafe80ca3dac8f2239ff545bc363 100644 (file)
@@ -6,11 +6,12 @@
  * 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;
 }
similarity index 81%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriverBuilder.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverBuilder.java
index 8760c899640a90415e785526d9dadf563222bcb7..f710c1f3b843ed31000f1851e1a212d2df47bb8e 100644 (file)
@@ -6,7 +6,7 @@
  * 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;
@@ -31,15 +31,16 @@ public interface ActivationDriverBuilder {
 
     /**
      * 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<>();
@@ -58,19 +59,19 @@ public interface ActivationDriverBuilder {
 
         /**
          * 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);
         }
 
         /**
similarity index 83%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriverNotFoundException.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverNotFoundException.java
index a72e6ba031d512cbcbe01e3d156d8d7a9fb73e6d..eaf90a4e61ea844ca6c5c2595e44490a72086bbe 100644 (file)
@@ -6,11 +6,12 @@
  * 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;
 }
similarity index 84%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriverRepoService.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/api/ActivationDriverRepoService.java
index 9c49ca379ea9349ef8f4053870ae8b733ff28a97..0c4d4f043f74c417d9419ecc1df661b67f338074 100644 (file)
@@ -6,7 +6,7 @@
  * 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;
 
@@ -15,10 +15,6 @@ import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectcl
  */
 public interface ActivationDriverRepoService {
 
-    void bindBuilder(ActivationDriverBuilder builder);
-
-    void unbindBuilder(ActivationDriverBuilder builder);
-
     /**
      * Get driver for a port.
      * @param port to
@@ -31,12 +27,12 @@ public interface ActivationDriverRepoService {
 
     /**
      * 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
similarity index 93%
rename from impl/src/main/java/org/mef/nrp/impl/FixedServiceNaming.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/FixedServiceNaming.java
index c7abdeb9becb6247bc17d40d7e60148cb6ea0fc9..0d33868dc42687ab0b23b788fb9e89cc7272ece6 100644 (file)
@@ -6,7 +6,7 @@
  * 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.
similarity index 95%
rename from impl/src/main/java/org/mef/nrp/impl/MountPointHelper.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/MountPointHelper.java
index e96666e37439c5b7ff91086d0d0f3527f8732f3b..245886a9d621bf74cbdb9a6972f652c2b08f7128 100644 (file)
@@ -6,7 +6,7 @@
  * 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;
@@ -25,12 +25,11 @@ import com.google.common.base.Optional;
 
 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);
diff --git a/impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/ResourceActivator.java b/impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/ResourceActivator.java
new file mode 100644 (file)
index 0000000..d3a9f91
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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);
+}
similarity index 94%
rename from impl/src/main/java/org/mef/nrp/impl/ServiceNaming.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/common/ServiceNaming.java
index f42cdc798dae61b1170dca46aa21bf03d5a1c405..de85c4f1d1491d65013fb656808a0f4dd08ba479 100644 (file)
@@ -6,7 +6,7 @@
  * 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.
similarity index 54%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationDriverRepoServiceImpl.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationDriverRepoServiceImpl.java
index 4aec03f779334fe8f63b1eafd38b02ea805f1924..8b132b0c6b35f4a135ceed280b8143a857f157ee 100644 (file)
@@ -6,50 +6,42 @@
  * 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) {
@@ -67,11 +59,19 @@ public class ActivationDriverRepoServiceImpl implements ActivationDriverRepoServ
         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);
+    }
 }
similarity index 76%
rename from impl/src/main/java/org/mef/nrp/impl/ActivationTransaction.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationTransaction.java
index c96823603af94c98cb4b7bf41c0de90fb5321a40..1d0c6af471f1732c030cacd22d716969418a7a93 100644 (file)
@@ -6,14 +6,15 @@
  * 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.
  *
@@ -28,10 +29,15 @@ public class ActivationTransaction {
         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) {
@@ -41,11 +47,15 @@ public class ActivationTransaction {
         }
     }
 
-
+    /**
+     * 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) {
@@ -64,7 +74,7 @@ public class ActivationTransaction {
     }
 
     private void sortDrivers() {
-        drivers.sort((a,b) -> a.priority() - b.priority());
+        drivers.sort((driverA, driverB) -> driverA.priority() - driverB.priority());
     }
 
 }
similarity index 85%
rename from impl/src/main/java/org/mef/nrp/impl/DummyActivationDriver.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/DummyActivationDriver.java
index 2bfbfc2f99755b84e500a3026ba1939515e8da26..6caa4374f3d5ec5fbbb60e765e6f41bdcccc324b 100644 (file)
@@ -6,8 +6,9 @@
  * 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;
 
@@ -32,5 +33,7 @@ public class DummyActivationDriver implements ActivationDriver {
     public void deactivate() {}
 
     @Override
-    public int priority() {return Integer.MIN_VALUE;}
+    public int priority() {
+        return Integer.MIN_VALUE;
+    }
 }
similarity index 64%
rename from impl/src/main/java/org/mef/nrp/impl/ForwardingConstructHelper.java
rename to impl/src/main/java/org/opendaylight/unimgr/mef/nrp/impl/ForwardingConstructHelper.java
index ceb2a54096470e4c47e556439f4e6cadcca67385..110ca9b2baf7074479c46dcefc4a8210d8397f74 100644 (file)
@@ -6,17 +6,24 @@
  * 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) {
index becaeaf7916839e71a9f07e9a64baaebf8f7f46a..489a71d7586b2a067d59a9b53ac0205fb7182093 100644 (file)
@@ -51,7 +51,7 @@ public class UniUtils {
     }
 
     /**
-     * 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
@@ -89,7 +89,7 @@ public class UniUtils {
     }
 
     /**
-     * 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
@@ -110,7 +110,7 @@ public class UniUtils {
     }
 
     /**
-     * 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
      */
@@ -195,7 +195,9 @@ public class UniUtils {
         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;
                 }
             }
@@ -204,7 +206,7 @@ public class UniUtils {
     }
 
     /**
-     * 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
@@ -241,7 +243,7 @@ public class UniUtils {
     }
 
     /**
-     * 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
@@ -276,42 +278,46 @@ public class UniUtils {
         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();
         }
diff --git a/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModule.java b/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModule.java
deleted file mode 100644 (file)
index 674e971..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-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;
-    }
-
-}
diff --git a/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModuleFactory.java b/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev151012/UnimgrModuleFactory.java
deleted file mode 100644 (file)
index 266059f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* 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{
-
-}
diff --git a/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModule.java b/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModule.java
new file mode 100644 (file)
index 0000000..fdf3c7c
--- /dev/null
@@ -0,0 +1,35 @@
+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;
+    }
+}
diff --git a/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModuleFactory.java b/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/unimgr/impl/rev160525/UnimgrModuleFactory.java
new file mode 100644 (file)
index 0000000..b51bb7f
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+* 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;
+    }
+}
diff --git a/impl/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/impl/src/main/resources/OSGI-INF/blueprint/blueprint.xml
deleted file mode 100644 (file)
index 6bd3c15..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<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
diff --git a/impl/src/main/resources/org/opendaylight/blueprint/unimgr.xml b/impl/src/main/resources/org/opendaylight/blueprint/unimgr.xml
new file mode 100644 (file)
index 0000000..547dfb6
--- /dev/null
@@ -0,0 +1,34 @@
+<?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
index c87f9826d57d7eb1d9a5de326f5ab6ba6ec1d5ca..82d9bd6deb0f6f49c59768e0608fda17e7348313 100755 (executable)
@@ -11,12 +11,11 @@ module unimgr-impl {
     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.";
     }
@@ -29,14 +28,6 @@ module unimgr-impl {
     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;
-                    }
-                }
-            }
         }
     }
 }
index 98a86d86eecb0bc94882f6bf3b539c2eb6c0e5b4..659955e64f12742407f3f1e95293c3f5f67f234c 100644 (file)
@@ -45,7 +45,6 @@ public class EvcRemoveCommandTest {
     private Link link;
     private DataBroker dataBroker;
 
-    @SuppressWarnings("unchecked")
     @Before
     public void setUp(){
         PowerMockito.mockStatic(MdsalUtils.class);
index e68f7bcbb9b3b294f7b6ed4cd7618cc6965e9bd7..7d0f7d2c0416a279bdd11688c56886b2a95c0460 100644 (file)
@@ -60,7 +60,6 @@ public class EvcUpdateCommandTest {
     private DataTreeModification<Link> evcLink;
     private DataBroker dataBroker;
 
-    @SuppressWarnings("unchecked")
     @Before
     public void setUp(){
         PowerMockito.mockStatic(UniUtils.class);
index 40d9498606a2c6dec735951519e8ae097a425864..e40369739f17b42647da38254cab6ddc51d8440d 100644 (file)
@@ -58,7 +58,6 @@ public class UniRemoveCommandTest {
     private DataBroker dataBroker;
     private Node uniNode;
 
-    @SuppressWarnings("unchecked")
     @Before
     public void setUp(){
         PowerMockito.mockStatic(UniUtils.class);
index 0bd992e07bacdc2f107dff9abcc64ab20b6f5cbc..9400962bddc5bb001abb7f042b78f906cad94b02 100644 (file)
@@ -58,7 +58,6 @@ public class UniUpdateCommandTest {
     private DataBroker dataBroker;
     private Node uniNode;
 
-    @SuppressWarnings("unchecked")
     @Before
     public void setUp(){
         PowerMockito.mockStatic(UniUtils.class);
diff --git a/impl/src/test/java/org/opendaylight/unimgr/impl/FcRouteActivatorServiceTest.java b/impl/src/test/java/org/opendaylight/unimgr/impl/FcRouteActivatorServiceTest.java
new file mode 100644 (file)
index 0000000..6caa6cf
--- /dev/null
@@ -0,0 +1,239 @@
+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
index 57b612b797222fef5d13f199ecafb46d103c2e79..5b8c4ccdac0c3e35f6c405f0a484908e3d04f8bc 100755 (executable)
@@ -9,8 +9,6 @@ package org.opendaylight.unimgr.impl;
 
 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;
@@ -18,7 +16,6 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.util.Dictionary;
 import java.util.List;
 
 import org.junit.Before;
@@ -30,7 +27,6 @@ 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.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;
@@ -50,8 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 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;
@@ -231,25 +225,13 @@ public class UnimgrProviderTest {
                      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));
     }
 
diff --git a/impl/src/test/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationDriverRepoServiceImplTest.java b/impl/src/test/java/org/opendaylight/unimgr/mef/nrp/impl/ActivationDriverRepoServiceImplTest.java
new file mode 100644 (file)
index 0000000..48b9f1b
--- /dev/null
@@ -0,0 +1,58 @@
+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);
+    }
+}
diff --git a/impl/src/test/java/org/opendaylight/unimgr/utils/ActivationDriverMocks.java b/impl/src/test/java/org/opendaylight/unimgr/utils/ActivationDriverMocks.java
new file mode 100644 (file)
index 0000000..4fe8b5e
--- /dev/null
@@ -0,0 +1,39 @@
+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;
+    }
+}
index 9603e8683c6c000134fb41cdea5ef394a0673e63..a50d7be6279cb620aef8615a71e0aaaf9af13b7f 100644 (file)
@@ -170,16 +170,6 @@ public class UnimgrIT extends AbstractMdsalTestBase {
     @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);
index d6e5aaec1b71b2306d943201551e634a89cdc9af..7ce1e96aad5a471d1cd6a4f7a2b5c7e89269b310 100644 (file)
@@ -4,7 +4,7 @@
 :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")))