2 * Copyright (c) 2016 Cisco Systems Inc and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
12 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileHelper;
13 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
14 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.LoopbackUtils;
15 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.MtuUtils;
16 import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.AttachmentCircuitHelper;
17 import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
18 import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.PseudowireHelper;
19 import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.XConnectHelper;
20 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.asr9k.policymgr.cfg.rev150518.PolicyManager;
21 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurations;
22 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
23 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
24 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.XconnectGroups;
25 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.xconnect.groups.XconnectGroup;
26 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;
27 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;
28 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
29 import org.opendaylight.yang.gen.v1.urn.onf.core.network.module.rev160630.g_forwardingconstruct.FcPort;
31 import java.util.Optional;
33 import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpApplicability.UNI;
34 import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.EGRESS;
35 import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.INGRESS;
39 * Activator of VPLS-based L2 VPN using cross connect connection on IOS-XR devices
41 * @author krzysztof.bijakowski@amartus.com
43 public class L2vpnXconnectActivator extends AbstractL2vpnActivator {
45 public L2vpnXconnectActivator(DataBroker dataBroker, MountPointService mountService) {
46 super(dataBroker, mountService);
50 protected Optional<PolicyManager> activateQos(String name, FcPort port) {
51 return new BandwidthProfileHelper(dataBroker, port)
52 .addPolicyMap(name, INGRESS, UNI)
53 .addPolicyMap(name, EGRESS, UNI)
58 public InterfaceConfigurations activateInterface(FcPort port, FcPort neighbor, long mtu) {
59 Mtus mtus = new MtuUtils().generateMtus(mtu, new CiscoIosXrString("GigabitEthernet"));
61 return new InterfaceHelper()
62 .addInterface(port, Optional.of(mtus), true)
67 public Pseudowires activatePseudowire(FcPort neighbor) {
68 return new PseudowireHelper()
69 .addPseudowire(LoopbackUtils.getIpv4Address(neighbor, dataBroker))
74 public XconnectGroups activateXConnect(String outerName, String innerName, FcPort port, FcPort neighbor, Pseudowires pseudowires) {
75 AttachmentCircuits attachmentCircuits = new AttachmentCircuitHelper()
79 XconnectGroup xconnectGroup = new XConnectHelper()
80 .appendXConnect(innerName, attachmentCircuits, pseudowires)
83 return XConnectHelper.createXConnectGroups(xconnectGroup);
87 public L2vpn activateL2Vpn(XconnectGroups xconnectGroups) {
88 return L2vpnHelper.build(xconnectGroups);