IOS-XR L2VPN activators code refactored 12/42212/8
authorKrzysztof Bijakowski <krzysztof.bijakowski@amartus.com>
Fri, 15 Jul 2016 13:41:37 +0000 (15:41 +0200)
committerKrzysztof Bijakowski <krzysztof.bijakowski@amartus.com>
Tue, 2 Aug 2016 09:19:39 +0000 (11:19 +0200)
Change-Id: Ifbf8989b1444e852d19204989b402b5c0543cc74
Signed-off-by: Krzysztof Bijakowski <krzysztof.bijakowski@amartus.com>
26 files changed:
cisco-xr-driver/pom.xml
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeActivator.java [deleted file]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectActivator.java [deleted file]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelper.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/LoopbackUtils.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtils.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/AbstractL2vpnActivator.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivator.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivator.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/driver/L2vpnBridgeDriverBuilder.java [moved from cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java with 95% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/driver/L2vpnXconnectDriverBuilder.java [moved from cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java with 95% similarity]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelper.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelper.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelper.java [new file with mode: 0644]
cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelper.java [new file with mode: 0644]
cisco-xr-driver/src/main/resources/org/opendaylight/blueprint/cisco-xr-driver.xml
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelperTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtilsTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnActivatorTestUtils.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivatorTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivatorTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelperTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelperTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelperTest.java [new file with mode: 0644]
cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelperTest.java [new file with mode: 0644]
cisco-xrmodels/src/main/yang/Cisco-IOS-XR-ip-static-cfg@2015-09-10.yang

index 71c39463ae8d3631a1091266a5e74aae345fa642..6288cc54107922318095a51f541ed6c65837ee3d 100644 (file)
@@ -53,6 +53,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
             <version>${project.version}</version>
         </dependency>
 
+        <!-- dependencies to use AbstractDataBrokerTest -->
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <!-- Testing Dependencies -->
         <dependency>
             <groupId>junit</groupId>
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeActivator.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeActivator.java
deleted file mode 100644 (file)
index 7ec48c9..0000000
+++ /dev/null
@@ -1,196 +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.opendaylight.unimgr.mef.nrp.cisco.xr;
-
-import java.util.LinkedList;
-import java.util.List;
-
-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;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfiguration;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3Builder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpnBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2Transport;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2TransportBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.Database;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.DatabaseBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroupsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnects;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnectsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuitsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.PseudowiresBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuitBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.InterfaceName;
-import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-
-public class L2vpnBridgeActivator implements ResourceActivator {
-
-    private static final Logger log = LoggerFactory.getLogger(L2vpnBridgeActivator.class);
-    private MountPointService mountService;
-
-    public L2vpnBridgeActivator(DataBroker dataBroker, MountPointService mountService) {
-        this.mountService = mountService;
-    }
-
-    @Override
-    public void activate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor, long mtu) {
-
-        InterfaceName aEndIfName = new InterfaceName(port.getTp().getValue());
-        InterfaceName zEndIfName = new InterfaceName(neighbor.getTp().getValue());
-        InterfaceName[] both = new InterfaceName[] { aEndIfName, zEndIfName };
-
-        List<InterfaceConfiguration> intConfigs = new LinkedList<>();
-        for (InterfaceName ifName : both) {
-            InterfaceConfigurationBuilder intConfigBuilder = new InterfaceConfigurationBuilder();
-            intConfigBuilder.setInterfaceName(ifName).setActive(new InterfaceActive("act")).setShutdown(Boolean.FALSE);
-
-            L2Transport l2transport = new L2TransportBuilder().setEnabled(true).build();
-            InterfaceConfiguration3 augmentation = new InterfaceConfiguration3Builder().setL2Transport(l2transport)
-                    .build();
-            intConfigBuilder.addAugmentation(InterfaceConfiguration3.class, augmentation);
-
-            intConfigs.add(intConfigBuilder.build());
-        }
-        InterfaceConfigurationsBuilder intConfigsBuilder = new InterfaceConfigurationsBuilder();
-        intConfigsBuilder.setInterfaceConfiguration(intConfigs);
-
-        InstanceIdentifier<InterfaceConfigurations> intConfigsId = InstanceIdentifier
-                .builder(InterfaceConfigurations.class).build();
-
-        AttachmentCircuitBuilder attachmentCircuitBuilderA = new AttachmentCircuitBuilder();
-        attachmentCircuitBuilderA.setName(aEndIfName).setEnable(Boolean.TRUE);
-        AttachmentCircuitBuilder attachmentCircuitBuilderZ = new AttachmentCircuitBuilder();
-        attachmentCircuitBuilderZ.setName(zEndIfName).setEnable(Boolean.TRUE);
-
-        List<AttachmentCircuit> attachmentCircuits = new LinkedList<>();
-        attachmentCircuits.add(attachmentCircuitBuilderA.build());
-        attachmentCircuits.add(attachmentCircuitBuilderZ.build());
-
-        AttachmentCircuitsBuilder attachmentCircuitsBuilder = new AttachmentCircuitsBuilder();
-        attachmentCircuitsBuilder.setAttachmentCircuit(attachmentCircuits);
-
-        List<Pseudowire> pseudowires = new LinkedList<>();
-        PseudowiresBuilder pseudowiresBuilder = new PseudowiresBuilder();
-        pseudowiresBuilder.setPseudowire(pseudowires);
-
-        P2pXconnectBuilder p2pXconnectBuilder = new P2pXconnectBuilder();
-        p2pXconnectBuilder.setName(new CiscoIosXrString(innerName))
-                .setAttachmentCircuits(attachmentCircuitsBuilder.build()).setPseudowires(pseudowiresBuilder.build());
-
-        List<P2pXconnect> p2pXconnects = new LinkedList<>();
-        p2pXconnects.add(p2pXconnectBuilder.build());
-        P2pXconnectsBuilder p2pXconnectsBuilder = new P2pXconnectsBuilder();
-        p2pXconnectsBuilder.setP2pXconnect(p2pXconnects);
-
-        XconnectGroupBuilder xconnectGroupBuilder = new XconnectGroupBuilder();
-        xconnectGroupBuilder.setKey(new XconnectGroupKey(new CiscoIosXrString(outerName)));
-        xconnectGroupBuilder.setName(new CiscoIosXrString(outerName)).setP2pXconnects(p2pXconnectsBuilder.build());
-
-        List<XconnectGroup> xconnectGroups = new LinkedList<>();
-        xconnectGroups.add(xconnectGroupBuilder.build());
-        XconnectGroupsBuilder xconnectGroupsBuilder = new XconnectGroupsBuilder();
-        xconnectGroupsBuilder.setXconnectGroup(xconnectGroups);
-
-        DatabaseBuilder dbBuilder = new DatabaseBuilder();
-        dbBuilder.setXconnectGroups(xconnectGroupsBuilder.build());
-
-        L2vpnBuilder l2vpnBuilder = new L2vpnBuilder();
-        l2vpnBuilder.setDatabase(dbBuilder.build());
-
-        InstanceIdentifier<L2vpn> l2vpnId = InstanceIdentifier.builder(L2vpn.class).build();
-
-        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
-        if (optional.isPresent() == false) {
-            log.error("Could not retrieve MountPoint for {}", nodeName);
-            return;
-        }
-        DataBroker nodeDataBroker = optional.get();
-
-        WriteTransaction w = null;
-        try {
-            w = nodeDataBroker.newWriteOnlyTransaction();
-            w.merge(LogicalDatastoreType.CONFIGURATION, intConfigsId, intConfigsBuilder.build());
-            w.merge(LogicalDatastoreType.CONFIGURATION, l2vpnId, l2vpnBuilder.build());
-            try {
-                w.submit().checkedGet();
-                log.info("Service activated: {} {} {}", nodeName, outerName, innerName);
-            } catch (TransactionCommitFailedException e) {
-                log.error("Transaction failed", e);
-            }
-        } catch (Throwable t) {
-            if (w != null)
-                w.cancel();
-            log.error("Failed to create write transaction", t);
-        }
-    }
-
-    @Override
-    public void deactivate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor,
-            long mtu) {
-        String portLtpId = port.getTp().getValue();
-        InterfaceName interfaceName = new InterfaceName(portLtpId.split(":")[1]);
-
-        InterfaceActive intActive = new InterfaceActive("act");
-
-        InstanceIdentifier<P2pXconnect> p2pId = InstanceIdentifier.builder(L2vpn.class).child(Database.class)
-                .child(XconnectGroups.class)
-                .child(XconnectGroup.class, new XconnectGroupKey(new CiscoIosXrString("local")))
-                .child(P2pXconnects.class).child(P2pXconnect.class, new P2pXconnectKey(new CiscoIosXrString(innerName)))
-                .build();
-
-        InstanceIdentifier<InterfaceConfiguration> intConfigId = InstanceIdentifier
-                .builder(InterfaceConfigurations.class)
-                .child(InterfaceConfiguration.class, new InterfaceConfigurationKey(intActive, interfaceName)).build();
-
-        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
-        if (optional.isPresent() == false) {
-            log.error("Could not retrieve MountPoint for {}", nodeName);
-            return;
-        }
-        DataBroker nodeDataBroker = optional.get();
-        WriteTransaction w = nodeDataBroker.newWriteOnlyTransaction();
-        w.delete(LogicalDatastoreType.CONFIGURATION, p2pId);
-        w.delete(LogicalDatastoreType.CONFIGURATION, intConfigId);
-
-        try {
-            w.submit().checkedGet();
-            log.info("Service deactivated: {} {} {}", nodeName, outerName, innerName);
-        } catch (TransactionCommitFailedException e) {
-            log.error("Transaction failed", e);
-        }
-    }
-
-}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectActivator.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectActivator.java
deleted file mode 100644 (file)
index 09a24aa..0000000
+++ /dev/null
@@ -1,244 +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.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.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;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfiguration;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.MtusBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.MtuBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3Builder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpnBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.PseudowireIdRange;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.PseudowireLabelRange;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2Transport;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2TransportBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.Database;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.DatabaseBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroupsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnects;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnectsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectKey;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuitsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.PseudowiresBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuitBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.PseudowireBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.Neighbor;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.NeighborBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabelsBuilder;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.InterfaceName;
-import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-
-public class L2vpnXconnectActivator implements ResourceActivator {
-
-    private static final Logger log = LoggerFactory.getLogger(L2vpnXconnectActivator.class);
-    private static final Map<String, String> loopbackMap = ImmutableMap.of("asr-101", "192.168.0.1", "asr-102",
-            "192.168.0.2", "asr-103", "192.168.0.3");
-    private static final AtomicLong pwIdGenerator = new AtomicLong(2000L);
-    private MountPointService mountService;
-
-    public L2vpnXconnectActivator(DataBroker dataBroker, MountPointService mountService) {
-        this.mountService = mountService;
-    }
-
-    @Override
-    public void activate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor, long mtu) {
-
-        String neighborHostname = neighbor.getNode().getValue();
-        InterfaceName interfaceName = new InterfaceName(port.getTp().getValue());
-
-        // XXX: need to flesh out real method to find neighbor's loopback
-        String neighborLoopback = loopbackMap.get(neighborHostname);
-        if (neighborLoopback == null) {
-            log.warn("No loopback address found for {}", neighborHostname);
-            neighborLoopback = "127.0.0.1";
-        }
-
-        Ipv4AddressNoZone neighborAddress = new Ipv4AddressNoZone(neighborLoopback);
-        InterfaceActive intActive = new InterfaceActive("act");
-
-        // XXX: need to implement real pseudowire-id generator
-        long pwIdVal = pwIdGenerator.getAndIncrement();
-
-        MtuBuilder mtuBuilder = new MtuBuilder();
-        mtuBuilder.setMtu(mtu);
-        mtuBuilder.setOwner(new CiscoIosXrString("GigabitEthernet"));
-
-        List<Mtu> mtus = new LinkedList<>();
-        mtus.add(mtuBuilder.build());
-        MtusBuilder mtusBuilder = new MtusBuilder();
-        mtusBuilder.setMtu(mtus);
-
-        InterfaceConfigurationBuilder intConfigBuilder = new InterfaceConfigurationBuilder();
-        intConfigBuilder.setInterfaceName(interfaceName).setActive(intActive).setMtus(mtusBuilder.build())
-                .setShutdown(Boolean.FALSE);
-
-        L2Transport l2transport = new L2TransportBuilder().setEnabled(true).build();
-        InterfaceConfiguration3 augmentation = new InterfaceConfiguration3Builder().setL2Transport(l2transport).build();
-        intConfigBuilder.addAugmentation(InterfaceConfiguration3.class, augmentation);
-
-        List<InterfaceConfiguration> intConfigs = new LinkedList<>();
-        intConfigs.add(intConfigBuilder.build());
-        InterfaceConfigurationsBuilder intConfigsBuilder = new InterfaceConfigurationsBuilder();
-        intConfigsBuilder.setInterfaceConfiguration(intConfigs);
-
-        InstanceIdentifier<InterfaceConfigurations> intConfigsId = InstanceIdentifier
-                .builder(InterfaceConfigurations.class).build();
-
-        AttachmentCircuitBuilder attachmentCircuitBuilder = new AttachmentCircuitBuilder();
-        attachmentCircuitBuilder.setName(interfaceName).setEnable(Boolean.TRUE);
-
-        List<AttachmentCircuit> attachmentCircuits = new LinkedList<>();
-        attachmentCircuits.add(attachmentCircuitBuilder.build());
-        AttachmentCircuitsBuilder attachmentCircuitsBuilder = new AttachmentCircuitsBuilder();
-        attachmentCircuitsBuilder.setAttachmentCircuit(attachmentCircuits);
-
-        PseudowireLabelRange label = new PseudowireLabelRange(pwIdVal);
-        MplsStaticLabelsBuilder labelBuilder = new MplsStaticLabelsBuilder();
-        labelBuilder.setLocalStaticLabel(label).setRemoteStaticLabel(label);
-
-        NeighborBuilder neighborBuilder = new NeighborBuilder();
-        neighborBuilder.setNeighbor(neighborAddress).setMplsStaticLabels(labelBuilder.build())
-                .setXmlClass(new CiscoIosXrString("static"));
-
-        List<Neighbor> neighbors = new LinkedList<>();
-        neighbors.add(neighborBuilder.build());
-
-        // XXX
-        PseudowireIdRange pwId = new PseudowireIdRange(pwIdVal);
-        PseudowireBuilder pseudowireBuilder = new PseudowireBuilder();
-        pseudowireBuilder.setNeighbor(neighbors).setPseudowireId(pwId);
-
-        List<Pseudowire> pseudowires = new LinkedList<>();
-        pseudowires.add(pseudowireBuilder.build());
-        PseudowiresBuilder pseudowiresBuilder = new PseudowiresBuilder();
-        pseudowiresBuilder.setPseudowire(pseudowires);
-
-        P2pXconnectBuilder p2pXconnectBuilder = new P2pXconnectBuilder();
-        p2pXconnectBuilder.setName(new CiscoIosXrString(innerName))
-                .setAttachmentCircuits(attachmentCircuitsBuilder.build()).setPseudowires(pseudowiresBuilder.build());
-
-        List<P2pXconnect> p2pXconnects = new LinkedList<>();
-        p2pXconnects.add(p2pXconnectBuilder.build());
-        P2pXconnectsBuilder p2pXconnectsBuilder = new P2pXconnectsBuilder();
-        p2pXconnectsBuilder.setP2pXconnect(p2pXconnects);
-
-        XconnectGroupBuilder xconnectGroupBuilder = new XconnectGroupBuilder();
-        xconnectGroupBuilder.setKey(new XconnectGroupKey(new CiscoIosXrString(outerName)));
-        xconnectGroupBuilder.setName(new CiscoIosXrString(outerName)).setP2pXconnects(p2pXconnectsBuilder.build());
-
-        List<XconnectGroup> xconnectGroups = new LinkedList<>();
-        xconnectGroups.add(xconnectGroupBuilder.build());
-        XconnectGroupsBuilder xconnectGroupsBuilder = new XconnectGroupsBuilder();
-        xconnectGroupsBuilder.setXconnectGroup(xconnectGroups);
-
-        DatabaseBuilder dbBuilder = new DatabaseBuilder();
-        dbBuilder.setXconnectGroups(xconnectGroupsBuilder.build());
-
-        L2vpnBuilder l2vpnBuilder = new L2vpnBuilder();
-        l2vpnBuilder.setDatabase(dbBuilder.build());
-
-        InstanceIdentifier<L2vpn> l2vpnId = InstanceIdentifier.builder(L2vpn.class).build();
-
-        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
-        if (! optional.isPresent()) {
-            log.error("Could not retrieve MountPoint for {}", nodeName);
-            return;
-        }
-        DataBroker nodeDataBroker = optional.get();
-        WriteTransaction w = nodeDataBroker.newWriteOnlyTransaction();
-        w.merge(LogicalDatastoreType.CONFIGURATION, intConfigsId, intConfigsBuilder.build());
-        w.merge(LogicalDatastoreType.CONFIGURATION, l2vpnId, l2vpnBuilder.build());
-
-        try {
-            w.submit().checkedGet();
-            log.info("Service activated: {} {} {}", nodeName, outerName, innerName);
-        } catch (TransactionCommitFailedException e) {
-            log.error("Transaction failed", e);
-        }
-    }
-
-    @Override
-    public void deactivate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor,
-            long mtu) {
-        String neighborHostname = neighbor.getNode().getValue();
-        InterfaceName interfaceName = new InterfaceName(port.getTp().getValue());
-
-        // XXX: need to flesh out real method to find neighbor's loopback
-        String neighborLoopback = loopbackMap.get(neighborHostname);
-        if (neighborLoopback == null) {
-            log.warn("No loopback address found for {}", neighborHostname);
-            neighborLoopback = "127.0.0.1";
-        }
-
-        InterfaceActive intActive = new InterfaceActive("act");
-
-        InstanceIdentifier<P2pXconnect> p2pId = InstanceIdentifier.builder(L2vpn.class).child(Database.class)
-                .child(XconnectGroups.class)
-                .child(XconnectGroup.class, new XconnectGroupKey(new CiscoIosXrString(outerName)))
-                .child(P2pXconnects.class).child(P2pXconnect.class, new P2pXconnectKey(new CiscoIosXrString(innerName)))
-                .build();
-
-        InstanceIdentifier<InterfaceConfiguration> intConfigId = InstanceIdentifier
-                .builder(InterfaceConfigurations.class)
-                .child(InterfaceConfiguration.class, new InterfaceConfigurationKey(intActive, interfaceName)).build();
-
-        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
-        if (! optional.isPresent()) {
-            log.error("Could not retrieve MountPoint for {}", nodeName);
-            return;
-        }
-        DataBroker nodeDataBroker = optional.get();
-        WriteTransaction w = nodeDataBroker.newWriteOnlyTransaction();
-        w.delete(LogicalDatastoreType.CONFIGURATION, p2pId);
-        w.delete(LogicalDatastoreType.CONFIGURATION, intConfigId);
-
-        try {
-            w.submit().checkedGet();
-            log.info("Service deactivated: {} {} {}", nodeName, outerName, innerName);
-        } catch (TransactionCommitFailedException e) {
-            log.error("Transaction failed", e);
-        }
-    }
-
-}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelper.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelper.java
new file mode 100644 (file)
index 0000000..9ff582f
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.cisco.xr.common.helper;
+
+import com.google.common.base.Optional;
+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;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3Builder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2Transport;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109._interface.configurations._interface.configuration.L2TransportBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.InterfaceName;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Helper, designated to support interface configuration
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class InterfaceHelper {
+    private List<InterfaceConfiguration> configurations;
+
+    public static InterfaceName getInterfaceName(FcPort port) {
+        String interfaceName = port.getTp().getValue();
+
+        if(interfaceName.contains(":")) {
+            interfaceName = interfaceName.split(":")[1];
+        }
+
+        return new InterfaceName(interfaceName);
+    }
+
+    public static InstanceIdentifier<InterfaceConfigurations> getInterfaceConfigurationsId() {
+        return InstanceIdentifier.builder(InterfaceConfigurations.class).build();
+    }
+
+    public InterfaceHelper() {
+        configurations = new LinkedList<>();
+    }
+
+    public InterfaceHelper addInterface(FcPort port, Optional<Mtus> mtus, boolean setL2Transport) {
+        return addInterface(getInterfaceName(port), mtus, setL2Transport);
+    }
+
+    public InterfaceHelper addInterface(InterfaceName name, Optional<Mtus> mtus, boolean setL2Transport) {
+        InterfaceConfigurationBuilder configurationBuilder = new InterfaceConfigurationBuilder();
+
+        configurationBuilder
+            .setInterfaceName(name)
+            .setActive(new InterfaceActive("act"))
+            .setShutdown(Boolean.FALSE);
+
+        if(mtus.isPresent()) {
+            configurationBuilder.setMtus(mtus.get());
+        }
+
+        if(setL2Transport) {
+            setL2Configuration(configurationBuilder);
+        }
+
+        configurations.add(configurationBuilder.build());
+        return this;
+    }
+
+    public InterfaceConfigurations build() {
+        return new InterfaceConfigurationsBuilder()
+            .setInterfaceConfiguration(configurations)
+            .build();
+    }
+
+    private void setL2Configuration(InterfaceConfigurationBuilder configurationBuilder) {
+        L2Transport l2transport = new L2TransportBuilder()
+            .setEnabled(true)
+            .build();
+
+        InterfaceConfiguration3 augmentation = new InterfaceConfiguration3Builder()
+            .setL2Transport(l2transport)
+            .build();
+
+        configurationBuilder.addAugmentation(InterfaceConfiguration3.class, augmentation);
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/LoopbackUtils.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/LoopbackUtils.java
new file mode 100644 (file)
index 0000000..0bf002f
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.cisco.xr.common.util;
+
+import com.google.common.collect.ImmutableMap;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * Tools designated to support operations on loopback interfaces data
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class LoopbackUtils {
+    private static final Logger LOG = LoggerFactory.getLogger(LoopbackUtils.class);
+
+    private static final String DEFAULT_LOOPBACK = "127.0.0.1";
+
+    private static final Map<String, String> loopbackMap = ImmutableMap.of(
+            "asr-101", "192.168.0.1",
+            "asr-102", "192.168.0.2",
+            "asr-103", "192.168.0.3"
+    );
+
+    // TODO: implement real method to find neighbor's loopback
+    public static Ipv4AddressNoZone getIpv4Address(FcPort port) {
+        String hostname = port.getNode().getValue();
+
+        String loopback = loopbackMap.get(hostname);
+        if (loopback == null) {
+            LOG.warn("No loopback address found for {}", hostname);
+            loopback = DEFAULT_LOOPBACK;
+        }
+
+        return new Ipv4AddressNoZone(loopback);
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtils.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtils.java
new file mode 100644 (file)
index 0000000..fe32a3f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.cisco.xr.common.util;
+
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.MtusBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.MtuBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Tools designated to support MTU-related configuration objects processing
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class MtuUtils {
+
+    public static Mtus generateMtus(List<Long> mtuValues, CiscoIosXrString owner) {
+        List<Mtu> mtus = new LinkedList<>();
+
+        for(Long mtuValue : mtuValues) {
+            mtus.add(generateMtu(mtuValue, owner));
+        }
+
+        return new MtusBuilder()
+            .setMtu(mtus)
+            .build();
+    }
+
+    public static Mtus generateMtus(long mtuValue, CiscoIosXrString owner) {
+        List<Long> mtuValues = new ArrayList<>();
+        mtuValues.add(mtuValue);
+
+        return generateMtus(mtuValues, owner);
+    }
+
+    private static Mtu generateMtu(long mtuValue, CiscoIosXrString owner) {
+        return new MtuBuilder()
+            .setMtu(mtuValue)
+            .setOwner(owner)
+            .build();
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/AbstractL2vpnActivator.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/AbstractL2vpnActivator.java
new file mode 100644 (file)
index 0000000..2c98e98
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+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.cisco.xr.common.helper.InterfaceHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
+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._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfigurationKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.Database;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnects;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstarct activator of VPLS-based L2 VPN on IOS-XR devices. It is responsible for handling activation and deactivation
+ * process of VPN configuration and it provides generic transaction designated for this purpose.
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public abstract class AbstractL2vpnActivator implements ResourceActivator {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractL2vpnActivator.class);
+
+    private MountPointService mountService;
+
+    protected AbstractL2vpnActivator(MountPointService mountService) {
+        this.mountService = mountService;
+    }
+
+    @Override
+    public void activate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor, long mtu) {
+        InterfaceConfigurations interfaceConfigurations = activateInterface(port, neighbor, mtu);
+        Pseudowires pseudowires = activatePseudowire(neighbor);
+        XconnectGroups xconnectGroups = activateXConnect(outerName, innerName, port, neighbor, pseudowires);
+        L2vpn l2vpn = activateL2Vpn(xconnectGroups);
+
+        doActivate(nodeName, outerName, innerName, interfaceConfigurations, l2vpn);
+    }
+
+    @Override
+    public void deactivate(String nodeName, String outerName, String innerName, FcPort port, FcPort neighbor, long mtu) {
+        InstanceIdentifier<P2pXconnect> xconnectId = deactivateXConnect(outerName, innerName);
+        InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId = deactivateInterface(port);
+
+        doDeactivate(nodeName, outerName, innerName, xconnectId, interfaceConfigurationId);
+    }
+
+    protected void doActivate(String nodeName, String outerName, String innerName, InterfaceConfigurations interfaceConfigurations, L2vpn l2vpn) {
+        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
+        if (!optional.isPresent()) {
+            LOG.error("Could not retrieve MountPoint for {}", nodeName);
+            return;
+        }
+
+        WriteTransaction transaction = optional.get().newWriteOnlyTransaction();
+        transaction.merge(LogicalDatastoreType.CONFIGURATION, InterfaceHelper.getInterfaceConfigurationsId(), interfaceConfigurations);
+        transaction.merge(LogicalDatastoreType.CONFIGURATION, L2vpnHelper.getL2vpnId(), l2vpn);
+
+        try {
+            transaction.submit().checkedGet();
+            LOG.info("Service activated: {} {} {}", nodeName, outerName, innerName);
+        } catch (TransactionCommitFailedException e) {
+            LOG.error("Transaction failed", e);
+        }
+    }
+
+    protected void doDeactivate(String nodeName, String outerName, String innerName,
+                                InstanceIdentifier<P2pXconnect>  xconnectId, InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId) {
+        Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, nodeName);
+        if (!optional.isPresent()) {
+            LOG.error("Could not retrieve MountPoint for {}", nodeName);
+            return;
+        }
+
+        WriteTransaction transaction = optional.get().newWriteOnlyTransaction();
+        transaction.delete(LogicalDatastoreType.CONFIGURATION, xconnectId);
+        transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceConfigurationId);
+
+        try {
+            transaction.submit().checkedGet();
+            LOG.info("Service activated: {} {} {}", nodeName, outerName, innerName);
+        } catch (TransactionCommitFailedException e) {
+            LOG.error("Transaction failed", e);
+        }
+    }
+
+    protected abstract InterfaceConfigurations activateInterface(FcPort portA, FcPort portZ, long mtu);
+
+    protected abstract Pseudowires activatePseudowire(FcPort neighbor);
+
+    protected abstract XconnectGroups activateXConnect(String outerName, String innerName, FcPort portA, FcPort portZ, Pseudowires pseudowires);
+
+    protected abstract L2vpn activateL2Vpn(XconnectGroups xconnectGroups);
+
+    private InstanceIdentifier<P2pXconnect> deactivateXConnect(String outerName, String innerName) {
+        return InstanceIdentifier.builder(L2vpn.class)
+            .child(Database.class)
+            .child(XconnectGroups.class)
+            .child(XconnectGroup.class, new XconnectGroupKey(new CiscoIosXrString(outerName)))
+            .child(P2pXconnects.class).child(P2pXconnect.class, new P2pXconnectKey(new CiscoIosXrString(innerName)))
+            .build();
+    }
+
+    private InstanceIdentifier<InterfaceConfiguration> deactivateInterface(FcPort port) {
+        return InstanceIdentifier.builder(InterfaceConfigurations.class)
+            .child(InterfaceConfiguration.class, new InterfaceConfigurationKey(new InterfaceActive("act"), InterfaceHelper.getInterfaceName(port)))
+            .build();
+    }
+}
\ No newline at end of file
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivator.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivator.java
new file mode 100644 (file)
index 0000000..a9c6931
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.AttachmentCircuitHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.PseudowireHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.XConnectHelper;
+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.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+
+/**
+ * Activator of VPLS-based L2 VPN using bridge connection on IOS-XR devices
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class L2vpnBridgeActivator extends AbstractL2vpnActivator {
+
+    public L2vpnBridgeActivator(DataBroker dataBroker, MountPointService mountService) {
+        super(mountService);
+    }
+
+    @Override
+    protected InterfaceConfigurations activateInterface(FcPort port, FcPort neighbor, long mtu) {
+        return new InterfaceHelper()
+            .addInterface(port, Optional.absent(), true)
+            .addInterface(neighbor, Optional.absent(), true)
+            .build();
+    }
+
+    @Override
+    protected Pseudowires activatePseudowire(FcPort neighbor) {
+        return new PseudowireHelper().build();
+    }
+
+    @Override
+    protected XconnectGroups activateXConnect(String outerName, String innerName, FcPort portA, FcPort portZ, Pseudowires pseudowires) {
+        AttachmentCircuits attachmentCircuits = new AttachmentCircuitHelper()
+            .addPort(portA)
+            .addPort(portZ)
+            .build();
+
+        XconnectGroup xconnectGroup = new XConnectHelper()
+            .appendXConnect(innerName, attachmentCircuits, pseudowires)
+            .build(outerName);
+
+        return XConnectHelper.createXConnectGroups(xconnectGroup);
+    }
+
+    @Override
+    protected L2vpn activateL2Vpn(XconnectGroups xconnectGroups) {
+        return L2vpnHelper.build(xconnectGroups);
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivator.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivator.java
new file mode 100644 (file)
index 0000000..0d1a377
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.LoopbackUtils;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.MtuUtils;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.AttachmentCircuitHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.PseudowireHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.XConnectHelper;
+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._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+
+/**
+ * Activator of VPLS-based L2 VPN using cross connect connection on IOS-XR devices
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class L2vpnXconnectActivator extends AbstractL2vpnActivator {
+
+    public L2vpnXconnectActivator(DataBroker dataBroker, MountPointService mountService) {
+        super(mountService);
+    }
+
+    @Override
+    public InterfaceConfigurations activateInterface(FcPort port, FcPort neighbor, long mtu) {
+        Mtus mtus = new MtuUtils().generateMtus(mtu, new CiscoIosXrString("GigabitEthernet")); //TODO remove hardcoded value
+
+        return new InterfaceHelper()
+            .addInterface(port, Optional.of(mtus), true)
+            .build();
+    }
+
+    @Override
+    public Pseudowires activatePseudowire(FcPort neighbor) {
+        return new PseudowireHelper()
+             .addPseudowire(LoopbackUtils.getIpv4Address(neighbor))
+             .build();
+    }
+
+    @Override
+    public XconnectGroups activateXConnect(String outerName, String innerName, FcPort port, FcPort neighbor, Pseudowires pseudowires) {
+        AttachmentCircuits attachmentCircuits = new AttachmentCircuitHelper()
+             .addPort(port)
+             .build();
+
+        XconnectGroup xconnectGroup = new XConnectHelper()
+             .appendXConnect(innerName, attachmentCircuits, pseudowires)
+             .build(outerName);
+
+        return XConnectHelper.createXConnectGroups(xconnectGroup);
+    }
+
+    @Override
+    public L2vpn activateL2Vpn(XconnectGroups xconnectGroups) {
+        return L2vpnHelper.build(xconnectGroups);
+    }
+}
similarity index 95%
rename from cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnBridgeDriverBuilder.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/driver/L2vpnBridgeDriverBuilder.java
index fb5bccef3da0757a3b0e8319d312b85127457305..7bc05e94e3aa5a611f1fc1ab382d80342fcfec5c 100644 (file)
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.unimgr.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.driver;
 
 import java.util.Optional;
 
@@ -14,6 +14,7 @@ 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.cisco.xr.l2vpn.activator.L2vpnBridgeActivator;
 import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.forwarding.constructs.ForwardingConstruct;
 import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
 
similarity index 95%
rename from cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/L2vpnXconnectDriverBuilder.java
rename to cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/driver/L2vpnXconnectDriverBuilder.java
index 856eb5dfc41f1a722e096134d48e31fd81eef385..ba15346f64b4391a7a7956ae8cb39d25525db525 100644 (file)
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.unimgr.mef.nrp.cisco.xr;
+package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.driver;
 
 import java.util.Optional;
 
@@ -14,6 +14,7 @@ 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.cisco.xr.l2vpn.activator.L2vpnXconnectActivator;
 import org.opendaylight.unimgr.mef.nrp.common.FixedServiceNaming;
 import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.forwarding.constructs.ForwardingConstruct;
 import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelper.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelper.java
new file mode 100644 (file)
index 0000000..45c17bb
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuitsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuitBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Helper, supports configuration of AttachmentCircuits
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class AttachmentCircuitHelper {
+
+    private List<AttachmentCircuit> attachmentCircuits;
+
+    public AttachmentCircuitHelper() {
+        attachmentCircuits = new LinkedList<>();
+    }
+
+    public AttachmentCircuitHelper addPort(FcPort port) {
+        attachmentCircuits.add(
+            new AttachmentCircuitBuilder()
+                .setName(InterfaceHelper.getInterfaceName(port))
+                .setEnable(Boolean.TRUE)
+                .build()
+        );
+
+        return this;
+    }
+
+    public AttachmentCircuits build() {
+        return new AttachmentCircuitsBuilder()
+            .setAttachmentCircuit(attachmentCircuits)
+            .build();
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelper.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelper.java
new file mode 100644 (file)
index 0000000..666e845
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpnBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.Database;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.DatabaseBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+/**
+ * Helper, supports configuration of L2VPN
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class L2vpnHelper {
+
+    public static InstanceIdentifier<L2vpn> getL2vpnId() {
+        return InstanceIdentifier.builder(L2vpn.class).build();
+    }
+
+    public static L2vpn build(XconnectGroups xconnectGroups) {
+        Database database = new DatabaseBuilder()
+            .setXconnectGroups(xconnectGroups)
+            .build();
+
+        return new L2vpnBuilder()
+            .setDatabase(database)
+            .build();
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelper.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelper.java
new file mode 100644 (file)
index 0000000..e99ca52
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+/**
+ * Helper, supports configuration of VPLS neighbors and pseudowires
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.PseudowireIdRange;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.PseudowireLabelRange;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.PseudowiresBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.PseudowireBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.Neighbor;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.NeighborBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabelsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabels;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class PseudowireHelper {
+
+    private long pseudowireId;
+
+    private List<Pseudowire> pseudowires;
+
+    public static class IdGenerator {
+        private static final AtomicLong idGenerator = new AtomicLong(2000L);
+
+        public static long generate() {
+            //TODO implement real pseudowire-id generator
+            return idGenerator.getAndIncrement();
+        }
+    }
+
+    public PseudowireHelper() {
+        this.pseudowireId = IdGenerator.generate();
+        pseudowires = new LinkedList<>();
+    }
+
+    public PseudowireHelper(long pseudowireId) {
+        this.pseudowireId = pseudowireId;
+        pseudowires = new LinkedList<>();
+    }
+
+    public PseudowireHelper addPseudowire(Ipv4AddressNoZone neighbor) {
+        PseudowireIdRange pwId = new PseudowireIdRange(pseudowireId);
+
+        Pseudowire pseudowire = new PseudowireBuilder()
+            .setNeighbor(createNeighbor(neighbor))
+            .setPseudowireId(pwId)
+            .build();
+
+        pseudowires.add(pseudowire);
+
+        return this;
+    }
+
+    public Pseudowires build() {
+        return new PseudowiresBuilder()
+            .setPseudowire(pseudowires)
+            .build();
+    }
+
+    private List<Neighbor> createNeighbor(Ipv4AddressNoZone address) {
+        PseudowireLabelRange label = new PseudowireLabelRange(pseudowireId);
+
+        MplsStaticLabels mplsStaticLabels = new MplsStaticLabelsBuilder()
+                .setLocalStaticLabel(label)
+                .setRemoteStaticLabel(label)
+                .build();
+
+        Neighbor neighbor = new NeighborBuilder()
+                .setNeighbor(address).setMplsStaticLabels(mplsStaticLabels)
+                .setXmlClass(new CiscoIosXrString("static"))
+                .build();
+
+        return Collections.singletonList(neighbor);
+    }
+}
diff --git a/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelper.java b/cisco-xr-driver/src/main/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelper.java
new file mode 100644 (file)
index 0000000..c25f03e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroupsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroupKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnects;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnectsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnectBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Helper, supports configuration of cross-connect connection
+ *
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class XConnectHelper {
+
+    private List<P2pXconnect> p2pXConnects;
+
+    public static XconnectGroups createXConnectGroups(XconnectGroup xconnectGroup) {
+        return createXConnectGroups(Collections.singletonList(xconnectGroup));
+    }
+
+    public static XconnectGroups createXConnectGroups(List<XconnectGroup> xconnectGroups) {
+        return new XconnectGroupsBuilder()
+            .setXconnectGroup(xconnectGroups)
+            .build();
+    }
+
+    public XConnectHelper() {
+        p2pXConnects = new LinkedList<>();
+    }
+
+    public XConnectHelper appendXConnect(String name, AttachmentCircuits attachmentCircuits, Pseudowires pseudowires) {
+        P2pXconnect p2pXconnect = new P2pXconnectBuilder()
+            .setName(new CiscoIosXrString(name))
+            .setAttachmentCircuits(attachmentCircuits)
+            .setPseudowires(pseudowires)
+            .build();
+
+        p2pXConnects.add(p2pXconnect);
+
+        return this;
+    }
+
+    public XconnectGroup build(String name) {
+        return new XconnectGroupBuilder()
+            .setKey(new XconnectGroupKey(new CiscoIosXrString(name)))
+            .setName(new CiscoIosXrString(name))
+            .setP2pXconnects(buildP2pXconnects())
+            .build();
+    }
+
+    private P2pXconnects buildP2pXconnects() {
+        return new P2pXconnectsBuilder()
+                .setP2pXconnect(p2pXConnects)
+                .build();
+    }
+}
index 61bb09ad0c8b51f61020ac4e13855ab3a3f8369c..43d315949c47096e64f2e64a00f94e3af0f5366b 100644 (file)
@@ -13,14 +13,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <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">
+    <bean class="org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.driver.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">
+    <bean class="org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.driver.L2vpnXconnectDriverBuilder">
       <argument ref="dataBroker" />
       <argument ref="mountPointService" />
     </bean>
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelperTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/helper/InterfaceHelperTest.java
new file mode 100644 (file)
index 0000000..e921bc0
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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.cisco.xr.common.helper;
+
+import com.google.common.base.Optional;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.MtuUtils;
+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._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.InterfaceConfiguration3;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.InterfaceName;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class InterfaceHelperTest {
+
+    @Test
+    public void testGetInterfaceName() {
+        //given
+        String interfaceName = "GigabitEthernet0/0/1";
+
+        TpId tp = Mockito.mock(TpId.class);
+        Mockito.when(tp.getValue()).thenReturn(interfaceName);
+
+        FcPort port = Mockito.mock(FcPort.class);
+        Mockito.when(port.getTp()).thenReturn(tp);
+
+        InterfaceName expected = new InterfaceName(interfaceName);
+
+        //when
+        InterfaceName actual = InterfaceHelper.getInterfaceName(port);
+
+        //then
+        assertEquals(expected, actual);
+    }
+
+    @Test
+    public void testGetInterfaceNameSplit() {
+        //given
+        String interfaceName = "xxxxxxxx:GigabitEthernet0/0/1";
+
+        TpId tp = Mockito.mock(TpId.class);
+        Mockito.when(tp.getValue()).thenReturn(interfaceName);
+
+        FcPort port = Mockito.mock(FcPort.class);
+        Mockito.when(port.getTp()).thenReturn(tp);
+
+        InterfaceName expected = new InterfaceName("GigabitEthernet0/0/1");
+
+        //when
+        InterfaceName actual = InterfaceHelper.getInterfaceName(port);
+
+        //then
+        assertEquals(expected, actual);
+    }
+
+    @Test
+    public void testBuildSingle() {
+        //given
+        String interfaceNameValue = "GigabitEthernet0/0/1";
+        InterfaceName interfaceName = new InterfaceName(interfaceNameValue);
+        Optional<Mtus> mtus = Optional.absent();
+        boolean setL2Transport = false;
+
+        InterfaceHelper interfaceHelper = new InterfaceHelper();
+
+        //when
+        interfaceHelper.addInterface(interfaceName, mtus, setL2Transport);
+        InterfaceConfigurations actual = interfaceHelper.build();
+
+        //then
+        assertNotNull(actual);
+
+        List<InterfaceConfiguration> actualInterfaceConfigurationList = actual.getInterfaceConfiguration();
+        assertNotNull(actualInterfaceConfigurationList);
+        assertEquals(1, actualInterfaceConfigurationList.size());
+
+        InterfaceConfiguration actualInterfaceConfiguration = actualInterfaceConfigurationList.get(0);
+
+        assertNotNull(actualInterfaceConfiguration);
+        assertEquals(interfaceName, actualInterfaceConfiguration.getInterfaceName());
+        assertNull(actualInterfaceConfiguration.getMtus());
+        assertNull(actualInterfaceConfiguration.getAugmentation(InterfaceConfiguration3.class));
+    }
+
+    @Test
+    public void testBuildSingleMtuL2() {
+        //given
+        String interfaceNameValue = "GigabitEthernet0/0/1";
+        CiscoIosXrString owner = new CiscoIosXrString("test");
+        long mtuValue = 1522L;
+        InterfaceName interfaceName = new InterfaceName(interfaceNameValue);
+        Optional<Mtus> mtus = Optional.of(MtuUtils.generateMtus(mtuValue, owner));
+        boolean setL2Transport = true;
+
+        InterfaceHelper interfaceHelper = new InterfaceHelper();
+
+        //when
+        interfaceHelper.addInterface(interfaceName, mtus, setL2Transport);
+        InterfaceConfigurations actual = interfaceHelper.build();
+
+        //then
+        assertNotNull(actual);
+
+        List<InterfaceConfiguration> actualInterfaceConfigurationList = actual.getInterfaceConfiguration();
+        assertNotNull(actualInterfaceConfigurationList);
+        assertEquals(1, actualInterfaceConfigurationList.size());
+
+        InterfaceConfiguration actualInterfaceConfiguration = actualInterfaceConfigurationList.get(0);
+
+        assertNotNull(actualInterfaceConfiguration);
+        assertEquals(interfaceName, actualInterfaceConfiguration.getInterfaceName());
+
+        Mtus actualMtus = actualInterfaceConfiguration.getMtus();
+        assertNotNull(actualMtus);
+        List<Mtu> actualMtuList = actualMtus.getMtu();
+        assertNotNull(actualMtuList);
+        assertEquals(1, actualMtuList.size());
+        assertNotNull(actualMtuList.get(0));
+        Mtu actualMtu = actualMtuList.get(0);
+        assertEquals(mtuValue, actualMtu.getMtu().longValue());
+        assertEquals(owner, actualMtu.getOwner());
+
+        InterfaceConfiguration3 l2Configuration = actualInterfaceConfiguration.getAugmentation(InterfaceConfiguration3.class);
+        assertNotNull(l2Configuration);
+        assertNotNull(l2Configuration.getL2Transport());
+        assertTrue(l2Configuration.getL2Transport().isEnabled());
+    }
+
+    @Test
+    public void testBuildMultiple() {
+        //given
+        String interfaceNameValue1 = "GigabitEthernet0/0/1";
+        InterfaceName interfaceName1 = new InterfaceName(interfaceNameValue1);
+        String interfaceNameValue2 = "GigabitEthernet0/0/2";
+        InterfaceName interfaceName2 = new InterfaceName(interfaceNameValue2);
+        Optional<Mtus> mtus = Optional.absent();
+        boolean setL2Transport = false;
+
+        InterfaceHelper interfaceHelper = new InterfaceHelper();
+
+        //when
+        interfaceHelper.addInterface(interfaceName1, mtus, setL2Transport);
+        interfaceHelper.addInterface(interfaceName2, mtus, setL2Transport);
+        InterfaceConfigurations actual = interfaceHelper.build();
+
+        //then
+        assertNotNull(actual);
+
+        List<InterfaceConfiguration> actualInterfaceConfigurationList = actual.getInterfaceConfiguration();
+        assertNotNull(actualInterfaceConfigurationList);
+        assertEquals(2, actualInterfaceConfigurationList.size());
+
+        InterfaceConfiguration actualInterfaceConfiguration = actualInterfaceConfigurationList.get(0);
+
+        assertNotNull(actualInterfaceConfiguration);
+        assertEquals(interfaceName1, actualInterfaceConfiguration.getInterfaceName());
+        assertNull(actualInterfaceConfiguration.getMtus());
+        assertNull(actualInterfaceConfiguration.getAugmentation(InterfaceConfiguration3.class));
+
+        actualInterfaceConfiguration = actualInterfaceConfigurationList.get(1);
+
+        assertNotNull(actualInterfaceConfiguration);
+        assertEquals(interfaceName2, actualInterfaceConfiguration.getInterfaceName());
+        assertNull(actualInterfaceConfiguration.getMtus());
+        assertNull(actualInterfaceConfiguration.getAugmentation(InterfaceConfiguration3.class));
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtilsTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/common/util/MtuUtilsTest.java
new file mode 100644 (file)
index 0000000..1c35862
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.cisco.xr.common.util;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class MtuUtilsTest {
+
+    @Test
+    public void testGenerateMtusSingle() {
+        //given
+        Long mtuValue = 1522L;
+        CiscoIosXrString owner = new CiscoIosXrString("test");
+
+        //when
+        Mtus actual = MtuUtils.generateMtus(mtuValue, owner);
+
+        //then
+        assertNotNull(actual);
+
+        List<Mtu> actualMtuList = actual.getMtu();
+        assertEquals(actualMtuList.size(), 1);
+
+        Mtu actualMtu = actualMtuList.get(0);
+        assertEquals(mtuValue, actualMtu.getMtu());
+        assertEquals(owner, actualMtu.getOwner());
+    }
+
+    @Test
+    public void testGenerateMtusMultiple() {
+        //given
+        List<Long> mtuValues = new LinkedList<>();
+        mtuValues.add(1522L);
+        mtuValues.add(3000L);
+
+        CiscoIosXrString owner = new CiscoIosXrString("test");
+
+        //when
+        Mtus actual = MtuUtils.generateMtus(mtuValues, owner);
+
+        //then
+        assertNotNull(actual);
+
+        List<Mtu> actualMtuList = actual.getMtu();
+        assertEquals(actualMtuList.size(), 2);
+
+        Mtu actualMtu = actualMtuList.get(0);
+        assertEquals(mtuValues.get(0), actualMtu.getMtu());
+        assertEquals(owner, actualMtu.getOwner());
+
+        actualMtu = actualMtuList.get(1);
+        assertEquals(mtuValues.get(1), actualMtu.getMtu());
+        assertEquals(owner, actualMtu.getOwner());
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnActivatorTestUtils.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnActivatorTestUtils.java
new file mode 100644 (file)
index 0000000..1f0118b
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.MountPointHelper;
+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._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.Neighbor;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabels;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.*;
+
+/**
+ * Util class responsible for executing suitable assert operations on given objects.
+ *
+ * @author marek.ryznar@amartus.com
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(MountPointHelper.class)
+public class L2vpnActivatorTestUtils {
+
+    public static MountPointService getMockedMountPointService(Optional<DataBroker> optBroker){
+        PowerMockito.mockStatic(MountPointHelper.class);
+        PowerMockito.when(MountPointHelper.getDataBroker(Mockito.anyObject(),Mockito.anyString())).thenReturn(optBroker);
+        return Mockito.mock(MountPointService.class);
+    }
+
+    public static void checkL2vpn(L2vpn l2vpn){
+        assertNotNull(l2vpn);
+        assertNotNull(l2vpn.getDatabase());
+        assertNotNull(l2vpn.getDatabase().getXconnectGroups());
+    }
+
+    public static void checkXConnectGroup(XconnectGroup xconnectGroup, String outerName){
+        assertNotNull(xconnectGroup);
+        assertEquals(outerName,xconnectGroup.getName().getValue());
+        assertNotNull(xconnectGroup.getP2pXconnects());
+        assertNotNull(xconnectGroup.getP2pXconnects().getP2pXconnect());
+    }
+
+    public static void checkP2pXconnect(P2pXconnect p2pXconnect, String innerName){
+        assertNotNull(p2pXconnect);
+        assertEquals(innerName,p2pXconnect.getName().getValue());
+        assertNotNull(p2pXconnect.getAttachmentCircuits());
+        assertNotNull(p2pXconnect.getAttachmentCircuits().getAttachmentCircuit());
+        assertNotNull(p2pXconnect.getPseudowires());
+        assertNotNull(p2pXconnect.getPseudowires().getPseudowire());
+    }
+
+    public static void checkAttachmentCircuit(AttachmentCircuit attachmentCircuit, String port){
+        assertTrue(attachmentCircuit.isEnable());
+        assertEquals(port,attachmentCircuit.getName().getValue());
+    }
+
+    public static void checkPseudowire(Pseudowire pseudowire){
+        assertNotNull(pseudowire);
+        assertNotNull(pseudowire.getPseudowireId());    //getPseudowireId=PseudowireIdRange [_value=2000]   (hardcoded value)
+        assertNotNull(pseudowire.getNeighbor());
+        assertNotNull(pseudowire.getNeighbor().get(0));
+    }
+
+    public static void checkNeighbor(Neighbor neighbor){
+        assertNotNull(neighbor);
+        assertNotNull(neighbor.getXmlClass());  //getXmlClass=CiscoIosXrString [_value=static], (hardcoded value)
+        assertNotNull(neighbor.getNeighbor());  //getNeighbor=Ipv4Address [_value=127.0.0.1],   (hardcoded value)
+        assertNotNull(neighbor.getMplsStaticLabels());
+    }
+
+    public static void checkMplsStaticLabels(MplsStaticLabels mplsStaticLabels){
+        assertNotNull(mplsStaticLabels);
+        assertNotNull(mplsStaticLabels.getLocalStaticLabel());  //getLocalStaticLabel=PseudowireLabelRange [_value=2000]    (hardcoded value)
+        assertNotNull(mplsStaticLabels.getRemoteStaticLabel()); //getRemoteStaticLabel=PseudowireLabelRange [_value=2000],  (hardcoded value)
+    }
+
+    public static void checkInterfaceConfigurations(InterfaceConfigurations interfaceConfigurations){
+        assertNotNull(interfaceConfigurations);
+        assertNotNull(interfaceConfigurations.getInterfaceConfiguration());
+    }
+
+    public static void checkInterfaceConfiguration(InterfaceConfiguration interfaceConfiguration, String portNo, boolean mtu){
+        assertNotNull(interfaceConfiguration);
+        assertNotNull(interfaceConfiguration.getActive()); //getActive=InterfaceActive [_value=act],                (hardcoded value)
+        assertNotNull(interfaceConfiguration.getInterfaceModeNonPhysical()); //getInterfaceModeNonPhysical=Default  (hardcoded value)
+        assertEquals(portNo,interfaceConfiguration.getInterfaceName().getValue());
+        assertTrue(interfaceConfiguration.isShutdown());
+        if(mtu){
+            assertNotNull(interfaceConfiguration.getMtus());
+            assertNotNull(interfaceConfiguration.getMtus().getMtu());
+        }
+    }
+
+    public static void checkMtu(Mtu mtu, Long mtuValue){
+        assertEquals(mtuValue,mtu.getMtu());
+        assertNotNull(mtu.getOwner());  //getOwner=CiscoIosXrString [_value=GigabitEthernet],   (hardcoded value)
+    }
+
+    public static void checkDeactivation(Optional<DataBroker> optBroker){
+        ReadOnlyTransaction transaction = optBroker.get().newReadOnlyTransaction();
+
+        InstanceIdentifier<L2vpn> l2vpn = InstanceIdentifier.builder(L2vpn.class).build();
+        InstanceIdentifier<InterfaceConfigurations> interfaceConfigurations = InstanceIdentifier.builder(InterfaceConfigurations.class).build();
+
+        CheckedFuture<Optional<L2vpn>, ReadFailedException> driverL2vpn = transaction.read(LogicalDatastoreType.CONFIGURATION, l2vpn);
+        CheckedFuture<Optional<InterfaceConfigurations>, ReadFailedException> driverInterfaceConfigurations = transaction.read(LogicalDatastoreType.CONFIGURATION, interfaceConfigurations);
+
+        try {
+            assertFalse(driverL2vpn.get().isPresent());
+            assertFalse(driverInterfaceConfigurations.get().isPresent());
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public static FcPort port(String topo, String host, String port) {
+        return new FcPortBuilder()
+                .setTopology(new TopologyId(topo))
+                .setNode(new NodeId(host))
+                .setTp(new TpId(port))
+                .build();
+    }
+}
\ No newline at end of file
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivatorTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnBridgeActivatorTest.java
new file mode 100644 (file)
index 0000000..dfb556d
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.MountPointHelper;
+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._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.fail;
+
+/**
+ * @author marek.ryznar@amartus.com
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(MountPointHelper.class)
+public class L2vpnBridgeActivatorTest extends AbstractDataBrokerTest{
+
+    private L2vpnBridgeActivator l2vpnBridgeActivator;
+    private MountPointService mountService;
+    private Optional<DataBroker> optBroker;
+    private String nodeName;
+    private String outerName;
+    private String innerName;
+    private String portNo1;
+    private String portNo2;
+    private FcPort port;
+    private FcPort neighbor;
+    private Long mtu ;
+
+    @Before
+    public void setUp(){
+        //given
+        DataBroker broker = getDataBroker();
+        optBroker = Optional.of(broker);
+
+        mountService = L2vpnActivatorTestUtils.getMockedMountPointService(optBroker);
+        l2vpnBridgeActivator = new L2vpnBridgeActivator(broker,mountService);
+
+        nodeName = "NodeNameExample";
+        outerName = "OuterNameExample";
+        innerName = "InnerNameExample";
+        portNo1 = "80";
+        portNo2 = "8080";
+        port = L2vpnActivatorTestUtils.port("a", "localhost", portNo1);
+        neighbor = L2vpnActivatorTestUtils.port("z", "localhost", portNo2);
+        mtu = Long.valueOf(1500);
+    }
+
+    @Test
+    public void testActivate(){
+        //when
+        l2vpnBridgeActivator.activate(nodeName, outerName, innerName, port, neighbor, mtu);
+
+        //then
+        ReadOnlyTransaction transaction = optBroker.get().newReadOnlyTransaction();
+
+        InstanceIdentifier<L2vpn> l2vpn = InstanceIdentifier.builder(L2vpn.class).build();
+        InstanceIdentifier<InterfaceConfigurations> interfaceConfigurations = InstanceIdentifier.builder(InterfaceConfigurations.class).build();
+
+        CheckedFuture<Optional<L2vpn>, ReadFailedException> driverL2vpn = transaction.read(LogicalDatastoreType.CONFIGURATION, l2vpn);
+        CheckedFuture<Optional<InterfaceConfigurations>, ReadFailedException> driverInterfaceConfigurations = transaction.read(LogicalDatastoreType.CONFIGURATION, interfaceConfigurations);
+
+        try {
+            checkL2vpnTree(driverL2vpn);
+            checkInterfaceConfigurationTree(driverInterfaceConfigurations);
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    @Test
+    public void testDeactivate(){
+        //when
+        l2vpnBridgeActivator.deactivate(nodeName,outerName,innerName,port,neighbor,mtu);
+
+        //then
+        L2vpnActivatorTestUtils.checkDeactivation(optBroker);
+    }
+
+    private void checkL2vpnTree(CheckedFuture<Optional<L2vpn>, ReadFailedException> driverL2vpn) throws InterruptedException, ExecutionException {
+       if (driverL2vpn.get().isPresent()){
+           L2vpn l2vpn = driverL2vpn.get().get();
+           L2vpnActivatorTestUtils.checkL2vpn(l2vpn);
+
+           XconnectGroup xconnectGroup = l2vpn.getDatabase().getXconnectGroups().getXconnectGroup().get(0);
+           L2vpnActivatorTestUtils.checkXConnectGroup(xconnectGroup,outerName);
+
+           P2pXconnect p2pXconnect = xconnectGroup.getP2pXconnects().getP2pXconnect().get(0);
+           L2vpnActivatorTestUtils.checkP2pXconnect(p2pXconnect,innerName);
+
+           AttachmentCircuit attachmentCircuit = p2pXconnect.getAttachmentCircuits().getAttachmentCircuit().get(0);
+           L2vpnActivatorTestUtils.checkAttachmentCircuit(attachmentCircuit,portNo2);
+           attachmentCircuit = p2pXconnect.getAttachmentCircuits().getAttachmentCircuit().get(1);
+           L2vpnActivatorTestUtils.checkAttachmentCircuit(attachmentCircuit,portNo1);
+       } else {
+           fail("L2vpn was not found.");
+       }
+    }
+
+    private void checkInterfaceConfigurationTree(CheckedFuture<Optional<InterfaceConfigurations>, ReadFailedException> driverInterfaceConfigurations) throws InterruptedException, ExecutionException{
+        if (driverInterfaceConfigurations.get().isPresent()){
+            InterfaceConfigurations interfaceConfigurations = driverInterfaceConfigurations.get().get();
+            L2vpnActivatorTestUtils.checkInterfaceConfigurations(interfaceConfigurations);
+
+            List<InterfaceConfiguration> interfaceConfigurationList = interfaceConfigurations.getInterfaceConfiguration();
+            interfaceConfigurationList.sort(
+                    (InterfaceConfiguration ic1, InterfaceConfiguration ic2)
+                            -> ic1.getInterfaceName().getValue().compareTo(ic2.getInterfaceName().getValue()));
+
+            L2vpnActivatorTestUtils.checkInterfaceConfiguration(interfaceConfigurationList.get(0),portNo1,false);
+            L2vpnActivatorTestUtils.checkInterfaceConfiguration(interfaceConfigurationList.get(1),portNo2,false);
+        } else {
+            fail("InterfaceConfigurations was not found.");
+        }
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivatorTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/activator/L2vpnXconnectActivatorTest.java
new file mode 100644 (file)
index 0000000..6a0a6e7
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 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.cisco.xr.l2vpn.activator;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.unimgr.mef.nrp.common.MountPointHelper;
+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._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.mtus.Mtu;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.Neighbor;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabels;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.fail;
+
+/**
+ * @author marek.ryznar@amartus.com
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(MountPointHelper.class)
+public class L2vpnXconnectActivatorTest extends AbstractDataBrokerTest {
+
+    private L2vpnXconnectActivator l2vpnXconnectActivator;
+    private MountPointService mountService;
+    private Optional<DataBroker> optBroker;
+    private String nodeName;
+    private String outerName;
+    private String innerName;
+    private String portNo;
+    private FcPort port;
+    private FcPort neighbor;
+    private Long mtu;
+
+
+    @Before
+    public void setUp(){
+        //given
+        DataBroker broker = getDataBroker();
+        optBroker = Optional.of(broker);
+
+        mountService = L2vpnActivatorTestUtils.getMockedMountPointService(optBroker);
+        l2vpnXconnectActivator = new L2vpnXconnectActivator(broker,mountService);
+
+        nodeName = "NodeNameExample";
+        outerName = "OuterNameExample";
+        innerName = "InnerNameExample";
+        portNo = "80";
+        port = L2vpnActivatorTestUtils.port("a", "localhost", portNo);
+        neighbor = L2vpnActivatorTestUtils.port("z", "localhost", "8080");
+        mtu = Long.valueOf(1500);
+    }
+
+    @Test
+    public void testActivate(){
+        //when
+        l2vpnXconnectActivator.activate(nodeName, outerName, innerName, port, neighbor, mtu);
+
+        //then
+        ReadOnlyTransaction transaction = optBroker.get().newReadOnlyTransaction();
+
+        InstanceIdentifier<L2vpn> l2vpn = InstanceIdentifier.builder(L2vpn.class).build();
+        InstanceIdentifier<InterfaceConfigurations> interfaceConfigurations = InstanceIdentifier.builder(InterfaceConfigurations.class).build();
+
+        CheckedFuture<Optional<L2vpn>, ReadFailedException> driverL2vpn = transaction.read(LogicalDatastoreType.CONFIGURATION, l2vpn);
+        CheckedFuture<Optional<InterfaceConfigurations>, ReadFailedException> driverInterfaceConfigurations = transaction.read(LogicalDatastoreType.CONFIGURATION, interfaceConfigurations);
+
+        try {
+            checkL2vpnTree(driverL2vpn);
+            checkInterfaceConfigurationTree(driverInterfaceConfigurations);
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    @Test
+    public void testDeactivate(){
+        //when
+        l2vpnXconnectActivator.deactivate(nodeName,outerName,innerName,port,neighbor,mtu);
+
+        //then
+        L2vpnActivatorTestUtils.checkDeactivation(optBroker);
+    }
+
+    private void checkL2vpnTree(CheckedFuture<Optional<L2vpn>, ReadFailedException> driverL2vpn) throws InterruptedException, ExecutionException{
+        if (driverL2vpn.get().isPresent()){
+            L2vpn l2vpn = driverL2vpn.get().get();
+            L2vpnActivatorTestUtils.checkL2vpn(l2vpn);
+
+            XconnectGroup xconnectGroup = l2vpn.getDatabase().getXconnectGroups().getXconnectGroup().get(0);
+            L2vpnActivatorTestUtils.checkXConnectGroup(xconnectGroup,outerName);
+
+            P2pXconnect p2pXconnect = xconnectGroup.getP2pXconnects().getP2pXconnect().get(0);
+            L2vpnActivatorTestUtils.checkP2pXconnect(p2pXconnect,innerName);
+
+            AttachmentCircuit attachmentCircuit = p2pXconnect.getAttachmentCircuits().getAttachmentCircuit().get(0);
+            L2vpnActivatorTestUtils.checkAttachmentCircuit(attachmentCircuit,portNo);
+
+            Pseudowire pseudowire = p2pXconnect.getPseudowires().getPseudowire().get(0);
+            L2vpnActivatorTestUtils.checkPseudowire(pseudowire);
+
+            Neighbor neighbor = pseudowire.getNeighbor().get(0);
+            L2vpnActivatorTestUtils.checkNeighbor(neighbor);
+
+            MplsStaticLabels mplsStaticLabels = neighbor.getMplsStaticLabels();
+            L2vpnActivatorTestUtils.checkMplsStaticLabels(mplsStaticLabels);
+        } else {
+            fail("L2vpn was not found.");
+        }
+    }
+
+    private void checkInterfaceConfigurationTree(CheckedFuture<Optional<InterfaceConfigurations>, ReadFailedException> driverInterfaceConfigurations) throws InterruptedException, ExecutionException{
+        if (driverInterfaceConfigurations.get().isPresent()){
+            InterfaceConfigurations interfaceConfigurations = driverInterfaceConfigurations.get().get();
+            L2vpnActivatorTestUtils.checkInterfaceConfigurations(interfaceConfigurations);
+
+            InterfaceConfiguration interfaceConfiguration = interfaceConfigurations.getInterfaceConfiguration().get(0);
+            L2vpnActivatorTestUtils.checkInterfaceConfiguration(interfaceConfiguration,portNo,true);
+
+            Mtu mtu1 = interfaceConfiguration.getMtus().getMtu().get(0);
+            L2vpnActivatorTestUtils.checkMtu(mtu1,mtu);
+        } else {
+            fail("InterfaceConfigurations was not found.");
+        }
+    }
+
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelperTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/AttachmentCircuitHelperTest.java
new file mode 100644 (file)
index 0000000..006ac92
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.InterfaceName;
+import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(InterfaceHelper.class)
+public class AttachmentCircuitHelperTest {
+
+    @Test
+    public void testBuild() {
+        //given
+        InterfaceName interfaceName = new InterfaceName("GigabitEthernet0/0/1");
+
+        FcPort port = Mockito.mock(FcPort.class);
+        PowerMockito.mockStatic(InterfaceHelper.class);
+        PowerMockito.when(InterfaceHelper.getInterfaceName(port)).thenReturn(interfaceName);
+
+        //when
+        AttachmentCircuits actual = new AttachmentCircuitHelper().addPort(port).build();
+
+        //then
+        List<AttachmentCircuit> actualAttachmentCircuitList = actual.getAttachmentCircuit();
+        assertNotNull(actualAttachmentCircuitList);
+        assertEquals(1, actualAttachmentCircuitList.size());
+
+        AttachmentCircuit actualAttachmentCircuit = actualAttachmentCircuitList.get(0);
+        assertNotNull(actualAttachmentCircuit);
+        assertEquals(interfaceName, actualAttachmentCircuit.getName());
+        assertTrue(actualAttachmentCircuit.isEnable());
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelperTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/L2vpnHelperTest.java
new file mode 100644 (file)
index 0000000..1d921c4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.Database;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class L2vpnHelperTest {
+
+    @Test
+    public void build() {
+        //given
+        XconnectGroups xconnectGroups =  Mockito.mock(XconnectGroups.class);
+
+        //when
+        L2vpn actual = L2vpnHelper.build(xconnectGroups);
+
+        //then
+        Database actualDatabase = actual.getDatabase();
+        assertNotNull(actualDatabase);
+
+        XconnectGroups actualXconnectGroups = actualDatabase.getXconnectGroups();
+        assertEquals(xconnectGroups, actualXconnectGroups);
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelperTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/PseudowireHelperTest.java
new file mode 100644 (file)
index 0000000..2bc4ac8
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.Pseudowire;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.Neighbor;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.pseudowires.pseudowire.pseudowire.content.MplsStaticLabels;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class PseudowireHelperTest {
+
+    @Test
+    public void testBuild() {
+        //given
+        Long pseudowireId = 2000L;
+        Ipv4AddressNoZone neighborAddress = new Ipv4AddressNoZone("1.2.3.4");
+
+        //when
+        Pseudowires actual = new PseudowireHelper(pseudowireId).addPseudowire(neighborAddress).build();
+
+        //then
+        assertNotNull(actual);
+
+        List<Pseudowire> actualPseudowireList = actual.getPseudowire();
+        assertNotNull(actualPseudowireList);
+        assertEquals(1, actualPseudowireList.size());
+
+        Pseudowire actualPseudowire = actualPseudowireList.get(0);
+        assertNotNull(actualPseudowire.getNeighbor());
+        assertEquals(1, actualPseudowire.getNeighbor().size());
+        assertEquals(pseudowireId, actualPseudowire.getPseudowireId().getValue());
+
+        List<Neighbor> actualNeighborList = actualPseudowire.getNeighbor();
+        assertNotNull(actualNeighborList);
+        assertEquals(1, actualNeighborList.size());
+
+        Neighbor actualNeighbor = actualNeighborList.get(0);
+        assertNotNull(actualNeighbor);
+        assertEquals(neighborAddress, actualNeighbor.getNeighbor());
+        assertEquals(new CiscoIosXrString("static"), actualNeighbor.getXmlClass());
+
+        MplsStaticLabels actualMplsStaticLabels = actualNeighbor.getMplsStaticLabels();
+        assertNotNull(actualMplsStaticLabels);
+        assertEquals(pseudowireId, actualMplsStaticLabels.getLocalStaticLabel().getValue());
+        assertEquals(pseudowireId, actualMplsStaticLabels.getRemoteStaticLabel().getValue());
+    }
+}
diff --git a/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelperTest.java b/cisco-xr-driver/src/test/java/org/opendaylight/unimgr/mef/nrp/cisco/xr/l2vpn/helper/XConnectHelperTest.java
new file mode 100644 (file)
index 0000000..25e212c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.cisco.xr.l2vpn.helper;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.P2pXconnects;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.P2pXconnect;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.Pseudowires;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author krzysztof.bijakowski@amartus.com
+ */
+public class XConnectHelperTest {
+
+    @Test
+    public void testCreateXConnectGroupsSingle() {
+        //given
+        XconnectGroup xconnectGroup = Mockito.mock(XconnectGroup.class);
+
+        //when
+        XconnectGroups xconnectGroups = XConnectHelper.createXConnectGroups(xconnectGroup);
+
+        //then
+        assertNotNull(xconnectGroups);
+
+        List<XconnectGroup> xconnectGroupList = xconnectGroups.getXconnectGroup();
+        assertNotNull(xconnectGroupList);
+        assertEquals(1, xconnectGroupList.size());
+
+        assertEquals(xconnectGroup, xconnectGroupList.get(0));
+
+    }
+
+    @Test
+    public void testCreateXConnectGroupsMultiple() {
+        //given
+        List<XconnectGroup>xconnectGroupList = new LinkedList<>();
+        xconnectGroupList.add(Mockito.mock(XconnectGroup.class));
+        xconnectGroupList.add(Mockito.mock(XconnectGroup.class));
+        
+        //when
+        XconnectGroups xconnectGroups = XConnectHelper.createXConnectGroups(xconnectGroupList);
+
+        //then
+        assertNotNull(xconnectGroups);
+        assertEquals(xconnectGroupList, xconnectGroups.getXconnectGroup());
+    }
+
+    @Test
+    public void testBuild() {
+        //given
+        //XConnectHelper xConnectHelper =
+        String xConnectName = "ExampleXConnectName";
+        String xConnectGroupName = "ExampleXConnectGroupName";
+        AttachmentCircuits attachmentCircuits = Mockito.mock(AttachmentCircuits.class);
+        Pseudowires pseudowires = Mockito.mock(Pseudowires.class);
+
+        //when
+        XconnectGroup xconnectGroup = new XConnectHelper().appendXConnect(xConnectName, attachmentCircuits, pseudowires).build(xConnectGroupName);
+
+        //then
+        assertNotNull(xconnectGroup);
+        assertEquals(xConnectGroupName, xconnectGroup.getName().getValue());
+        assertEquals(xConnectGroupName, xconnectGroup.getKey().getName().getValue());
+
+        P2pXconnects p2pXconnects = xconnectGroup.getP2pXconnects();
+        assertEquals(p2pXconnects, xconnectGroup.getP2pXconnects());
+        assertNotNull(p2pXconnects);
+
+        List<P2pXconnect> p2pXconnectList =  p2pXconnects.getP2pXconnect();
+        assertNotNull(p2pXconnectList);
+        assertEquals(1, p2pXconnectList.size());
+
+        P2pXconnect p2pXconnect = p2pXconnectList.get(0);
+        assertNotNull(p2pXconnect);
+        assertEquals(xConnectName, p2pXconnect.getName().getValue());
+        assertEquals(pseudowires, p2pXconnect.getPseudowires());
+        assertEquals(attachmentCircuits, p2pXconnect.getAttachmentCircuits());
+    }
+}
\ No newline at end of file
index ad8c3cd08995fd4d981ad42c58e06d26fc8e683d..50daa3849959c3a38c104c4449fc97dca3f47e4c 100644 (file)
@@ -9,7 +9,7 @@ module Cisco-IOS-XR-ip-static-cfg {
 
   /*** LINKAGE (IMPORTS / INCLUDES) ***/
 
-  import ietf-inet-types { prefix "inet"; }
+  import ietf-inet-types { prefix "inet";  revision-date 2013-07-15;}
 
   import Cisco-IOS-XR-types { prefix "xr"; }