/** * Construct a new instance. * * @param link A {@link Link} instance. * @throws NullPointerException * {@code link} is {@code null}. * @throws IllegalArgumentException * An invalid instance is specified to {@code link}. */ public LinkEdge(Link link) { sourcePort = SalPort.create(link.getSource()); if (sourcePort == null) { throw new IllegalArgumentException( "Source port is not configured: " + link); } destinationPort = SalPort.create(link.getDestination()); if (destinationPort == null) { throw new IllegalArgumentException( "Destination port is not configured: " + link); } }
public LinkBuilder(Link base) { if (base.getKey() == null) { this._key = new LinkKey( base.getLinkId() ); this._linkId = base.getLinkId(); } else { this._key = base.getKey(); this._linkId = _key.getLinkId(); } this._destination = base.getDestination(); this._source = base.getSource(); this._supportingLink = base.getSupportingLink(); if (base instanceof LinkImpl) { LinkImpl impl = (LinkImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
public LinkBuilder(Link base) { this.key = base.key(); this._linkId = base.getLinkId(); this._destination = base.getDestination(); this._source = base.getSource(); this._supportingLink = base.getSupportingLink(); if (base instanceof LinkImpl) { LinkImpl impl = (LinkImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") Map<Class<? extends Augmentation<Link>>, Augmentation<Link>> aug =((AugmentationHolder<Link>) base).augmentations(); if (!aug.isEmpty()) { this.augmentation = new HashMap<>(aug); } } }
if (!Objects.equals(_destination, other.getDestination())) { return false; if (!Objects.equals(_linkId, other.getLinkId())) { return false; if (!Objects.equals(_source, other.getSource())) { return false; if (!Objects.equals(_supportingLink, other.getSupportingLink())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
/** * Initialize VTN network topology. * * @param luctx A {@link LinkUpdateContext} instance. * @param topology MD-SAL network topology. * @throws VTNException * An error occurred. */ private void initLinks(LinkUpdateContext luctx, Topology topology) throws VTNException { if (topology == null) { return; } List<Link> links = topology.getLink(); if (links == null) { return; } for (Link link: links) { SalPort src = SalPort.create(link.getSource()); SalPort dst = SalPort.create(link.getDestination()); if (src == null || dst == null) { LOG.debug("Ignore unsupported inter-switch link: {}", link); } else { luctx.addVtnLink(link.getLinkId(), src, dst); } } }
if (link != null) { SalPort peer = SalPort.create(link.getDestination()); if (peer != null) { LogicalDatastoreType oper = LogicalDatastoreType.OPERATIONAL; if (vpeer != null && InventoryUtils.isEnabled(vpeer)) { restoreVtnLink(link.getLinkId(), sport, peer); sport.equals(SalPort.create(rlink.getDestination()))) { restoreVtnLink(rlink.getLinkId(), peer, sport);
public String dstNodeId() { return this.link.getDestination().getDestNode().getValue(); }
/** * Puts the given value (Link) only in this local HashMap. Ideally used for * Link data listener events. * * @param ii the value's (Link's) InstanceIdentifier<Link> * @param value the Link to store locally. * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> */ public synchronized V putLocally(InstanceIdentifier<Link> ii, V value) { Link l = ((Link) value); LOG.trace("Putting locally {}", l.getLinkId()); this.instanceIDs.put(ii, (K) l.getLinkId()); return this.linkHashMap.put((K) l.getLinkId(), value); }
public String srcTpId() { return this.link.getSource().getSourceTp().getValue(); }
/** * Puts the given link in the this local HashMap and into MD-SAL database. * * @param linkId * the key for the map * @param link * the value for the map * @return the old value from the local cache if present, null otherwise. */ @Override public synchronized V put(K linkId, V link) { final Link linkNode = ((Link) link); final InstanceIdentifier<Link> buildLinkIID = Utilities.buildLinkIID( linkNode.getKey(), topologyId); this.opProcessor.enqueueOperation(new HostTrackerOperation() { @Override public void applyOperation(ReadWriteTransaction tx) { tx.merge(LogicalDatastoreType.OPERATIONAL, buildLinkIID, linkNode, true); } }); LOG.trace("Putting MD-SAL {}", linkNode.getLinkId()); return putLocally(buildLinkIID, link); }
static InstanceIdentifier<Link> linkPath(final Link link, final InstanceIdentifier<Topology> topology) { return topology.child(Link.class, link.getKey()); }
/** * Retrieve the list of links in the Operational DataStore. * @param dataBroker The dataBroker instance to create transactions * @return A list of Links retrieved from the Operational DataStore */ public static List<Link> getEvcLinks(final DataBroker dataBroker) { final List<Link> evcLinks = new ArrayList<>(); final InstanceIdentifier<Topology> evcTopology = UnimgrMapper.getEvcTopologyIid(); final Topology topology = MdsalUtils.read(dataBroker, LogicalDatastoreType.OPERATIONAL, evcTopology); if ((topology != null) && (topology.getLink() != null)) { for (final Link link : topology.getLink()) { final EvcAugmentation evcAugmentation = link.getAugmentation(EvcAugmentation.class); if (evcAugmentation != null) { evcLinks.add(link); } } } return evcLinks; }
link = findGWLink(trans, fabricId, tpOnRouter, routerId); if (link != null) trans.delete(LogicalDatastoreType.OPERATIONAL, MdSalUtils.createLinkIId(fabricId, link.getLinkId())); lswId = link.getDestination().getDestNode(); tpOnSwitch = link.getDestination().getDestTp(); trans.delete(LogicalDatastoreType.OPERATIONAL, MdSalUtils.createLogicPortIId(fabricId, lswId, tpOnSwitch));
public String dstTpId() { return this.link.getDestination().getDestTp().getValue(); }
public String id() { return this.link.getLinkId().getValue(); }
public String srcNodeId() { return this.link.getSource().getSourceNode().getValue(); }
/** * Removes the value (Host) with the given linkId from this local HashMap * and MD-SAL database. * * @param linkId * the link's linkId to remove * @return the old value from the local cache if present, null otherwise. */ @Override public synchronized V remove(Object linkId) { V removedValue = this.linkHashMap.remove(linkId); if (removedValue != null) { Link linkNode = (Link) removedValue; final InstanceIdentifier<Link> lnIID = Utilities.buildLinkIID( linkNode.getKey(), topologyId); this.opProcessor.enqueueOperation(new HostTrackerOperation() { @Override public void applyOperation(ReadWriteTransaction tx) { tx.delete(LogicalDatastoreType.OPERATIONAL, lnIID); } }); this.instanceIDs.remove(lnIID); } return removedValue; } /**
@Override protected ListenableFuture<OperationResult> invokeOperation() { final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.pcepDestroyTunnelInput); final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.pcepDestroyTunnelInput); try (final ReadOnlyTransaction t = this.dataProvider.newReadOnlyTransaction()) { final Node node; final Link link; try { // The link has to exist link = t.read(LogicalDatastoreType.OPERATIONAL, lii).checkedGet().get(); // The source node has to exist node = TunelProgrammingUtil.sourceNode(t, tii, link).get(); } catch (IllegalStateException | ReadFailedException e) { LOG.debug("Link or node does not exist.", e); return TunelProgrammingUtil.RESULT; } final RemoveLspInputBuilder ab = new RemoveLspInputBuilder(); ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName()); ab.setNode(node.getSupportingNode().get(0).getKey().getNodeRef()); return Futures.transform( (ListenableFuture<RpcResult<RemoveLspOutput>>) this.topologyService.removeLsp(ab.build()), new Function<RpcResult<RemoveLspOutput>, OperationResult>() { @Override public OperationResult apply(final RpcResult<RemoveLspOutput> input) { return input.getResult(); } }); } } }