</parent>
<properties>
+ <checkstyle.skip>false</checkstyle.skip>
<powermock.version>2.0.0-beta.5</powermock.version>
<mdsal.version>3.0.8</mdsal.version>
<netconf.version>1.6.1</netconf.version>
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
+
/**
* @author bartosz.michalik@amartus.com
*/
public class TopologyDataHandler implements DataTreeChangeListener<Node> {
private static final Logger LOG = LoggerFactory.getLogger(TopologyDataHandler.class);
public static final InstanceIdentifier<Topology> NETCONF_TOPO_IID =
- InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class,
- new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())));
+ InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
+ new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())));
private final int MAX_RETRIALS = 5;
- private final TopologyManager topologyManager;
+ private final TopologyManager topologyManager;
- LoadingCache<NodeKey, KeyedInstanceIdentifier<Node, NodeKey>> mountIds = CacheBuilder.newBuilder()
- .maximumSize(20)
- .build(
- new CacheLoader<NodeKey, KeyedInstanceIdentifier<Node, NodeKey>>() {
+ LoadingCache<NodeKey, KeyedInstanceIdentifier<Node, NodeKey>> mountIds =
+ CacheBuilder.newBuilder().maximumSize(20)
+ .build(new CacheLoader<NodeKey, KeyedInstanceIdentifier<Node, NodeKey>>() {
public KeyedInstanceIdentifier<Node, NodeKey> load(final NodeKey key) {
return NETCONF_TOPO_IID.child(Node.class, key);
}
private XrCapabilitiesService capabilitiesService;
- public TopologyDataHandler(TopologyManager topologyManager, DataBroker dataBroker, MountPointService mountService) {
+ public TopologyDataHandler(TopologyManager topologyManager, DataBroker dataBroker,
+ MountPointService mountService) {
this.topologyManager = topologyManager;
Objects.requireNonNull(dataBroker);
Objects.requireNonNull(mountService);
ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
NrpDao dao = new NrpDao(tx);
- dao.createNode(topologyManager.getSystemTopologyId(), XrDriverBuilder.XR_NODE, LayerProtocolName.ETH, null);
+ dao.createNode(topologyManager.getSystemTopologyId(), XrDriverBuilder.XR_NODE,
+ LayerProtocolName.ETH, null);
Futures.addCallback(tx.commit(), new FutureCallback<CommitInfo>() {
@Override
@Override
public void onFailure(Throwable t) {
- if(retrialCouter != 0) {
+ if (retrialCouter != 0) {
try {
TimeUnit.MILLISECONDS.sleep(500);
- } catch (InterruptedException _e) { }
- if(retrialCouter != MAX_RETRIALS) {
- LOG.debug("Retrying initialization of {} for {} time", XrDriverBuilder.XR_NODE, MAX_RETRIALS - retrialCouter + 1);
+ } catch (InterruptedException _e) {
+ }
+ if (retrialCouter != MAX_RETRIALS) {
+ LOG.debug("Retrying initialization of {} for {} time",
+ XrDriverBuilder.XR_NODE, MAX_RETRIALS - retrialCouter + 1);
}
initializeWithRetrial(retrialCouter - 1);
} else {
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) {
List<Node> addedNodes = changes.stream().map(DataTreeModification::getRootNode)
- .map(addedNode::apply)
- .filter(n -> {
- if (n == null) return false;
- return capabilitiesService.node(n).isSupporting(AND, NETCONF, NETCONF_CISCO_IOX_IFMGR, NETCONF_CISCO_IOX_L2VPN);
+ .map(addedNode::apply).filter(n -> {
+ if (n == null)
+ return false;
+ return capabilitiesService.node(n).isSupporting(AND, NETCONF,
+ NETCONF_CISCO_IOX_IFMGR, NETCONF_CISCO_IOX_L2VPN);
}).collect(Collectors.toList());
try {
onAddedNodes(addedNodes);
- } catch(Exception e) {
- //TODO improve error handling
+ } catch (Exception e) {
+ // TODO improve error handling
LOG.error("error while processing new Cisco nodes", e);
}
}
private void onAddedNodes(@Nonnull Collection<Node> added) throws ReadFailedException {
- if (added.isEmpty()) return;
+ if (added.isEmpty())
+ return;
LOG.debug("found {} added XR nodes", added.size());
final ReadWriteTransaction topoTx = dataBroker.newReadWriteTransaction();
ServiceInterfacePoint sip = new ServiceInterfacePointBuilder()
.setUuid(new Uuid("sip:" + nep.getUuid().getValue()))
-// .setState(St)
- .setLayerProtocolName(Collections.singletonList(LayerProtocolName.ETH))
- .build();
+ // .setState(St)
+ .setLayerProtocolName(Collections.singletonList(LayerProtocolName.ETH)).build();
dao.addSip(sip);
- MappedServiceInterfacePoint sipRef = TapiUtils.toSipRef(sip.getUuid(), MappedServiceInterfacePoint.class);
- nep = new OwnedNodeEdgePointBuilder(nep).setMappedServiceInterfacePoint(Collections.singletonList(sipRef)).build();
+ MappedServiceInterfacePoint sipRef =
+ TapiUtils.toSipRef(sip.getUuid(), MappedServiceInterfacePoint.class);
+ nep = new OwnedNodeEdgePointBuilder(nep)
+ .setMappedServiceInterfacePoint(Collections.singletonList(sipRef)).build();
LOG.trace("Adding nep {} to {} node", nep.getUuid(), XrDriverBuilder.XR_NODE);
dao.updateNep(XrDriverBuilder.XR_NODE, nep);
});
}, MoreExecutors.directExecutor());
}
- //simplyfied version of selecting
- private Pattern gbPort = Pattern.compile(".*(GigabitEthernet|TenGigE)[^.]+$");
+ // simplyfied version of selecting
+ private Pattern gbPort = Pattern.compile(".*(GigabitEthernet|TenGigE)[^-]+$");
final Predicate<InterfaceConfiguration> isNep = ic -> {
final String name = ic.key().getInterfaceName().getValue();
Optional<MountPoint> mountPoint = mountService.getMountPoint(id);
if (mountPoint.isPresent()) {
DataBroker deviceBroker = mountPoint.get().getService(DataBroker.class).get();
- LOG.debug(deviceBroker.toString());
List<OwnedNodeEdgePoint> tps;
try(ReadTransaction tx = deviceBroker.newReadOnlyTransaction()) {
tps = ports(tx)
- .filter(i -> {
- boolean shutdown = i != null && i.isShutdown() != null && i.isShutdown();
- return !shutdown;
- })
- .filter(isNep::test)
- .map(i -> {
- InterfaceConfigurationKey ikey = i.key();
- LOG.debug("found {} interface", ikey);
-
- Uuid tpId = new Uuid(cn.getNodeId().getValue() + ":" + ikey.getInterfaceName().getValue());
- return tpBuilder
- .setUuid(tpId)
- .withKey(new OwnedNodeEdgePointKey(tpId))
- .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
- .setLinkPortRole(PortRole.SYMMETRIC)
- .setLayerProtocolName(LayerProtocolName.ETH)
- .build();
- }).collect(Collectors.toList());
+ .filter(i -> {
+ boolean shutdown =
+ i != null && i.isShutdown() != null && i.isShutdown();
+ return !shutdown;
+ }).filter(isNep::test).map(i -> {
+ InterfaceConfigurationKey ikey = i.key();
+ LOG.debug("found {} interface", ikey);
+
+ Uuid tpId = new Uuid(cn.getNodeId().getValue() + ":"
+ + ikey.getInterfaceName().getValue());
+ return tpBuilder
+ .setUuid(tpId)
+ .withKey(new OwnedNodeEdgePointKey(tpId))
+ .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
+ .setLinkPortRole(PortRole.SYMMETRIC)
+ .setLayerProtocolName(LayerProtocolName.ETH).build();
+ }).collect(Collectors.toList());
}
return Stream.empty();
}
+
}
@Override
public String getInnerName(String id) {
- return "EUR16-p2p-" + id;
+ return "EUR16-" + id;
+ }
+
+ @Override
+ public String replaceForbidenCharacters(String id) {
+ return id.replace(":", "_");
}
-}
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems Inc and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.unimgr.mef.nrp.cisco.xr.common;
+
+import java.util.Optional;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+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.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MountPointHelper {
+ /**
+ * Find a node's NETCONF mount point and then retrieve its DataBroker. e.
+ * http://localhost:8080/restconf/config/network-topology:network-topology/
+ * topology/topology-netconf/node/{nodeName}/yang-ext:mount/
+ */
+ public static Optional<DataBroker> getDataBroker(MountPointService mountService, String nodeName) {
+ NodeId nodeId = new NodeId(nodeName);
+
+ InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
+ .child(Node.class, new NodeKey(nodeId))
+ .build();
+ final Optional<MountPoint> nodeOptional = mountService.getMountPoint(nodeInstanceId);
+
+ if (!nodeOptional.isPresent()) {
+ return Optional.empty();
+ }
+
+ MountPoint nodeMountPoint = nodeOptional.get();
+ return Optional.of(nodeMountPoint.getService(DataBroker.class).get());
+ }
+
+}
*/
package org.opendaylight.unimgr.mef.nrp.cisco.xr.common;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
+import java.util.stream.Collectors;
import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.SipHandler;
import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev180321.carrier.eth.connectivity.end.point.resource.EgressBwpFlow;
.getCeVlanIdListAndUntag().getVlanId().get(0).getVlanId().getValue().intValue();
}
+ public static boolean isSameDevice(EndPoint endPoint, List<String> ls) {
+ Uuid sip = endPoint.getEndpoint().getServiceInterfacePoint().getServiceInterfacePointId(); //sip:ciscoD1:GigabitEthernet0/0/0/1
+ NodeId nodeId = new NodeId(SipHandler.getDeviceName(sip));
+
+ if (ls.size() == 0) {
+ ls.add(nodeId.getValue());
+ } else if (ls.size() > 0) {
+ List<String> listWithoutDuplicates =
+ ls.stream().distinct().collect(Collectors.toList());
+
+ java.util.Optional<String> preset = listWithoutDuplicates.stream()
+ .filter(x -> x.equals(nodeId.getValue())).findFirst();
+
+ if (preset.isPresent()) {
+ return true;
+ }
+ ls.add(nodeId.getValue());
+ }
+
+ return false;
+ }
+
public String getInterfaceName() {
TpId tpId = this.getTp();
Matcher matcher = interface_name_pattern.matcher(tpId.getValue());
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.infra.policymgr.cfg.rev161215.policy.map.rule.policy.map.rule.Police;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.infra.policymgr.cfg.rev161215.policy.map.rule.policy.map.rule.PoliceBuilder;
import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.infra.policymgr.cfg.rev161215.policy.map.rule.policy.map.rule.police.*;
-
import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.common.rev180321.BwpFlow;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class BandwidthProfileHelper {
}
public BandwidthProfileHelper addPolicyMap(String fcName, BandwidthProfileComposition.BwpDirection direction, BandwidthProfileComposition.BwpApplicability applicability) {
- if(BandwidthProfileComposition.BwpApplicability.UNI == applicability) {
+ if (BandwidthProfileComposition.BwpApplicability.UNI == applicability) {
BwpFlow bwp = null;
- if(direction == BandwidthProfileComposition.BwpDirection.INGRESS) {
+ if (direction == BandwidthProfileComposition.BwpDirection.INGRESS) {
bwp = port.getIngressBwpFlow();
}
- if(direction == BandwidthProfileComposition.BwpDirection.EGRESS) {
+ if (direction == BandwidthProfileComposition.BwpDirection.EGRESS) {
bwp = port.getEgressBwpFlow();
}
- if(bwp == null) return this;
+ if (bwp == null) return this;
PolicyMapRule rule = new PolicyMapRuleBuilder()
.setClassName(CLASS_DEFAULT)
*/
package org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
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.InterfaceModeEnum;
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.l2.eth.infra.cfg.rev151109.InterfaceConfiguration2;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.cfg.rev151109.InterfaceConfiguration2Builder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.cfg.rev151109._interface.configurations._interface.configuration.EthernetServiceBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.cfg.rev151109._interface.configurations._interface.configuration.ethernet.service.Encapsulation;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.cfg.rev151109._interface.configurations._interface.configuration.ethernet.service.EncapsulationBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.datatypes.rev151109.Match;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2.eth.infra.datatypes.rev151109.VlanTagOrAny;
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.xr.types.rev150629.InterfaceName;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Optional;
-
/**
* Helper, designated to support interface configuration
*
return new InterfaceName(interfaceName);
}
+ public static InterfaceName getSubInterfaceName(ServicePort port) {
+ String interfaceName = port.getTp().getValue();
+
+ if (interfaceName.contains(":")) {
+ interfaceName = interfaceName.split(":")[1];
+ }
+ // adding vlan id with interface name
+ interfaceName = interfaceName + "." + port.getVlanId();
+ return new InterfaceName(interfaceName);
+ }
+
+
public static InstanceIdentifier<InterfaceConfigurations> getInterfaceConfigurationsId() {
return InstanceIdentifier.builder(InterfaceConfigurations.class).build();
}
return addInterface(getInterfaceName(port), mtus, setL2Transport);
}
+ public InterfaceHelper addSubInterface(ServicePort port, Optional<Mtus> mtus) {
+ return addSubInterface(getSubInterfaceName(port), mtus, port);
+ }
+
public InterfaceHelper addInterface(InterfaceName name, Optional<Mtus> mtus, boolean setL2Transport) {
InterfaceConfigurationBuilder configurationBuilder = new InterfaceConfigurationBuilder();
configurationBuilder
.setInterfaceName(name)
- .setActive(new InterfaceActive("act"))
- .setShutdown(Boolean.FALSE);
+ .setActive(new InterfaceActive("act"));
if (mtus.isPresent()) {
configurationBuilder.setMtus(mtus.get());
return this;
}
+ public InterfaceHelper addSubInterface(InterfaceName name, Optional<Mtus> mtus, ServicePort port) {
+ InterfaceConfigurationBuilder configurationBuilder = new InterfaceConfigurationBuilder();
+
+ configurationBuilder
+ .setInterfaceName(name)
+ .setActive(new InterfaceActive("act"))
+ //.setShutdown(Boolean.FALSE)
+ .setDescription("Create sub interface through ODL")
+ .setInterfaceModeNonPhysical(InterfaceModeEnum.L2Transport);
+ // set ethernet service
+ setEthernetService(configurationBuilder, port);
+
+ if (mtus.isPresent()) {
+ configurationBuilder.setMtus(mtus.get());
+ }
+ configurations.add(configurationBuilder.build());
+
+ return this;
+ }
+
+ private void setEthernetService(InterfaceConfigurationBuilder configurationBuilder, ServicePort port) {
+ Encapsulation encapsulation = new EncapsulationBuilder()
+ .setOuterRange1Low(new VlanTagOrAny(port.getVlanId()))
+ .setOuterTagType(Match.MatchDot1q)
+ .build();
+
+ InterfaceConfiguration2 augmentation = new InterfaceConfiguration2Builder()
+ .setEthernetService(new EthernetServiceBuilder()
+ .setEncapsulation(encapsulation)
+ .build()
+ )
+ .build();
+
+ configurationBuilder.addAugmentation(InterfaceConfiguration2.class, augmentation);
+ }
+
public InterfaceConfigurations build() {
return new InterfaceConfigurationsBuilder()
.setInterfaceConfiguration(configurations)
private void setL2Configuration(InterfaceConfigurationBuilder configurationBuilder) {
L2Transport l2transport = new L2TransportBuilder()
- .setEnabled(true)
- .build();
+ .setEnabled(true)
+ .build();
InterfaceConfiguration3 augmentation = new InterfaceConfiguration3Builder()
.setL2Transport(l2transport)
configurationBuilder.addAugmentation(InterfaceConfiguration3.class, augmentation);
}
+
}
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;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+
/**
* Tools designated to support MTU-related configuration objects processing
NETCONF_CISCO_IOX_IFMGR((dbBroker, node) ->
checkForNetconfCapability(node,NetconfConstants.CAPABILITY_IOX_IFMGR)),
NETCONF_CISCO_IOX_POLICYMGR((dbBroker, node) ->
- checkForNetconfCapability(node,NetconfConstants.CAPABILITY_IOX_ASR9K_POLICYMGR));
+ checkForNetconfCapability(node,NetconfConstants.CAPABILITY_IOX_INFRA_POLICYMGR));
private BiFunction<DataBroker, Node, Boolean> condition;
import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort.toServicePort;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.MountPointService;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
-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.ResourceActivator;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.infra.policymgr.cfg.rev161215.PolicyManager;
-import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceActive;
+import org.opendaylight.unimgr.utils.NetconfConstants;
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.infra.policymgr.cfg.rev161215.PolicyManager;
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.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.mef.yang.nrp._interface.rev180321.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResource;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
-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.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ServiceType;
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.
+ * 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 static final String NETCONF_TOPOLODY_NAME = "topology-netconf";
- private static final long mtu = 1500;
+ private static final long MTU = 1500;
protected DataBroker dataBroker;
-
- private MountPointService mountService;
+ protected MountPointService mountService;
+ protected static List<String> dvls = new ArrayList<String>();
+ protected static List<Uuid> inls = new ArrayList<Uuid>();
protected AbstractL2vpnActivator(DataBroker dataBroker, MountPointService mountService) {
+ LOG.info(" L2vpn XConnect activator initiated...");
+
this.dataBroker = dataBroker;
this.mountService = mountService;
+ inls.clear();
+ dvls.clear();
}
@Override
public void activate(List<EndPoint> endPoints, String serviceId, boolean isExclusive, ServiceType serviceType) throws InterruptedException, ExecutionException {
- String innerName = getInnerName(serviceId);
- String outerName = getOuterName(serviceId);
+ String innerOuterName = getInnerName(serviceId);
+
ServicePort port = null;
ServicePort neighbor = null;
- for (EndPoint endPoint: endPoints) {
- if (port==null) {
- port = toServicePort(endPoint, NETCONF_TOPOLODY_NAME);
- NrpCarrierEthConnectivityEndPointResource attrs = endPoint.getAttrs() == null ? null : endPoint.getAttrs().getNrpCarrierEthConnectivityEndPointResource();
- if(attrs != null) {
+
+ for (EndPoint endPoint : endPoints) {
+ if (port == null) {
+ port = toServicePort(endPoint, NetconfConstants.NETCONF_TOPOLODY_NAME);
+ NrpCarrierEthConnectivityEndPointResource attrs = endPoint.getAttrs() == null ? null
+ : endPoint.getAttrs().getNrpCarrierEthConnectivityEndPointResource();
+ if (attrs != null) {
port.setEgressBwpFlow(attrs.getEgressBwpFlow());
port.setIngressBwpFlow(attrs.getIngressBwpFlow());
}
} else {
- neighbor = toServicePort(endPoint, NETCONF_TOPOLODY_NAME);
+ neighbor = toServicePort(endPoint, NetconfConstants.NETCONF_TOPOLODY_NAME);
}
}
- java.util.Optional<PolicyManager> qosConfig = activateQos(innerName, port);
- InterfaceConfigurations interfaceConfigurations = activateInterface(port, neighbor, mtu);
+ java.util.Optional<PolicyManager> qosConfig = activateQos(innerOuterName, port);
+ InterfaceConfigurations interfaceConfigurations = activateInterface(port, neighbor, MTU, isExclusive);
Pseudowires pseudowires = activatePseudowire(neighbor);
- XconnectGroups xconnectGroups = activateXConnect(outerName, innerName, port, neighbor, pseudowires);
+ XconnectGroups xconnectGroups = activateXConnect(innerOuterName, innerOuterName, port, neighbor, pseudowires, isExclusive);
L2vpn l2vpn = activateL2Vpn(xconnectGroups);
- doActivate(port.getNode().getValue(), interfaceConfigurations, l2vpn, qosConfig);
+ // create sub interface for tag based service
+ if (!isExclusive) {
+ InterfaceConfigurations subInterfaceConfigurations = createSubInterface(port, neighbor, MTU);
+ createSubInterface(port.getNode().getValue(), subInterfaceConfigurations, mountService);
+ }
+
+ doActivate(port.getNode().getValue(), interfaceConfigurations, l2vpn, mountService, qosConfig);
}
@Override
- public void deactivate(List<EndPoint> endPoints, String serviceId, ServiceType serviceType) throws InterruptedException, ExecutionException {
- String innerName = getInnerName(serviceId);
- String outerName = getOuterName(serviceId);
- ServicePort port = toServicePort(endPoints.stream().findFirst().get(), NETCONF_TOPOLODY_NAME);
-
- InstanceIdentifier<P2pXconnect> xconnectId = deactivateXConnect(outerName, innerName);
- InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId = deactivateInterface(port);
-
- doDeactivate(port.getNode().getValue(), xconnectId, interfaceConfigurationId);
+ public void deactivate(List<EndPoint> endPoints, String serviceId, boolean isExclusive, ServiceType serviceType) throws InterruptedException, ExecutionException {
+ String innerOuterName = getInnerName(serviceId);
+ ServicePort port = toServicePort(endPoints.stream().findFirst().get(), NetconfConstants.NETCONF_TOPOLODY_NAME);
+
+ InstanceIdentifier<P2pXconnect> xconnectId = deactivateXConnect(innerOuterName, innerOuterName);
+ LOG.debug("Is service has vlan ? validate isExclusive : ", isExclusive);
+ InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId = deactivateInterface(port, isExclusive);
+ doDeactivate(port, xconnectId, interfaceConfigurationId, isExclusive, endPoints.stream().findFirst().get(), mountService, dvls, inls);
}
- // for now QoS is ignored
- protected void doActivate(String nodeName,
- InterfaceConfigurations interfaceConfigurations,
- L2vpn l2vpn,
- java.util.Optional<PolicyManager> qosConfig) throws InterruptedException, ExecutionException {
-
- Optional<DataBroker> optional = getMountPointDataBroker(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);
- transaction.commit().get();
- }
+ protected abstract java.util.Optional<PolicyManager> activateQos(String name, ServicePort port);
- protected void doDeactivate(String nodeName,
- InstanceIdentifier<P2pXconnect> xconnectId,
- InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId)
- throws InterruptedException, ExecutionException {
+ protected abstract String getInnerName(String serviceId);
- Optional<DataBroker> optional = getMountPointDataBroker(mountService, nodeName);
- if (!optional.isPresent()) {
- LOG.error("Could not retrieve MountPoint for {}", nodeName);
- return;
- }
+ protected abstract String getOuterName(String serviceId);
- WriteTransaction transaction = optional.get().newWriteOnlyTransaction();
- transaction.delete(LogicalDatastoreType.CONFIGURATION, xconnectId);
- transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceConfigurationId);
- transaction.commit().get();
- }
+ protected abstract InterfaceConfigurations activateInterface(ServicePort portA, ServicePort portZ, long mtu, boolean isExclusive);
- protected abstract java.util.Optional<PolicyManager> activateQos(String name, ServicePort port);
+ protected abstract void createSubInterface(String value, InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2) throws InterruptedException, ExecutionException;
- protected abstract InterfaceConfigurations activateInterface(ServicePort portA, ServicePort portZ, long mtu);
+ protected abstract InterfaceConfigurations createSubInterface(ServicePort portA, ServicePort portZ, long mtu);
protected abstract Pseudowires activatePseudowire(ServicePort neighbor);
- protected abstract XconnectGroups activateXConnect(String outerName, String innerName, ServicePort portA, ServicePort portZ, Pseudowires pseudowires);
+ protected abstract XconnectGroups activateXConnect(String outerName, String innerName, ServicePort portA, ServicePort portZ, Pseudowires pseudowires, boolean isExclusive);
protected abstract L2vpn activateL2Vpn(XconnectGroups xconnectGroups);
+ protected abstract void doActivate(String node, InterfaceConfigurations interfaceConfigurations, L2vpn l2vpn, MountPointService mountService2,
+ java.util.Optional<PolicyManager> qosConfig) throws InterruptedException, ExecutionException;
+
+ protected abstract InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port, boolean isExclusive);
+
private InstanceIdentifier<P2pXconnect> deactivateXConnect(String outerName, String innerName) {
- return InstanceIdentifier.builder(L2vpn.class)
- .child(Database.class)
+ 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)))
+ .child(P2pXconnects.class)
+ .child(P2pXconnect.class, new P2pXconnectKey(new CiscoIosXrString(innerName)))
.build();
}
- private InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port) {
- return InstanceIdentifier.builder(InterfaceConfigurations.class)
- .child(InterfaceConfiguration.class, new InterfaceConfigurationKey(new InterfaceActive("act"), InterfaceHelper.getInterfaceName(port)))
- .build();
- }
+ protected abstract void doDeactivate(ServicePort port, InstanceIdentifier<P2pXconnect> xconnectId, InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, MountPointService mountService2, List<String> dvls, List<Uuid> inls) throws InterruptedException, ExecutionException;
- protected abstract String getInnerName(String serviceId);
- protected abstract String getOuterName(String serviceId);
-
- /**
- * Find a node's NETCONF mount point and then retrieve its DataBroker.
- * e.
- * http://localhost:8080/restconf/config/network-topology:network-topology/
- * topology/topology-netconf/node/{nodeName}/yang-ext:mount/
- */
- protected Optional<DataBroker> getMountPointDataBroker(MountPointService mountService, String nodeName) {
- NodeId nodeId = new NodeId(nodeName);
-
- InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
- .child(Node.class, new NodeKey(nodeId))
- .build();
-
- final Optional<MountPoint> nodeOptional = mountService.getMountPoint(nodeInstanceId);
-
- if (!nodeOptional.isPresent()) {
- return Optional.empty();
- }
-
- MountPoint nodeMountPoint = nodeOptional.get();
- return Optional.of(nodeMountPoint.getService(DataBroker.class).get());
- }
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort.toServicePort;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivator;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivatorException;
+import org.opendaylight.unimgr.utils.NetconfConstants;
+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.infra.policymgr.cfg.rev161215.PolicyManager;
+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.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroupKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.BridgeDomains;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomainKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResource;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortRole;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ServiceType;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public abstract class AbstractL2vpnBridgeDomainActivator implements ResourceActivator {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractL2vpnBridgeDomainActivator.class);
+ private static final long MTU = 1500;
+
+ protected DataBroker dataBroker;
+ protected MountPointService mountService;
+ protected static List<Uuid> inls = new ArrayList<Uuid>();
+ protected static List<String> dvls = new ArrayList<String>();
+
+ protected AbstractL2vpnBridgeDomainActivator(DataBroker dataBroker,
+ MountPointService mountService) {
+ LOG.info(" L2vpn bridge domain activator initiated...");
+
+ this.dataBroker = dataBroker;
+ this.mountService = mountService;
+ inls.clear();
+ dvls.clear();
+ }
+
+ @Override
+ public void activate(List<EndPoint> endPoints, String serviceId, boolean isExclusive, ServiceType serviceType)
+ throws ResourceActivatorException, InterruptedException, ExecutionException {
+ String innerOuterName = getInnerName(serviceId);
+ ServicePort port = null;
+ ServicePort neighbor = null;
+ String portRole = null, neighborRole = null;
+
+ for (EndPoint endPoint : endPoints) {
+ if (port == null) {
+ port = toServicePort(endPoint, NetconfConstants.NETCONF_TOPOLODY_NAME);
+ NrpCarrierEthConnectivityEndPointResource attrs = endPoint.getAttrs() == null ? null
+ : endPoint.getAttrs().getNrpCarrierEthConnectivityEndPointResource();
+ if (attrs != null) {
+ port.setEgressBwpFlow(attrs.getEgressBwpFlow());
+ port.setIngressBwpFlow(attrs.getIngressBwpFlow());
+ }
+ portRole = endPoint.getEndpoint().getRole().name();
+ } else {
+ neighbor = toServicePort(endPoint, NetconfConstants.NETCONF_TOPOLODY_NAME);
+ neighborRole = endPoint.getEndpoint().getRole().name();
+ }
+ }
+
+ java.util.Optional<PolicyManager> qosConfig = activateQos(innerOuterName, port);
+ InterfaceConfigurations interfaceConfigurations = activateInterface(port, neighbor, MTU, isExclusive);
+ BdPseudowires bdPseudowires = activateBdPseudowire(neighbor);
+ BridgeDomainGroups bridgeDomainGroups = activateBridgeDomain(innerOuterName, innerOuterName, port, neighbor, bdPseudowires, isExclusive);
+ L2vpn l2vpn = activateL2Vpn(bridgeDomainGroups);
+
+ // create sub interface for tag based service
+ if (!isExclusive) {
+ InterfaceConfigurations subInterfaceConfigurations = createSubInterface(port, neighbor, MTU);
+ createSubInterface(port.getNode().getValue(), subInterfaceConfigurations, mountService);
+ }
+
+ if (serviceType != null && serviceType.getName().equals(ServiceType.ROOTEDMULTIPOINTCONNECTIVITY.getName())) {
+ if (!(portRole != null && portRole.equals(PortRole.LEAF.getName())
+ && neighborRole != null && neighborRole.equals(PortRole.LEAF.getName()))) {
+ doActivate(port.getNode().getValue(), interfaceConfigurations, l2vpn, mountService, qosConfig);
+ }
+ } else {
+ doActivate(port.getNode().getValue(), interfaceConfigurations, l2vpn, mountService, qosConfig);
+ }
+ }
+
+ @Override
+ public void deactivate(List<EndPoint> endPoints, String serviceId, boolean isExclusive, ServiceType serviceType)
+ throws ResourceActivatorException, InterruptedException, ExecutionException {
+ String innerOuterName = getInnerName(serviceId);
+ ServicePort port = toServicePort(endPoints.stream().findFirst().get(), NetconfConstants.NETCONF_TOPOLODY_NAME);
+
+ InstanceIdentifier<BridgeDomain> bridgeDomainId = deactivateBridgeDomain(innerOuterName, innerOuterName);
+ InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId = deactivateInterface(port, isExclusive);
+ doDeactivate(port, bridgeDomainId, interfaceConfigurationId, isExclusive, endPoints.stream().findFirst().get(), dvls, inls);
+ }
+
+ /**
+ * Function is checking bridge domain configuration already deleted from XR-device.
+ *
+ * @param endPoint
+ * @param ls
+ * @return boolean
+ */
+ protected static boolean isSameInterface(EndPoint endPoint, List<Uuid> ls) {
+ Uuid sip = endPoint.getEndpoint().getServiceInterfacePoint().getServiceInterfacePointId(); // sip:ciscoD1:GigabitEthernet0/0/0/1
+
+ if (ls.size() == 0) {
+ ls.add(sip);
+ } else if (ls.size() > 0) {
+ List<Uuid> listWithoutDuplicates = ls.stream().distinct().collect(Collectors.toList());
+
+ java.util.Optional<Uuid> preset =
+ listWithoutDuplicates.stream().filter(x -> x.equals(sip)).findFirst();
+
+ if (preset.isPresent()) {
+ return true;
+ }
+ ls.add(sip);
+ }
+
+ return false;
+ }
+
+ protected abstract java.util.Optional<PolicyManager> activateQos(String name, ServicePort port);
+
+ protected abstract String getInnerName(String serviceId);
+
+ protected abstract String getOuterName(String serviceId);
+
+ protected abstract InterfaceConfigurations activateInterface(ServicePort portA, ServicePort portZ, long mtu, boolean isExclusive);
+
+ protected abstract void createSubInterface(String value, InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2)
+ throws ResourceActivatorException, InterruptedException, ExecutionException;
+
+ protected abstract InterfaceConfigurations createSubInterface(ServicePort portA, ServicePort portZ, long mtu);
+
+ protected abstract BdPseudowires activateBdPseudowire(ServicePort neighbor);
+
+ protected abstract BridgeDomainGroups activateBridgeDomain(String outerName, String innerName, ServicePort port, ServicePort neighbor, BdPseudowires bdPseudowires,
+ boolean isExclusive);
+
+ protected abstract L2vpn activateL2Vpn(BridgeDomainGroups bridgeDomainGroups);
+
+ protected abstract void doActivate(String node, InterfaceConfigurations interfaceConfigurations, L2vpn l2vpn, MountPointService mountService2,
+ java.util.Optional<PolicyManager> qosConfig) throws ResourceActivatorException, InterruptedException, ExecutionException;
+
+ protected abstract InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port, boolean isExclusive);
+
+ private InstanceIdentifier<BridgeDomain> deactivateBridgeDomain(String outerName, String innerName) {
+
+ return InstanceIdentifier.builder(L2vpn.class).child(Database.class)
+ .child(BridgeDomainGroups.class)
+ .child(BridgeDomainGroup.class, new BridgeDomainGroupKey(new CiscoIosXrString(outerName)))
+ .child(BridgeDomains.class)
+ .child(BridgeDomain.class, new BridgeDomainKey(new CiscoIosXrString(innerName)))
+ .build();
+ }
+
+ protected abstract void doDeactivate(ServicePort port, InstanceIdentifier<BridgeDomain> bridgeDomainId, InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, List<String> dvls2, List<Uuid> inls2) throws ResourceActivatorException, InterruptedException, ExecutionException;
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 java.util.Optional;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
+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.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.ifmgr.cfg.rev150730._interface.configurations._interface.configuration.Mtus;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class InterfaceActivator {
+
+ protected InterfaceConfigurations activate(ServicePort port, ServicePort neighbor, long mtu, boolean isExclusive) {
+ String interfraceName = port.getInterfaceName();
+ new MtuUtils();
+ Mtus mtus = MtuUtils.generateMtus(mtu, new CiscoIosXrString(interfraceName));
+
+ // Enable L2Trasportation for port basesd service
+ boolean setL2Transport = (isExclusive) ? true : false;
+
+ return new InterfaceHelper().addInterface(port, Optional.of(mtus), setL2Transport).build();
+ }
+
+ protected InstanceIdentifier<InterfaceConfiguration> deactivate(ServicePort port, boolean isExclusive) {
+
+ return InstanceIdentifier
+ .builder(
+ InterfaceConfigurations.class)
+ .child(InterfaceConfiguration.class,
+ new InterfaceConfigurationKey(new InterfaceActive("act"),
+ isExclusive == true ? InterfaceHelper.getInterfaceName(port)
+ : InterfaceHelper.getSubInterfaceName(port)))
+ .build();
+ }
+
+ protected InterfaceConfigurations buildSubInterface(ServicePort port, ServicePort neighbor, long mtu) {
+ String mtuOwnerName = "sub_vlan";
+ new MtuUtils();
+ Mtus mtus = MtuUtils.generateMtus(mtu, new CiscoIosXrString(mtuOwnerName));
+
+ return new InterfaceHelper().addSubInterface(port, Optional.of(mtus)).build();
+ }
+
+ protected InterfaceConfigurations activateLocalInterface(ServicePort port, ServicePort neighbor, long mtu, boolean isExclusive) {
+ boolean setL2Transport = (isExclusive) ? true : false;
+
+ return new InterfaceHelper().addInterface(port, Optional.empty(), setL2Transport)
+ .addInterface(neighbor, Optional.empty(), setL2Transport).build();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpApplicability.UNI;
+import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.EGRESS;
+import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.INGRESS;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.FixedServiceNaming;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.LoopbackUtils;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainAttachmentCircuitHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainPseudowireHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
+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.infra.policymgr.cfg.rev161215.PolicyManager;
+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.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public class L2vpnBridgeDomainActivator extends AbstractL2vpnBridgeDomainActivator {
+
+ private final FixedServiceNaming namingProvider;
+
+ public L2vpnBridgeDomainActivator(DataBroker dataBroker, MountPointService mountService) {
+ super(dataBroker, mountService);
+ namingProvider = new FixedServiceNaming();
+ }
+
+ @Override
+ protected Optional<PolicyManager> activateQos(String name, ServicePort port) {
+ return new BandwidthProfileHelper(port).addPolicyMap(name, INGRESS, UNI)
+ .addPolicyMap(name, EGRESS, UNI).build();
+ }
+
+ @Override
+ protected String getInnerName(String serviceId) {
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
+
+ @Override
+ protected String getOuterName(String serviceId) {
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
+
+ @Override
+ protected InterfaceConfigurations activateInterface(ServicePort portA, ServicePort portZ,
+ long mtu, boolean isExclusive) {
+
+ return new InterfaceActivator().activate(portA, portZ, mtu, isExclusive);
+ }
+
+ @Override
+ protected void createSubInterface(String nodeName,
+ InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2)
+ throws InterruptedException, ExecutionException
+ {
+
+ new TransactionActivator().activateSubInterface(nodeName, subInterfaceConfigurations, mountService2);
+ }
+
+ @Override
+ protected InterfaceConfigurations createSubInterface(ServicePort portA, ServicePort portZ,
+ long mtu) {
+
+ return new InterfaceActivator().buildSubInterface(portA, portZ, mtu);
+ }
+
+ @Override
+ protected BdPseudowires activateBdPseudowire(ServicePort neighbor) {
+
+ return new BridgeDomainPseudowireHelper()
+ .addBdPseudowire(LoopbackUtils.getIpv4Address(neighbor, dataBroker)).build();
+ }
+
+ @Override
+ protected BridgeDomainGroups activateBridgeDomain(String outerName, String innerName,
+ ServicePort port, ServicePort neighbor, BdPseudowires bdPseudowires,
+ boolean isExclusive) {
+
+ BdAttachmentCircuits bdattachmentCircuits = new BridgeDomainAttachmentCircuitHelper().addPort(port, isExclusive).build();
+ BridgeDomainGroup bridgeDomainGroup = new BridgeDomainHelper()
+ .appendBridgeDomain(innerName, bdattachmentCircuits, bdPseudowires)
+ .build(outerName);
+
+ return BridgeDomainHelper.createBridgeDomainGroups(bridgeDomainGroup);
+ }
+
+ @Override
+ protected L2vpn activateL2Vpn(BridgeDomainGroups bridgeDomainGroups) {
+
+ return L2vpnHelper.build(bridgeDomainGroups);
+ }
+
+ @Override
+ protected void doActivate(String node, InterfaceConfigurations interfaceConfigurations,
+ L2vpn l2vpn, MountPointService mountService2, Optional<PolicyManager> qosConfig)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activate(node, interfaceConfigurations, l2vpn, mountService2, qosConfig);
+ }
+
+ @Override
+ protected InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port,
+ boolean isExclusive) {
+
+ return new InterfaceActivator().deactivate(port, isExclusive);
+ }
+
+ @Override
+ protected void doDeactivate(ServicePort port, InstanceIdentifier<BridgeDomain> bridgeDomainId,
+ InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, List<String> dvls2, List<Uuid> inls2)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().deactivate(port, bridgeDomainId, interfaceConfigurationId,
+ isExclusive, endPoint, mountService, dvls2, inls2);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpApplicability.UNI;
+import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.EGRESS;
+import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.INGRESS;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.FixedServiceNaming;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainAttachmentCircuitHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.BridgeDomainPseudowireHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.L2vpnHelper;
+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.infra.policymgr.cfg.rev161215.PolicyManager;
+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.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public class L2vpnBridgeDomainLocalActivator extends AbstractL2vpnBridgeDomainActivator {
+
+ private final FixedServiceNaming namingProvider;
+
+ public L2vpnBridgeDomainLocalActivator(DataBroker dataBroker, MountPointService mountService) {
+ super(dataBroker, mountService);
+ namingProvider = new FixedServiceNaming();
+ }
+
+ @Override
+ protected Optional<PolicyManager> activateQos(String name, ServicePort port) {
+ return new BandwidthProfileHelper(port)
+ .addPolicyMap(name, INGRESS, UNI)
+ .addPolicyMap(name, EGRESS, UNI)
+ .build();
+ }
+
+ @Override
+ protected String getInnerName(String serviceId) {
+
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
+
+ @Override
+ protected String getOuterName(String serviceId) {
+
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
+
+ @Override
+ protected InterfaceConfigurations activateInterface(ServicePort portA, ServicePort portZ,
+ long mtu, boolean isExclusive) {
+
+ return new InterfaceActivator().activateLocalInterface(portA, portZ, mtu, isExclusive);
+ }
+
+ @Override
+ protected void createSubInterface(String nodeName,
+ InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activateSubInterface(nodeName, subInterfaceConfigurations,
+ mountService2);
+ }
+
+ @Override
+ protected InterfaceConfigurations createSubInterface(ServicePort portA, ServicePort portZ,
+ long mtu) {
+
+ return new InterfaceActivator().buildSubInterface(portA, portZ, mtu);
+ }
+
+ @Override
+ protected BdPseudowires activateBdPseudowire(ServicePort neighbor) {
+
+ return new BridgeDomainPseudowireHelper().build();
+ }
+
+ @Override
+ protected BridgeDomainGroups activateBridgeDomain(String outerName, String innerName,
+ ServicePort port, ServicePort neighbor, BdPseudowires bdPseudowires,
+ boolean isExclusive) {
+
+ BdAttachmentCircuits bdattachmentCircuits = new BridgeDomainAttachmentCircuitHelper()
+ .addPort(port, isExclusive).addPort(neighbor, isExclusive).build();
+
+ BridgeDomainGroup bridgeDomainGroup = new BridgeDomainHelper()
+ .appendBridgeDomain(innerName, bdattachmentCircuits, bdPseudowires)
+ .build(outerName);
+
+ return BridgeDomainHelper.createBridgeDomainGroups(bridgeDomainGroup);
+ }
+
+ @Override
+ protected L2vpn activateL2Vpn(BridgeDomainGroups bridgeDomainGroups) {
+
+ return L2vpnHelper.build(bridgeDomainGroups);
+ }
+
+ @Override
+ protected void doActivate(String node, InterfaceConfigurations interfaceConfigurations,
+ L2vpn l2vpn, MountPointService mountService2, Optional<PolicyManager> qosConfig)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activate(node, interfaceConfigurations, l2vpn, mountService,
+ qosConfig);
+ }
+
+ @Override
+ protected InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port,
+ boolean isExclusive) {
+
+ return new InterfaceActivator().deactivate(port, isExclusive);
+ }
+
+ @Override
+ protected void doDeactivate(ServicePort port, InstanceIdentifier<BridgeDomain> bridgeDomainId,
+ InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, List<String> dvls2, List<Uuid> inls2)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().deactivate(port, bridgeDomainId, interfaceConfigurationId, isExclusive, endPoint, mountService, dvls2, inls2);
+ }
+
+
+}
import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.EGRESS;
import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.INGRESS;
+import java.util.List;
import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.FixedServiceNaming;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileHelper;
-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.infra.policymgr.cfg.rev161215.PolicyManager;
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.infra.policymgr.cfg.rev161215.PolicyManager;
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.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 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Activator of VPLS-based L2 VPN using bridge connection on IOS-XR devices
*/
public class L2vpnLocalConnectActivator extends AbstractL2vpnActivator {
- private static final String GROUP_NAME = "local";
+ private final FixedServiceNaming namingProvider;
public L2vpnLocalConnectActivator(DataBroker dataBroker, MountPointService mountService) {
super(dataBroker, mountService);
+ namingProvider = new FixedServiceNaming();
}
@Override
}
@Override
- protected InterfaceConfigurations activateInterface(ServicePort port, ServicePort neighbor, long mtu) {
- return new InterfaceHelper()
- .addInterface(port, Optional.empty(), true)
- .addInterface(neighbor, Optional.empty(), true)
- .build();
+ protected InterfaceConfigurations activateInterface(ServicePort port, ServicePort neighbor,
+ long mtu, boolean isExclusive) {
+
+ return new InterfaceActivator().activateLocalInterface(port, neighbor, mtu, isExclusive);
+ }
+
+
+ @Override
+ public InterfaceConfigurations createSubInterface(ServicePort port, ServicePort neighbor,
+ long mtu) {
+
+ return new InterfaceActivator().buildSubInterface(port, neighbor, mtu);
}
@Override
}
@Override
- protected XconnectGroups activateXConnect(String outerName, String innerName, ServicePort portA, ServicePort portZ, Pseudowires pseudowires) {
+ protected XconnectGroups activateXConnect(String outerName, String innerName, ServicePort portA, ServicePort portZ, Pseudowires pseudowires, boolean isExclusive) {
AttachmentCircuits attachmentCircuits = new AttachmentCircuitHelper()
- .addPort(portA)
- .addPort(portZ)
+ .addPort(portA, isExclusive)
+ .addPort(portZ, isExclusive)
.build();
XconnectGroup xconnectGroup = new XConnectHelper()
@Override
protected String getInnerName(String serviceId) {
- return GROUP_NAME;
+ return namingProvider.replaceForbidenCharacters(serviceId);
}
@Override
protected String getOuterName(String serviceId) {
- return GROUP_NAME;
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
+
+ @Override
+ protected void doActivate(String node, InterfaceConfigurations interfaceConfigurations, L2vpn l2vpn, MountPointService mountService2,
+ Optional<PolicyManager> qosConfig) throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activate(node, interfaceConfigurations, l2vpn, mountService2, qosConfig);
+ }
+
+ @Override
+ protected void createSubInterface(String nodeName, InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2)
+ throws InterruptedException, ExecutionException
+ {
+
+ new TransactionActivator().activateSubInterface(nodeName, subInterfaceConfigurations, mountService2);
+ }
+
+ @Override
+ protected InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port, boolean isExclusive) {
+ return new InterfaceActivator().deactivate(port, isExclusive);
+ }
+
+ @Override
+ protected void doDeactivate(ServicePort port, InstanceIdentifier<P2pXconnect> xconnectId, InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, MountPointService mountService2, List<String> dvls, List<Uuid> inls) throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().deactivate(port, xconnectId, interfaceConfigurationId, isExclusive, endPoint, mountService2, dvls, inls);
}
}
import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.EGRESS;
import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileComposition.BwpDirection.INGRESS;
+import java.util.List;
import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.FixedServiceNaming;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.BandwidthProfileHelper;
-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.infra.policymgr.cfg.rev161215.PolicyManager;
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.ifmgr.cfg.rev150730._interface.configurations.InterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.infra.policymgr.cfg.rev161215.PolicyManager;
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.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 org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- * Activator of VPLS-based L2 VPN using cross connect connection on IOS-XR devices
+ * Activator of VPLS-based L2 VPN using cross connect connection on IOS-XR devices.
*
* @author krzysztof.bijakowski@amartus.com
*/
}
@Override
- public InterfaceConfigurations activateInterface(ServicePort port, ServicePort neighbor, long mtu) {
- String interfraceName = port.getInterfaceName();
- Mtus mtus = MtuUtils.generateMtus(mtu, new CiscoIosXrString(interfraceName));
+ protected String getInnerName(String serviceId) {
+ return namingProvider.replaceForbidenCharacters(serviceId);
+ }
- return new InterfaceHelper()
- .addInterface(port, Optional.of(mtus), true)
- .build();
+ @Override
+ protected String getOuterName(String serviceId) {
+ return namingProvider.replaceForbidenCharacters(serviceId);
}
@Override
- public Pseudowires activatePseudowire(ServicePort neighbor) {
+ protected InterfaceConfigurations activateInterface(ServicePort port, ServicePort neighbor,
+ long mtu, boolean isExclusive) {
+
+ return new InterfaceActivator().activate(port, neighbor, mtu, isExclusive);
+ }
+
+ @Override
+ protected void createSubInterface(String nodeName,
+ InterfaceConfigurations subInterfaceConfigurations, MountPointService mountService2)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activateSubInterface(nodeName, subInterfaceConfigurations, mountService2);
+ }
+
+ @Override
+ protected InterfaceConfigurations createSubInterface(ServicePort port, ServicePort neighbor,
+ long mtu) {
+
+ return new InterfaceActivator().buildSubInterface(port, neighbor, mtu);
+ }
+
+ @Override
+ protected Pseudowires activatePseudowire(ServicePort neighbor) {
+
return new PseudowireHelper()
- .addPseudowire(LoopbackUtils.getIpv4Address(neighbor, dataBroker))
- .build();
+ .addPseudowire(LoopbackUtils.getIpv4Address(neighbor, dataBroker)).build();
}
@Override
- public XconnectGroups activateXConnect(String outerName, String innerName, ServicePort port, ServicePort neighbor, Pseudowires pseudowires) {
+ protected XconnectGroups activateXConnect(String outerName, String innerName, ServicePort port,
+ ServicePort portZ, Pseudowires pseudowires, boolean isExclusive) {
+
AttachmentCircuits attachmentCircuits = new AttachmentCircuitHelper()
- .addPort(port)
- .build();
+ .addPort(port, isExclusive)
+ .build();
- XconnectGroup xconnectGroup = new XConnectHelper()
- .appendXConnect(innerName, attachmentCircuits, pseudowires)
- .build(outerName);
+ XconnectGroup xconnectGroup = new XConnectHelper()
+ .appendXConnect(innerName, attachmentCircuits, pseudowires)
+ .build(outerName);
- return XConnectHelper.createXConnectGroups(xconnectGroup);
+ return XConnectHelper.createXConnectGroups(xconnectGroup);
}
@Override
- public L2vpn activateL2Vpn(XconnectGroups xconnectGroups) {
+ protected L2vpn activateL2Vpn(XconnectGroups xconnectGroups) {
+
return L2vpnHelper.build(xconnectGroups);
}
@Override
- protected String getInnerName(String serviceId) {
- return namingProvider.getInnerName(replaceForbidenCharacters(serviceId));
+ protected void doActivate(String nodeName, InterfaceConfigurations interfaceConfigurations,
+ L2vpn l2vpn, MountPointService mountService2, Optional<PolicyManager> qosConfig)
+ throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().activate(nodeName, interfaceConfigurations, l2vpn, mountService, qosConfig);
}
@Override
- protected String getOuterName(String serviceId) {
- return namingProvider.getOuterName(replaceForbidenCharacters(serviceId));
+ protected InstanceIdentifier<InterfaceConfiguration> deactivateInterface(ServicePort port,
+ boolean isExclusive) {
+
+ return new InterfaceActivator().deactivate(port, isExclusive);
}
- /**
- * ASR 9000 can't accept colon in xconnect group name, so it have to be replaced with underscore.
- * If any other restriction will be found, this is a good place to change serviceId name.
- *
- * @param serviceId old service id
- * @return new service id
- */
- private String replaceForbidenCharacters(String serviceId) {
- return serviceId.replace(":","_");
+ @Override
+ protected void doDeactivate(ServicePort port, InstanceIdentifier<P2pXconnect> xconnectId,
+ InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endPoint, MountPointService mountService2,
+ List<String> dvls, List<Uuid> inls) throws InterruptedException, ExecutionException {
+
+ new TransactionActivator().deactivate(port, xconnectId, interfaceConfigurationId, isExclusive, endPoint, mountService, dvls, inls);
}
+
}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.MountPointHelper;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+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.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.infra.policymgr.cfg.rev161215.PolicyManager;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.L2vpn;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TransactionActivator {
+ private static final Logger LOG = LoggerFactory.getLogger(TransactionActivator.class);
+
+ // for now QoS is ignored
+ protected void activate(String nodeName, InterfaceConfigurations interfaceConfigurations, L2vpn l2vpn, MountPointService mountService,
+ java.util.Optional<PolicyManager> qosConfig) throws InterruptedException, ExecutionException {
+
+ 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);
+ transaction.commit().get();
+ }
+
+
+ protected void activateSubInterface(String nodeName, InterfaceConfigurations interfaceConfigurations, MountPointService mountService) throws InterruptedException, ExecutionException
+ {
+
+ 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.commit().get();
+ }
+
+
+ protected void deactivate(ServicePort port, InstanceIdentifier<?> ids, InstanceIdentifier<InterfaceConfiguration> interfaceConfigurationId,
+ boolean isExclusive, EndPoint endpoint, MountPointService mountService, List<String> dvls, List<Uuid> inls) throws InterruptedException, ExecutionException
+ {
+
+ Optional<DataBroker> optional = MountPointHelper.getDataBroker(mountService, port.getNode().getValue());
+ if (!optional.isPresent()) {
+ LOG.error("Could not retrieve MountPoint for {}", port.getNode().getValue());
+ return;
+ }
+
+ WriteTransaction transaction = optional.get().newWriteOnlyTransaction();
+
+ if (ids.getTargetType().equals(
+ 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.class)) {
+
+ if (!ServicePort.isSameDevice(endpoint, dvls)) {
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, ids);
+ }
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceConfigurationId);
+ } else {
+
+ if (!AbstractL2vpnBridgeDomainActivator.isSameInterface(endpoint, inls)) {
+ if (!ServicePort.isSameDevice(endpoint, dvls)) {
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, ids);
+ }
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, interfaceConfigurationId);
+ }
+ }
+ transaction.commit().get();
+ }
+
+}
*/
package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.driver;
+import static org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort.toServicePort;
+
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import org.opendaylight.unimgr.mef.nrp.api.ActivationDriver;
import org.opendaylight.unimgr.mef.nrp.api.ActivationDriverBuilder;
import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util.SipHandler;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.AbstractL2vpnActivator;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.AbstractL2vpnBridgeDomainActivator;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.L2vpnBridgeDomainLocalActivator;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.L2vpnBridgeDomainActivator;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.L2vpnLocalConnectActivator;
import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.activator.L2vpnP2pConnectActivator;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.PseudowireHelper;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivatorException;
+import org.opendaylight.unimgr.utils.NetconfConstants;
import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.NrpConnectivityServiceAttrs;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ServiceType;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private MountPointService mountPointService;
private L2vpnLocalConnectActivator localActivator;
private L2vpnP2pConnectActivator p2pActivator;
+ private L2vpnBridgeDomainActivator bdActivator;
+ private L2vpnBridgeDomainLocalActivator localBdActivator;
public XrDriverBuilder(DataBroker dataBroker, MountPointService mountPointService) {
this.dataBroker = dataBroker;
protected ActivationDriver getDriver() {
final ActivationDriver driver = new ActivationDriver() {
- List<Map.Entry<EndPoint,EndPoint>> bridgeActivatedPairs = null;
+ List<Map.Entry<EndPoint, EndPoint>> bridgeActivatedPairs = null;
List<EndPoint> endPoints;
String serviceId;
- ServiceType serviceType;
boolean isExclusive;
+ ServiceType serviceType;
@Override
public void commit() {
- //ignore for the moment
+ // ignore for the moment
}
@Override
public void rollback() {
- //ignore for the moment
+ // ignore for the moment
}
@Override
- public void initialize(List<EndPoint> endPoints, String serviceId, NrpConnectivityServiceAttrs context, boolean isExclusive, ServiceType serviceType) {
- this.endPoints = new ArrayList<>(endPoints);
+ public void initialize(List<EndPoint> endPoints, String serviceId,
+ NrpConnectivityServiceAttrs context, boolean isExclusive, ServiceType serviceType) {
+ this.endPoints = endPoints;
this.serviceId = serviceId;
this.isExclusive = isExclusive;
this.serviceType = serviceType;
- localActivator = new L2vpnLocalConnectActivator(dataBroker,mountPointService);
- p2pActivator = new L2vpnP2pConnectActivator(dataBroker,mountPointService);
+ if (serviceType != null
+ && (serviceType.getName().equals(ServiceType.MULTIPOINTCONNECTIVITY.getName())
+ || serviceType.getName().equals(
+ ServiceType.ROOTEDMULTIPOINTCONNECTIVITY.getName()))) {
+ localBdActivator =
+ new L2vpnBridgeDomainLocalActivator(dataBroker, mountPointService);
+ bdActivator = new L2vpnBridgeDomainActivator(dataBroker, mountPointService);
+ } else {
+ localActivator = new L2vpnLocalConnectActivator(dataBroker, mountPointService);
+ p2pActivator = new L2vpnP2pConnectActivator(dataBroker, mountPointService);
+ }
}
@Override
- public void activate() {
- handleEndpoints(activate);
+ public void activate() {
+ PseudowireHelper.generatePseudowireId();
+ if (serviceType != null
+ && (serviceType.getName().equals(ServiceType.MULTIPOINTCONNECTIVITY.getName())
+ || serviceType.getName().equals(
+ ServiceType.ROOTEDMULTIPOINTCONNECTIVITY.getName()))) {
+ handleBdEndpoints(activateBd);
+ } else {
+ handleEndpoints(activate);
+ }
}
@Override
- public void deactivate() {
- handleEndpoints(deactivate);
+ public void deactivate() {
+
+ if (serviceType != null
+ && (serviceType.getName().equals(ServiceType.MULTIPOINTCONNECTIVITY.getName())
+ || serviceType.getName().equals(
+ ServiceType.ROOTEDMULTIPOINTCONNECTIVITY.getName()))) {
+ handleBdEndpoints(deactivateBd);
+ } else {
+ handleEndpoints(deactivate);
+ }
}
@Override
return 0;
}
- private void handleEndpoints(BiConsumer<List<EndPoint>,AbstractL2vpnActivator> action) {
- endPoints.forEach(endPoint -> connectWithAllNeighbors(action,endPoint,endPoints));
+ private void handleEndpoints(
+ BiConsumer<List<EndPoint>, AbstractL2vpnActivator> action) {
+ endPoints.forEach(endPoint -> connectWithAllNeighbors(action, endPoint, endPoints));
}
- private void connectWithAllNeighbors(BiConsumer<List<EndPoint>,AbstractL2vpnActivator> action,
- EndPoint endPoint, List<EndPoint> neighbors) {
- neighbors.stream()
- .filter(neighbor -> !neighbor.equals(endPoint))
- .forEach(neighbor -> activateNeighbors(action,endPoint,neighbor));
+ private void connectWithAllNeighbors(
+ BiConsumer<List<EndPoint>, AbstractL2vpnActivator> action, EndPoint endPoint,
+ List<EndPoint> neighbors) {
+ neighbors.stream().filter(neighbor -> !neighbor.equals(endPoint))
+ .forEach(neighbor -> activateNeighbors(action, endPoint, neighbor));
}
- private void activateNeighbors(BiConsumer<List<EndPoint>,AbstractL2vpnActivator> action,
- EndPoint portA, EndPoint portZ) {
- List<EndPoint> endPointsToActivate = Arrays.asList(portA,portZ);
+ private void activateNeighbors(
+ BiConsumer<List<EndPoint>, AbstractL2vpnActivator> action, EndPoint portA,
+ EndPoint portZ) {
+ List<EndPoint> endPointsToActivate = Arrays.asList(portA, portZ);
- if (SipHandler.isTheSameDevice(
- portA.getEndpoint().getServiceInterfacePoint(),
+ if (SipHandler.isTheSameDevice(portA.getEndpoint().getServiceInterfacePoint(),
portZ.getEndpoint().getServiceInterfacePoint())) {
if (bridgeActivatedPairs == null) {
bridgeActivatedPairs = new ArrayList<>();
}
- if (isPairActivated(portA,portZ)) {
- return;
- }
+ /*
+ * if (isPairActivated(portA,portZ)) { return; }
+ */
action.accept(endPointsToActivate, localActivator);
- bridgeActivatedPairs.add(new AbstractMap.SimpleEntry<>(portA,portZ));
+ bridgeActivatedPairs.add(new AbstractMap.SimpleEntry<>(portA, portZ));
} else {
action.accept(endPointsToActivate, p2pActivator);
}
}
private boolean isPairActivated(EndPoint a, EndPoint z) {
- return bridgeActivatedPairs.stream()
- .anyMatch( entry -> {
- if ( (entry.getKey().equals(a) && entry.getValue().equals(z))
- || (entry.getKey().equals(z) && entry.getValue().equals(a))) {
- return true;
- }
- return false;
- });
+ return bridgeActivatedPairs.stream().anyMatch(entry -> {
+ if ((entry.getKey().equals(a) && entry.getValue().equals(z))
+ || (entry.getKey().equals(z) && entry.getValue().equals(a))) {
+ return true;
+ }
+ return false;
+ });
}
- BiConsumer<List<EndPoint>,AbstractL2vpnActivator> activate = (neighbors, activator) -> {
- try {
- activator.activate(neighbors, serviceId, isExclusive, serviceType);
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Activation error occured: {}", e.getMessage());
- }
- };
+ BiConsumer<List<EndPoint>, AbstractL2vpnActivator> activate =
+ (neighbors, activator) -> {
+ try {
+ activator.activate(neighbors, serviceId, isExclusive, serviceType);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Activation error occured: {}", e.getMessage());
+ }
+ };
+
+ BiConsumer<List<EndPoint>, AbstractL2vpnActivator> deactivate =
+ (neighbors, activator) -> {
+ try {
+ activator.deactivate(neighbors, serviceId, isExclusive, serviceType);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Deactivation error occured: {}", e.getMessage());
+ }
+ };
+
+ // L2vpn bridge domain configuration implementation
+ private void handleBdEndpoints(
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> action) {
+ List<String> devlist = new ArrayList<String>();
+
+ endPoints.forEach(e -> {
+ ServicePort port = toServicePort(e, NetconfConstants.NETCONF_TOPOLODY_NAME);
+ devlist.add(port.getNode().getValue());
+ });
- BiConsumer<List<EndPoint>,AbstractL2vpnActivator> deactivate = (neighbors, activator) -> {
- try {
- activator.deactivate(neighbors, serviceId, serviceType);
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Deactivation error occured: {}",e.getMessage());
+ boolean isUniqueDevice = devlist.stream().distinct().limit(2).count() <= 1;
+ if (isUniqueDevice) {
+ endPoints.forEach(endPoint -> connectWithAllBdNeighborsWithSameDevice(action,
+ endPoint, endPoints));
+ } else {
+ endPoints.forEach(
+ endPoint -> connectWithAllBdNeighbors(action, endPoint, endPoints));
}
- };
+ }
+
+ private void connectWithAllBdNeighborsWithSameDevice(
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> action,
+ EndPoint endPoint, List<EndPoint> neighbors) {
+ neighbors.stream().filter(neighbor -> !neighbor.equals(endPoint))
+ .forEach(neighbor -> ignoreBdNeighbors(action, endPoint, neighbor));
+ }
+
+ private void connectWithAllBdNeighbors(
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> action,
+ EndPoint endPoint, List<EndPoint> neighbors) {
+ neighbors.stream().filter(neighbor -> !neighbor.equals(endPoint))
+ .filter(neighbor -> !new NodeId(
+ SipHandler.getDeviceName(neighbor.getEndpoint()
+ .getServiceInterfacePoint().getServiceInterfacePointId()))
+ .getValue()
+ .equals(new NodeId(SipHandler.getDeviceName(endPoint
+ .getEndpoint().getServiceInterfacePoint()
+ .getServiceInterfacePointId())).getValue()))
+ .forEach(neighbor -> activateBdNeighbors(action, endPoint, neighbor));
+ }
+
+
+ private void ignoreBdNeighbors(
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> action,
+ EndPoint portA, EndPoint portZ) {
+ List<EndPoint> endPointsToActivate = Arrays.asList(portA, portZ);
+
+ action.accept(endPointsToActivate, localBdActivator);
+ }
+
+ private void activateBdNeighbors(
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> action,
+ EndPoint portA, EndPoint portZ) {
+ List<EndPoint> endPointsToActivate = Arrays.asList(portA, portZ);
+
+ action.accept(endPointsToActivate, bdActivator);
+ }
+
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> activateBd =
+ (neighbors, activator) -> {
+ try {
+ activator.activate(neighbors, serviceId, isExclusive, serviceType);
+ } catch (InterruptedException | ResourceActivatorException | ExecutionException e) {
+ LOG.error("Activation error occured: {}", e.getMessage());
+ }
+ };
+
+ BiConsumer<List<EndPoint>, AbstractL2vpnBridgeDomainActivator> deactivateBd =
+ (neighbors, activator) -> {
+ try {
+ activator.deactivate(neighbors, serviceId, isExclusive, serviceType);
+ } catch (InterruptedException | ResourceActivatorException | ExecutionException e) {
+ LOG.info("Deactivation error occured: {}", e);
+ LOG.error("Deactivation error occured: {}", e.getMessage());
+ }
+ };
};
attachmentCircuits = new LinkedList<>();
}
- public AttachmentCircuitHelper addPort(ServicePort port) {
+ public AttachmentCircuitHelper addPort(ServicePort port, boolean isExclusive) {
attachmentCircuits.add(
new AttachmentCircuitBuilder()
- .setName(InterfaceHelper.getInterfaceName(port))
+ .setName((isExclusive) ? InterfaceHelper.getInterfaceName(port) : InterfaceHelper.getSubInterfaceName(port))
.setEnable(Boolean.TRUE)
.build()
);
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 java.util.LinkedList;
+import java.util.List;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+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.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuitsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.bd.attachment.circuits.BdAttachmentCircuit;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.bd.attachment.circuits.BdAttachmentCircuitBuilder;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public class BridgeDomainAttachmentCircuitHelper {
+ private List<BdAttachmentCircuit> bdAttachmentCircuits;
+
+
+ public BridgeDomainAttachmentCircuitHelper() {
+ bdAttachmentCircuits = new LinkedList<>();
+ }
+
+ public BridgeDomainAttachmentCircuitHelper addPort(ServicePort port, boolean isExclusive) {
+ bdAttachmentCircuits.add(
+ new BdAttachmentCircuitBuilder()
+ .setName((isExclusive) ? InterfaceHelper.getInterfaceName(port) : InterfaceHelper.getSubInterfaceName(port))
+ .build());
+
+ return this;
+ }
+
+
+ public BdAttachmentCircuits build() {
+ return new BdAttachmentCircuitsBuilder().setBdAttachmentCircuit(bdAttachmentCircuits)
+ .build();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.BridgeDomainGroupsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroupBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroupKey;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.BridgeDomains;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.BridgeDomainsBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomainBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150629.CiscoIosXrString;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public class BridgeDomainHelper {
+
+
+ private List<BridgeDomain> bridgeDomains;
+
+
+ public BridgeDomainHelper() {
+ bridgeDomains = new LinkedList<>();
+ }
+
+ public static BridgeDomainGroups createBridgeDomainGroups(BridgeDomainGroup bridgeDomainGroup) {
+ return createBridgeDomainGroups(Collections.singletonList(bridgeDomainGroup));
+ }
+
+ private static BridgeDomainGroups createBridgeDomainGroups(
+ List<BridgeDomainGroup> bridgeDomainGroups) {
+ return new BridgeDomainGroupsBuilder().setBridgeDomainGroup(bridgeDomainGroups).build();
+ }
+
+ public BridgeDomainHelper appendBridgeDomain(String name, BdAttachmentCircuits bdattachmentCircuits, BdPseudowires bdpseudowires) {
+ BridgeDomain bridgeDomain = new BridgeDomainBuilder()
+ .setName(new CiscoIosXrString(name))
+ .setBdAttachmentCircuits(bdattachmentCircuits)
+ .setBdPseudowires(bdpseudowires)
+ .build();
+
+ bridgeDomains.add(bridgeDomain);
+
+ return this;
+ }
+
+ public BridgeDomainGroup build(String name) {
+ return new BridgeDomainGroupBuilder()
+ .withKey(new BridgeDomainGroupKey(new CiscoIosXrString(name)))
+ .setName(new CiscoIosXrString(name))
+ .setBridgeDomains(buildBridgeDomains())
+ .build();
+ }
+
+ private BridgeDomains buildBridgeDomains() {
+ return new BridgeDomainsBuilder()
+ .setBridgeDomain(bridgeDomains)
+ .build();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 java.util.LinkedList;
+import java.util.List;
+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.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowiresBuilder;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.bd.pseudowires.BdPseudowire;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.bd.pseudowires.BdPseudowireBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+
+/**
+ * @author arif.hussain@xoriant.com
+ */
+public class BridgeDomainPseudowireHelper {
+
+ private List<BdPseudowire> bdpseudowires;
+
+ public BridgeDomainPseudowireHelper() {
+ bdpseudowires = new LinkedList<>();
+ }
+
+ public BridgeDomainPseudowireHelper addBdPseudowire(Ipv4AddressNoZone neighbor) {
+ PseudowireIdRange pwId = new PseudowireIdRange(PseudowireHelper.getPseudowireId());
+
+ BdPseudowire bdpseudowire =
+ new BdPseudowireBuilder().setNeighbor(neighbor).setPseudowireId(pwId).build();
+ bdpseudowires.add(bdpseudowire);
+
+ return this;
+ }
+
+ public BdPseudowires build() {
+ return new BdPseudowiresBuilder().setBdPseudowire(bdpseudowires).build();
+ }
+}
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.BridgeDomainGroups;
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;
.setDatabase(database)
.build();
}
+
+ public static L2vpn build(BridgeDomainGroups bridgeDomainGroups) {
+ Database database = new DatabaseBuilder()
+ .setBridgeDomainGroups(bridgeDomainGroups)
+ .build();
+
+ return new L2vpnBuilder()
+ .setDatabase(database)
+ .build();
+ }
}
*/
package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
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.MplsStaticLabels;
-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.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;
-
/**
* Helper, supports configuration of VPLS neighbors and pseudowires
*
*/
public class PseudowireHelper {
- private long pseudowireId;
+ private static long pseudowireId;
private List<Pseudowire> pseudowires;
private static final AtomicLong idGenerator = new AtomicLong(2000L);
public static long generate() {
- //TODO implement real pseudowire-id generator
+
+ // 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 static long generatePseudowireId() {
+ pseudowireId = IdGenerator.generate();
+ return pseudowireId;
}
public PseudowireHelper addPseudowire(Ipv4AddressNoZone neighbor) {
PseudowireIdRange pwId = new PseudowireIdRange(pseudowireId);
- Pseudowire pseudowire = new PseudowireBuilder()
- .setNeighbor(createNeighbor(neighbor))
- .setPseudowireId(pwId)
- .build();
+
+ Pseudowire pseudowire = new PseudowireBuilder().setNeighbor(createNeighbor(neighbor))
+ .setPseudowireId(pwId).build();
pseudowires.add(pseudowire);
}
public Pseudowires build() {
- return new PseudowiresBuilder()
- .setPseudowire(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"))
+ Neighbor neighbor = new NeighborBuilder().setNeighbor(address)
+ // .setMplsStaticLabels(mplsStaticLabels)
+ // .setXmlClass(new CiscoIosXrString("static"))
.build();
return Collections.singletonList(neighbor);
}
+
+ public static long getPseudowireId() {
+ return pseudowireId;
+ }
}
String CAPABILITY_IOX_IFMGR =
"(http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg?revision=2015-07-30)Cisco-IOS-XR-ifmgr-cfg";
- String CAPABILITY_IOX_ASR9K_POLICYMGR =
- "(http://cisco.com/ns/yang/Cisco-IOS-XR-asr9k-policymgr-cfg?revision=2015-05-18)Cisco-IOS-XR-asr9k-policymgr-cfg";
+ String CAPABILITY_IOX_INFRA_POLICYMGR =
+ "(http://cisco.com/ns/yang/Cisco-IOS-XR-infra-policymgr-cfg?revision=2016-12-15)Cisco-IOS-XR-infra-policymgr-cfg";
+
+ String NETCONF_TOPOLODY_NAME = "topology-netconf";
}
import com.google.common.util.concurrent.FluentFuture;
+
/**
* @author bartosz.michalik@amartus.com
*/
verify(transaction).close();
}
-}
\ No newline at end of file
+}
if (withNetconfCapabilities) {
netconfCapabilityList = Arrays.asList(createAvailableCapability(NetconfConstants.CAPABILITY_IOX_L2VPN),
createAvailableCapability(NetconfConstants.CAPABILITY_IOX_IFMGR),
- createAvailableCapability(NetconfConstants.CAPABILITY_IOX_ASR9K_POLICYMGR));
+ createAvailableCapability(NetconfConstants.CAPABILITY_IOX_INFRA_POLICYMGR));
}
AvailableCapabilities availableCapabilities = Mockito.mock(AvailableCapabilities.class);
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.MountPointHelper;
+import org.opendaylight.unimgr.mef.nrp.common.ResourceActivatorException;
+import org.opendaylight.unimgr.mef.nrp.common.TapiUtils;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev150730.InterfaceConfigurations;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortDirection;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortRole;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ConnectivityServiceEndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ServiceType;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.end.point.ServiceInterfacePoint;
+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 com.google.common.util.concurrent.FluentFuture;
+
+
+/**
+ * @author Om.SAwasthi@Xoriant.Com
+ *
+ */
+@PrepareForTest({AbstractL2vpnActivator.class, MountPointHelper.class})
+@RunWith(PowerMockRunner.class)
+public class AbstractL2vpnBridgeDomainActivatorTest {
+
+ public static final String UUID1 = "sip:ciscoD1:GigabitEthernet0/0/0/1";
+ public static final String UUID2 = "sip:ciscoD2:GigabitEthernet0/0/0/1";
+ private EndPoint ep1;
+ private EndPoint ep2;
+ private AbstractL2vpnBridgeDomainActivator absl2vpnBridgeDomain;
+ private ArrayList<EndPoint> endPoints;
+ private String serviceId = "";
+ private Boolean isExclusive;
+ private ServiceType serviceType;
+ private Optional<DataBroker> optBroker;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() {
+
+ absl2vpnBridgeDomain =
+ Mockito.mock(AbstractL2vpnBridgeDomainActivator.class, Mockito.CALLS_REAL_METHODS);
+ endPoints = new ArrayList<EndPoint>();
+ isExclusive = true;
+ serviceType = ServiceType.POINTTOPOINTCONNECTIVITY;
+
+ ConnectivityServiceEndPoint cep =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPointBuilder()
+ .setServiceInterfacePoint(
+ TapiUtils.toSipRef(new Uuid(UUID1), ServiceInterfacePoint.class))
+ .setDirection(PortDirection.BIDIRECTIONAL).setRole(PortRole.LEAF).build();
+ // .setbuild();
+
+ ep1 = new EndPoint(cep, null);
+ ConnectivityServiceEndPoint cep1 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPointBuilder()
+ .setServiceInterfacePoint(
+ TapiUtils.toSipRef(new Uuid(UUID2), ServiceInterfacePoint.class))
+ .setDirection(PortDirection.BIDIRECTIONAL).setRole(PortRole.LEAF).build();
+ ep2 = new EndPoint(cep1, null);
+ endPoints.add(ep1);
+ endPoints.add(ep2);
+ optBroker = PowerMockito.mock(Optional.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void activateTest() throws ResourceActivatorException, InterruptedException, ExecutionException {
+
+ PowerMockito.mockStatic(MountPointHelper.class);
+ PowerMockito.when(MountPointHelper.getDataBroker(Mockito.any(), Mockito.anyString()))
+ .thenReturn(optBroker);
+ PowerMockito.when(optBroker.isPresent()).thenReturn(true);
+ WriteTransaction transaction = Mockito.mock(WriteTransaction.class);
+ DataBroker databroker = Mockito.mock(DataBroker.class);
+ PowerMockito.when(optBroker.get()).thenReturn(databroker);
+ PowerMockito.when(databroker.newWriteOnlyTransaction()).thenReturn(transaction);
+
+ PowerMockito.doNothing().when(transaction).merge(any(LogicalDatastoreType.class),
+ any(InstanceIdentifier.class), any(InterfaceConfigurations.class));
+ PowerMockito.doNothing().when(transaction).merge(any(LogicalDatastoreType.class),
+ any(InstanceIdentifier.class), Mockito.any());
+ @SuppressWarnings("rawtypes")
+ FluentFuture checkedFuture = Mockito.mock(FluentFuture.class);
+ PowerMockito.when(transaction.commit()).thenReturn(checkedFuture);
+
+ absl2vpnBridgeDomain.activate(endPoints, serviceId, isExclusive, serviceType);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void deactivateTest()
+ throws ResourceActivatorException, InterruptedException, ExecutionException {
+ serviceId = "cs:16b9e18aa84:-364cc8e5";
+
+ PowerMockito.when(absl2vpnBridgeDomain.getInnerName(serviceId)).thenReturn(serviceId);
+ PowerMockito.when(absl2vpnBridgeDomain.getOuterName(serviceId)).thenReturn(serviceId);
+ PowerMockito.mockStatic(MountPointHelper.class);
+ PowerMockito.when(MountPointHelper.getDataBroker(Mockito.any(), Mockito.anyString()))
+ .thenReturn(optBroker);
+ PowerMockito.when(optBroker.isPresent()).thenReturn(true);
+ WriteTransaction transaction = Mockito.mock(WriteTransaction.class);
+ DataBroker databroker = Mockito.mock(DataBroker.class);
+ PowerMockito.when(optBroker.get()).thenReturn(databroker);
+ PowerMockito.when(databroker.newWriteOnlyTransaction()).thenReturn(transaction);
+ PowerMockito.doNothing().when(transaction).delete(any(LogicalDatastoreType.class),
+ any(InstanceIdentifier.class));
+ PowerMockito.doNothing().when(transaction).delete(any(LogicalDatastoreType.class),
+ any(InstanceIdentifier.class));
+ @SuppressWarnings("rawtypes")
+ FluentFuture checkedFuture = Mockito.mock(FluentFuture.class);
+ PowerMockito.when(transaction.commit()).thenReturn(checkedFuture);
+
+ absl2vpnBridgeDomain.deactivate(endPoints, serviceId, isExclusive, serviceType);
+ }
+
+ @Test
+ public void isSameInterfaceTest() {
+
+ List<Uuid> ls = new ArrayList<Uuid>();
+ assertFalse(AbstractL2vpnBridgeDomainActivator.isSameInterface(ep1, ls));
+
+ ls.add(new Uuid(UUID1));
+ assertTrue(AbstractL2vpnBridgeDomainActivator.isSameInterface(ep1, ls));
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Xoriant Corporation 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 static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.common.TapiUtils;
+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.database.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.BridgeDomains;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.bd.attachment.circuits.BdAttachmentCircuit;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortDirection;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ConnectivityServiceEndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.end.point.ServiceInterfacePoint;
+import org.powermock.api.mockito.PowerMockito;
+
+import org.junit.Assert;
+
+/**
+ * @author Om.SAwasthi@Xoriant.Com
+ *
+ */
+public class L2vpnBridgeDomainActivatorTest {
+
+ @Mock
+ private DataBroker dataBroker;
+ @Mock
+ private MountPointService mountService;
+ private static final String uuid1 = "sip:ciscoD1:GigabitEthernet0/0/0/1";
+ private static final String uuid2 = "sip:ciscoD2:GigabitEthernet0/0/0/1";
+ private static final String NETCONF_TOPOLODY_NAME = "topology-netconf";
+ private EndPoint ep1;
+ private EndPoint ep2;
+ private ServicePort port;
+ private ServicePort neighbor;
+ private L2vpnBridgeDomainActivator l2vpnBridgeDomainActivator;
+
+ @Before
+ public void setUp() throws Exception {
+ ConnectivityServiceEndPoint cep =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPointBuilder()
+ .setServiceInterfacePoint(
+ TapiUtils.toSipRef(new Uuid(uuid1), ServiceInterfacePoint.class))
+ .setDirection(PortDirection.BIDIRECTIONAL).build();
+ ep1 = new EndPoint(cep, null);
+ ConnectivityServiceEndPoint cep1 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPointBuilder()
+ .setServiceInterfacePoint(
+ TapiUtils.toSipRef(new Uuid(uuid2), ServiceInterfacePoint.class))
+ .setDirection(PortDirection.BIDIRECTIONAL).build();
+ ep2 = new EndPoint(cep1, null);
+ port = ServicePort.toServicePort(ep1, NETCONF_TOPOLODY_NAME);
+ neighbor = ServicePort.toServicePort(ep2, NETCONF_TOPOLODY_NAME);
+ l2vpnBridgeDomainActivator = new L2vpnBridgeDomainActivator(dataBroker, mountService);
+ }
+
+ @Test
+ public void activateBridgeDomainTest() {
+
+ String outerName = "cs:16b9e18aa84:-364cc8e5";
+ String innerName = "cs:16b9e18aa84:-364cc8e5";
+ BdPseudowires bdPseudowires = PowerMockito.mock(BdPseudowires.class);
+ boolean isExclusive = true;
+
+ BridgeDomainGroups dominGroups = l2vpnBridgeDomainActivator.activateBridgeDomain(outerName,
+ innerName, port, neighbor, bdPseudowires, isExclusive);
+ List<BridgeDomainGroup> domainGroupList = dominGroups.getBridgeDomainGroup();
+ BridgeDomainGroup bridgeDomainGroup = domainGroupList.get(0);
+ BridgeDomains bridgeDomains = bridgeDomainGroup.getBridgeDomains();
+ List<BridgeDomain> bdlist = bridgeDomains.getBridgeDomain();
+
+ BridgeDomain bd = (BridgeDomain) bdlist.get(0);
+ BdAttachmentCircuits bdAttachmentCircuits = bd.getBdAttachmentCircuits();
+ List<BdAttachmentCircuit> bdAttachmentCircuitList =
+ bdAttachmentCircuits.getBdAttachmentCircuit();
+ BdAttachmentCircuit bdAttachmentCircuit = bdAttachmentCircuitList.get(0);
+ assertEquals("GigabitEthernet0/0/0/1", bdAttachmentCircuit.getName().getValue());
+ }
+
+ @Test
+ public void activateInterfaceTest() {
+
+ InterfaceConfigurations interfaceConfigruaton =
+ l2vpnBridgeDomainActivator.activateInterface(port, neighbor, 2000, false);
+ interfaceConfigruaton.getImplementedInterface();
+ List<InterfaceConfiguration> list = interfaceConfigruaton.getInterfaceConfiguration();
+ InterfaceConfiguration interfaceConfiguration = list.get(0);
+ assertEquals("act", interfaceConfiguration.getActive().getValue());
+ }
+
+ @Test
+ public void createSubInterfaceTest() {
+ port.setVlanId(301l);
+ InterfaceConfigurations interfaceConfiguration =
+ l2vpnBridgeDomainActivator.createSubInterface(port, neighbor, 2000);
+ Assert.assertNotNull(interfaceConfiguration);
+ }
+
+}
l2VpnLocalConnectActivator = new L2vpnLocalConnectActivator(getDataBroker(),mountService);
- outerName = "local";
- innerName = "local";
- portNo1 = "80";
- portNo2 = "8080";
+ outerName = "serviceId";
+ innerName = "serviceId";
+ portNo1 = "8080";
+ portNo2 = "8081";
endPoints = L2vpnTestUtils.mockEndpoints(deviceName,deviceName,portNo1,portNo2);
}
deactivate();
//then
- L2vpnTestUtils.checkDeactivated(getDataBroker(), portNo1);
+ L2vpnTestUtils.checkDeactivated(getDataBroker(), portNo2);
}
private void deactivate() {
try {
- l2VpnLocalConnectActivator.deactivate(endPoints,serviceId, ServiceType.POINTTOPOINTCONNECTIVITY);
- } catch (InterruptedException | ExecutionException e) {
+ l2VpnLocalConnectActivator.deactivate(endPoints,serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
+ } catch ( InterruptedException | ExecutionException e) {
fail("Error during deactivation : " + e.getMessage());
}
}
private void activate() {
LOG.debug("activate L2VPN");
try {
- l2VpnLocalConnectActivator.activate(endPoints, serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
+ l2VpnLocalConnectActivator.activate(endPoints,serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
} catch (InterruptedException | ExecutionException e) {
fail("Error during activation : " + e.getMessage());
}
fail("InterfaceConfigurations was not found.");
}
}
-}
\ No newline at end of file
+}
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper.PseudowireHelper;
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.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.otcc.yang.tapi.connectivity.rev180307.ServiceType;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private MountPointService mountService;
private Long mtu;
private String deviceName = "localhost";
- private String portNo1="80";
- private String portNo2="8080";
+ private String portNo1 = "8080";
+ private String portNo2 = "8081";
private String serviceId = "serviceId";
private List<EndPoint> endPoints;
-
+ private List<EndPoint> endPoints1;
@Before
public void setUp() {
//given
mtu = Long.valueOf(1500);
endPoints = L2vpnTestUtils.mockEndpoints(deviceName,deviceName,portNo1,portNo2);
+ endPoints1 = L2vpnTestUtils.mockEndpoints(deviceName,deviceName,portNo2,portNo1);
+
}
@Test
public void testActivateAndDeactivate() {
//when
try {
- l2VpnP2PConnectActivator.activate(endPoints, serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
+ PseudowireHelper.generatePseudowireId();
+ l2VpnP2PConnectActivator.activate(endPoints,serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
+ l2VpnP2PConnectActivator.activate(endPoints1,serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
+
} catch (InterruptedException | ExecutionException e) {
fail("Error during activation : " + e.getMessage());
}
deactivate();
//then
- L2vpnTestUtils.checkDeactivated(getDataBroker(), portNo1);
+ L2vpnTestUtils.checkDeactivated(getDataBroker(), portNo2);
}
private void deactivate() {
//when
try {
- l2VpnP2PConnectActivator.deactivate(endPoints,serviceId, ServiceType.POINTTOPOINTCONNECTIVITY);
+ l2VpnP2PConnectActivator.deactivate(endPoints,serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
} catch (InterruptedException | ExecutionException e) {
fail("Error during deactivation : " + e.getMessage());
}
}
- private void checkL2vpnTree(FluentFuture<Optional<L2vpn>> driverL2vpn) throws InterruptedException, ExecutionException{
+ private void checkL2vpnTree(FluentFuture<Optional<L2vpn>> driverL2vpn) throws InterruptedException, ExecutionException {
if (driverL2vpn.get().isPresent()) {
L2vpn l2vpn = driverL2vpn.get().get();
L2vpnTestUtils.checkL2vpn(l2vpn);
XconnectGroup xconnectGroup = l2vpn.getDatabase().getXconnectGroups().getXconnectGroup().get(0);
- L2vpnTestUtils.checkXConnectGroup(xconnectGroup,"EUR16-"+serviceId);
+ L2vpnTestUtils.checkXConnectGroup(xconnectGroup, serviceId);
P2pXconnect p2pXconnect = xconnectGroup.getP2pXconnects().getP2pXconnect().get(0);
- L2vpnTestUtils.checkP2pXconnect(p2pXconnect,"EUR16-p2p-"+serviceId);
+ L2vpnTestUtils.checkP2pXconnect(p2pXconnect, serviceId);
AttachmentCircuit attachmentCircuit = p2pXconnect.getAttachmentCircuits().getAttachmentCircuit().get(0);
L2vpnTestUtils.checkAttachmentCircuit(attachmentCircuit,portNo1);
Neighbor neighbor = pseudowire.getNeighbor().get(0);
L2vpnTestUtils.checkNeighbor(neighbor);
- MplsStaticLabels mplsStaticLabels = neighbor.getMplsStaticLabels();
- L2vpnTestUtils.checkMplsStaticLabels(mplsStaticLabels);
+ // MplsStaticLabels mplsStaticLabels = neighbor.getMplsStaticLabels();
+ // L2vpnTestUtils.checkMplsStaticLabels(mplsStaticLabels);
} else {
fail("L2vpn was not found.");
}
}
- private void checkInterfaceConfigurationTree(FluentFuture<Optional<InterfaceConfigurations>> driverInterfaceConfigurations) throws InterruptedException, ExecutionException{
+ private void checkInterfaceConfigurationTree(FluentFuture<Optional<InterfaceConfigurations>> driverInterfaceConfigurations) throws InterruptedException, ExecutionException {
if (driverInterfaceConfigurations.get().isPresent()) {
InterfaceConfigurations interfaceConfigurations = driverInterfaceConfigurations.get().get();
L2vpnTestUtils.checkInterfaceConfigurations(interfaceConfigurations);
- InterfaceConfiguration interfaceConfiguration = interfaceConfigurations.getInterfaceConfiguration().get(0);
- L2vpnTestUtils.checkInterfaceConfiguration(interfaceConfiguration,portNo1,true);
+ List<InterfaceConfiguration> interfaceConfigurationList = interfaceConfigurations.getInterfaceConfiguration();
+ interfaceConfigurationList.sort(
+ (InterfaceConfiguration ic1, InterfaceConfiguration ic2)
+ -> ic1.getInterfaceName().getValue().compareTo(ic2.getInterfaceName().getValue()));
+
+ L2vpnTestUtils.checkInterfaceConfiguration(interfaceConfigurationList.get(0),portNo1,false);
- Mtu mtu1 = interfaceConfiguration.getMtus().getMtu().get(0);
+ Mtu mtu1 = interfaceConfigurationList.get(0).getMtus().getMtu().get(0);
L2vpnTestUtils.checkMtu(mtu1,mtu);
} else {
fail("InterfaceConfigurations was not found.");
}
}
-}
\ No newline at end of file
+}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
public static void checkNeighbor(Neighbor neighbor) {
assertNotNull(neighbor);
- assertNotNull(neighbor.getXmlClass());
- assertNotNull(neighbor.getNeighbor());
- assertNotNull(neighbor.getMplsStaticLabels());
- }
+ }
public static void checkMplsStaticLabels(MplsStaticLabels mplsStaticLabels) {
assertNotNull(mplsStaticLabels);
assertNotNull(interfaceConfiguration.getActive());
assertNotNull(interfaceConfiguration.getInterfaceModeNonPhysical());
assertEquals(portNo,interfaceConfiguration.getInterfaceName().getValue());
- assertTrue(interfaceConfiguration.isShutdown());
+ assertNull(interfaceConfiguration.isShutdown());
if (mtu) {
assertNotNull(interfaceConfiguration.getMtus());
assertNotNull(interfaceConfiguration.getMtus().getMtu());
L2vpnTestUtils.checkInterfaceConfigurations(interfaceConfigurations);
List<InterfaceConfiguration> interfaceConfigurationList = interfaceConfigurations.getInterfaceConfiguration();
- assertFalse(interfaceConfigurationList.stream().anyMatch(
- x -> x.getInterfaceName().getValue().equals(deactivatedPort)
- ));
+ assertTrue(interfaceConfigurationList.stream().anyMatch(x -> x.getInterfaceName().getValue().equals(deactivatedPort)));
} else {
// Semantics changed so interface-configurations container disappears when empty?
// fail("InterfaceConfigurations was not found.");
public static List<EndPoint> mockEndpoints(String device1Name, String device2Name, String portNo1, String portNo2) {
List<EndPoint> endPoints = new ArrayList<>();
- endPoints.add(mockEndPoint("sip:"+device1Name+":"+portNo1));
- endPoints.add(mockEndPoint("sip:"+device2Name+":"+portNo2));
+ endPoints.add(mockEndPoint("sip:" + device1Name + ":" + portNo1));
+ endPoints.add(mockEndPoint("sip:" + device2Name + ":" + portNo2));
return endPoints;
}
return new EndPoint(connectivityServiceEndPoint,attrs);
}
-}
\ No newline at end of file
+}
PowerMockito.when(InterfaceHelper.getInterfaceName(port)).thenReturn(interfaceName);
//when
- AttachmentCircuits actual = new AttachmentCircuitHelper().addPort(port).build();
+ AttachmentCircuits actual = new AttachmentCircuitHelper().addPort(port, true).build();
//then
List<AttachmentCircuit> actualAttachmentCircuitList = actual.getAttachmentCircuit();
--- /dev/null
+/*
+ * Copyright (c) 2018 Xoriant Corporation 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 junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.unimgr.mef.nrp.api.EndPoint;
+import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
+import org.opendaylight.unimgr.mef.nrp.common.TapiUtils;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortDirection;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.ConnectivityServiceEndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.end.point.ServiceInterfacePoint;
+
+/**
+ * @author Om.SAwasthi@Xoriant.Com
+ *
+ */
+public class BridgeDomainAttachmentCircuitHelperTest {
+
+ private BridgeDomainAttachmentCircuitHelper bdAttachmentCircuitHelper;
+ private EndPoint ep1;
+ private ServicePort port;
+ private static final String UUID1 = "sip:ciscoD1:GigabitEthernet0/0/0/1";
+ private static final String NETCONF_TOPOLODY_NAME = "topology-netconf";
+
+ @Before
+ public void setUp() throws Exception {
+ bdAttachmentCircuitHelper = new BridgeDomainAttachmentCircuitHelper();
+
+ }
+
+ @Test
+ public void testAddPort() {
+ ConnectivityServiceEndPoint cep =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPointBuilder()
+ .setServiceInterfacePoint(
+ TapiUtils.toSipRef(new Uuid(UUID1), ServiceInterfacePoint.class))
+ .setDirection(PortDirection.BIDIRECTIONAL).build();
+ ep1 = new EndPoint(cep, null);
+ port = ServicePort.toServicePort(ep1, NETCONF_TOPOLODY_NAME);
+ port.setVlanId(301l);
+ BridgeDomainAttachmentCircuitHelper bdAttachmentCircuitHelper1 =
+ bdAttachmentCircuitHelper.addPort(port, false);
+ Assert.assertNotNull(bdAttachmentCircuitHelper1);
+
+ }
+
+ @Test
+ public void testBuild() {
+ BdAttachmentCircuits bdAttachmentCircuits = bdAttachmentCircuitHelper.build();
+ Assert.assertNotNull(bdAttachmentCircuits);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems Inc and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper;
+
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.BridgeDomainGroups;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.BridgeDomainGroup;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdAttachmentCircuits;
+import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev151109.l2vpn.database.bridge.domain.groups.bridge.domain.group.bridge.domains.bridge.domain.BdPseudowires;
+import org.powermock.api.mockito.PowerMockito;
+
+/**
+ * @author Om.SAwasthi@Xoriant.Com
+ *
+ */
+public class BridgeDomainHelperTest {
+ private BridgeDomainHelper bridgeDomainHelper;
+
+ @Before
+ public void setUp() throws Exception {
+ bridgeDomainHelper = new BridgeDomainHelper();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void createBridgeDomainGroupsTest() {
+ BridgeDomainGroup bridgeDomainGroup = PowerMockito.mock(BridgeDomainGroup.class);
+ BridgeDomainGroups bridgeDoaminGroups =
+ BridgeDomainHelper.createBridgeDomainGroups(bridgeDomainGroup);
+ Assert.assertNotNull(bridgeDoaminGroups);
+
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void appendBridgeDomainTest() {
+ String name = "ciscoD2";
+ BdAttachmentCircuits bdattachmentCircuits = PowerMockito.mock(BdAttachmentCircuits.class);
+ BdPseudowires bdpseudowires = PowerMockito.mock(BdPseudowires.class);
+ BridgeDomainHelper bridgeDomainHelper1 =
+ bridgeDomainHelper.appendBridgeDomain(name, bdattachmentCircuits, bdpseudowires);
+ Assert.assertNotNull(bridgeDomainHelper1);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void buildTest() {
+ BridgeDomainGroup bridgeDomainGroups = bridgeDomainHelper.build("ciscoD2");
+ Assert.assertNotNull(bridgeDomainGroups);
+ }
+
+}
*/
package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
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
*/
@Test
public void testBuild() {
//given
- Long pseudowireId = 2000L;
+ Long pseudowireId = PseudowireHelper.generatePseudowireId();
Ipv4AddressNoZone neighborAddress = new Ipv4AddressNoZone("1.2.3.4");
//when
- Pseudowires actual = new PseudowireHelper(pseudowireId).addPseudowire(neighborAddress).build();
-
+ Pseudowires actual = new PseudowireHelper().addPseudowire(neighborAddress).build();
//then
assertNotNull(actual);
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());
}
}
@Test
public void testCreateXConnectGroupsMultiple() {
//given
- List<XconnectGroup>xconnectGroupList = new LinkedList<>();
+ List<XconnectGroup> xconnectGroupList = new LinkedList<>();
xconnectGroupList.add(Mockito.mock(XconnectGroup.class));
xconnectGroupList.add(Mockito.mock(XconnectGroup.class));
-
+
//when
XconnectGroups xconnectGroups = XConnectHelper.createXConnectGroups(xconnectGroupList);
* @throws InterruptedException transaction was interrupted
*/
void activate(List<EndPoint> endPoints, String serviceName, boolean isExclusive, ServiceType serviceType)
- throws ResourceActivatorException, InterruptedException, ExecutionException;
+ throws ResourceActivatorException, InterruptedException, ExecutionException;
/**
* Deactivate connectivity between the provided endpoints.
* @throws ExecutionException transaction execution failed
* @throws InterruptedException transaction was interrupted
*/
- void deactivate(List<EndPoint> endPoints, String serviceName, ServiceType serviceType)
+ void deactivate(List<EndPoint> endPoints, String serviceName, boolean isExclusive, ServiceType serviceType)
throws ResourceActivatorException, InterruptedException, ExecutionException;
}
* @return String name
*/
String getInnerName(String id);
+
+ /**
+ * ASR 9000 can't accept colon in xconnect and bridgeDomain group name, so it have to be replaced with
+ * underscore. If any other restriction will be found, this is a good place to change serviceId
+ * name.
+ *
+ * @param id unique allocated id
+ * @return new id
+ */
+ String replaceForbidenCharacters(String id);
}
ValidationResult validationResult = new ValidationResult();
- if(input.getEndPoint() == null || input.getEndPoint().isEmpty()) {
+ if (input.getEndPoint() == null || input.getEndPoint().isEmpty()) {
validationResult.problem("No endpoints specified for a connectivity service");
} else {
package org.opendaylight.unimgr.mef.nrp.impl.connectivityservice;
import java.text.MessageFormat;
-import java.util.Collections;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
import org.opendaylight.unimgr.mef.nrp.common.TapiUtils;
import org.opendaylight.unimgr.mef.nrp.impl.ActivationTransaction;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint1;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.ServiceInterfacePointRef;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.Context1;
import org.slf4j.LoggerFactory;
/**
- * Delete connectivity implementation.
* @author bartosz.michalik@amartus.com
*/
public class DeleteConnectivityAction implements Callable<RpcResult<DeleteConnectivityServiceOutput>> {
private Uuid serviceId;
private List<Uuid> connectionIds = new LinkedList<>();
- DeleteConnectivityAction(TapiConnectivityServiceImpl tapiConnectivityService,
- DeleteConnectivityServiceInput input) {
+ DeleteConnectivityAction(TapiConnectivityServiceImpl tapiConnectivityService, DeleteConnectivityServiceInput input) {
Objects.requireNonNull(tapiConnectivityService);
Objects.requireNonNull(input);
this.service = tapiConnectivityService;
}
@Override
- @SuppressWarnings("checkstyle:illegalcatch")
public RpcResult<DeleteConnectivityServiceOutput> call() {
serviceId = new Uuid(input.getServiceIdOrName());
NrpDao nrpDao = new NrpDao(service.getBroker().newReadOnlyTransaction());
ConnectivityService cs =
nrpDao.getConnectivityService(serviceId);
+
if (cs == null) {
+ LOG.warn("No ConnectivityService for id {}", input.getServiceIdOrName());
return RpcResultBuilder
.<DeleteConnectivityServiceOutput>failed()
- .withError(RpcError.ErrorType.APPLICATION,
- MessageFormat.format("Service {0} does not exist", input.getServiceIdOrName()))
+ .withError(RpcError.ErrorType.APPLICATION, MessageFormat.format("Service {0} does not exist", input.getServiceIdOrName()))
.build();
}
+
+ LOG.info("ConnectivityService cs = {}", cs.toString());
+
Map<Uuid, LinkedList<EndPoint>> data;
try {
data = prepareData(cs, nrpDao);
LOG.info("Service {} does not exists", input.getServiceIdOrName());
return RpcResultBuilder
.<DeleteConnectivityServiceOutput>failed()
- .withError(RpcError.ErrorType.APPLICATION,
- MessageFormat.format("error while preparing data for service {0} ",
- input.getServiceIdOrName()))
+ .withError(RpcError.ErrorType.APPLICATION, MessageFormat.format("error while preparing data for service {0} ", input.getServiceIdOrName()))
.build();
}
Service response = new ServiceBuilder(cs).build();
try {
- ActivationTransaction tx = prepareTransaction(data, nrpDao, cs.getServiceType());
+ ActivationTransaction tx = prepareTransaction(data,nrpDao, cs.isIsExclusive() , cs.getServiceType());
if (tx != null) {
ActivationTransaction.Result txResult = tx.deactivate();
.setService(new ServiceBuilder(response).build()).build();
return RpcResultBuilder.success(result).build();
} else {
- LOG.warn("CreateConnectivityService deactivation failed, reason = {}, request = {}",
- txResult.getMessage(), input);
+ LOG.warn("CreateConnectivityService deactivation failed, reason = {}, request = {}", txResult.getMessage(), input);
}
}
throw new IllegalStateException("no transaction created for delete connectivity request");
NrpDao nrpDao = new NrpDao(tx);
InstanceIdentifier<Context1> conCtx = NrpDao.ctx().augmentation(Context1.class);
LOG.debug("Removing connectivity service {}", serviceId.getValue());
- tx.delete(LogicalDatastoreType.OPERATIONAL, conCtx.child(ConnectivityService.class,
- new ConnectivityServiceKey(serviceId)));
+ tx.delete(LogicalDatastoreType.OPERATIONAL, conCtx.child(ConnectivityService.class, new ConnectivityServiceKey(serviceId)));
connectionIds.forEach(csId -> {
LOG.debug("Removing connection {}", csId.getValue());
nrpDao.removeConnection(csId);
tx.commit().get();
}
- private ActivationTransaction prepareTransaction(Map<Uuid, LinkedList<EndPoint>> data, NrpDao nrpDao, ServiceType serviceType) {
+ private ActivationTransaction prepareTransaction(Map<Uuid, LinkedList<EndPoint>> data, NrpDao nrpDao, boolean isExclusive, ServiceType serviceType) {
assert data != null;
ActivationTransaction tx = new ActivationTransaction();
data.entrySet().stream().map(e -> {
LOG.warn("Unable to get activationDriverId for node {}",e.getKey(),e1);
}
if (!driver.isPresent()) {
- throw new IllegalStateException(MessageFormat
- .format("driver {} cannot be created", e.getKey()));
+ throw new IllegalStateException(MessageFormat.format("driver {} cannot be created", e.getKey()));
}
- driver.get().initialize(e.getValue(), serviceId.getValue(), null, false, serviceType);
+ driver.get().initialize(e.getValue(), serviceId.getValue(), null, isExclusive, serviceType);
LOG.debug("driver {} added to deactivation transaction", driver.get());
return driver.get();
}).forEach(tx::addDriver);
final Uuid nodeId = c.getConnectionEndPoint().get(0).getNodeId();
return c.getConnectionEndPoint().stream().map(cep -> {
- Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
- .connectivity.service.EndPoint> optEndPoint = Optional.empty();
+ Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPoint> optEndPoint = Optional.empty();
OwnedNodeEdgePoint nep = nrpDao.getNepByCep(cep);
.filter(csEp -> {
Uuid csSip = csEp.getServiceInterfacePoint().getServiceInterfacePointId();
return nep.getMappedServiceInterfacePoint().stream()
- .map(ServiceInterfacePointRef::getServiceInterfacePointId)
- .anyMatch(mSip -> mSip.equals(csSip));
+ .map(ServiceInterfacePointRef::getServiceInterfacePointId).anyMatch(mSip -> mSip.equals(csSip));
})
.findFirst();
}
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
- .connectivity.service.EndPoint endPoint = optEndPoint.orElse(null);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.EndPoint endPoint =
+ optEndPoint.orElse(null);
-
- EndPoint ep = new EndPoint(endPoint, null)
- .setNepRef(TapiUtils.toSysNepRef(nodeId, nep.getUuid()));
+ EndPoint ep = new EndPoint(endPoint, endPoint.augmentation(EndPoint1.class)).setNepRef(TapiUtils.toSysNepRef(nodeId, nep.getUuid()));
return new Pair(nodeId, ep);
});
- }).collect(Collectors
- .toMap(Pair::getNodeId, p -> new LinkedList<>(Collections.singletonList(p.getEndPoint())),
- (ol, nl) -> {
- ol.addAll(nl);
- return ol;
- }
- ));
+ }).collect(Collectors.toMap(Pair::getNodeId, p -> new LinkedList<>(Arrays.asList(p.getEndPoint())), (ol, nl) -> {
+ ol.addAll(nl);
+ return ol;
+ }));
}
- private static final class Pair {
+ private static class Pair {
private final Uuid nodeId;
private final EndPoint endPoint;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.powermock.api.mockito.PowerMockito;
-import org.powermock.api.support.membermodification.MemberMatcher;
-import org.powermock.api.support.membermodification.MemberModifier;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
* @author Om.SAwasthi@Xoriant.Com
*/
-@SuppressWarnings("deprecation")
@RunWith(PowerMockRunner.class)
@PrepareForTest({LegatoUtils.class})
public class EvpLineIntegrationTest {
}
@Override
- public void deactivate(List<EndPoint> endPoints, String serviceName, ServiceType serviceType)
+ public void deactivate(List<EndPoint> endPoints, String serviceName, boolean isExclusive, ServiceType serviceType)
throws InterruptedException, ExecutionException, ResourceNotAvailableException {
- boolean isExclusive = false;
-
for (EndPoint endPoint:endPoints) {
deactivateEndpoint(endPoint, serviceName);
}
@Override
public void deactivate() throws ResourceNotAvailableException, InterruptedException, ExecutionException {
- activator.deactivate(endPoints, serviceId, serviceType);
+ activator.deactivate(endPoints, serviceId, isExclusive, serviceType);
}
@Override
Nodes nodes = readOpenFLowTopology(dataBroker);
Node odlNode = OvsdbUtils.getOdlNode(dataBroker);
checkTable(nodes,activated);
- System.out.println("Before deactivation: "+ nodes.toString());
//when
try {
- ovsActivator.deactivate(endPoints, serviceId, ServiceType.POINTTOPOINTCONNECTIVITY);
+ ovsActivator.deactivate(endPoints, serviceId, true, ServiceType.POINTTOPOINTCONNECTIVITY);
} catch (ResourceNotAvailableException | InterruptedException | ExecutionException e) {
fail(e.getMessage());
}
nodes = readOpenFLowTopology(dataBroker);
checkTable(nodes,deactivated);
- System.out.println("After deactivation: "+ nodes.toString());
}
BiConsumer<Table,List<String>> activated = (table,interswitchPorts) -> {