use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1 in project bgpcep by opendaylight.
the class NodeChangedListener method getIpTerminationPoint.
private InstanceIdentifier<TerminationPoint> getIpTerminationPoint(final ReadWriteTransaction trans, final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl) throws ReadFailedException {
final Topology topo = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).checkedGet().get();
if (topo.getNode() != null) {
for (final Node n : topo.getNode()) {
if (n.getTerminationPoint() != null) {
for (final TerminationPoint tp : n.getTerminationPoint()) {
final TerminationPoint1 tpa = tp.getAugmentation(TerminationPoint1.class);
if (tpa != null) {
final TerminationPointType tpt = tpa.getIgpTerminationPointAttributes().getTerminationPointType();
if (tpt instanceof Ip) {
for (final IpAddress address : ((Ip) tpt).getIpAddress()) {
if (addr.equals(address)) {
handleSni(sni, n, inControl, trans);
return this.target.builder().child(Node.class, n.getKey()).child(TerminationPoint.class, tp.getKey()).build();
}
}
} else {
LOG.debug("Ignoring termination point type {}", tpt);
}
}
}
}
}
}
LOG.debug("Termination point for {} not found, creating a new one", addr);
return createTP(addr, sni, inControl, trans);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1 in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method buildTp.
private static TerminationPoint buildTp(final TpId id, final TerminationPointType type) {
final TerminationPointBuilder stpb = new TerminationPointBuilder();
stpb.setKey(new TerminationPointKey(id));
stpb.setTpId(id);
if (type != null) {
stpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(type).build()).build());
}
return stpb.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1 in project bgpcep by opendaylight.
the class TunnelProgrammingTest method createNode.
private static Node createNode(final NodeId nodeId, final TpId tpId, final String ipv4Address) {
final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setTpId(tpId);
tpBuilder.setKey(new TerminationPointKey(tpId));
tpBuilder.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(new IpBuilder().setIpAddress(Collections.singletonList(new IpAddress(new Ipv4Address(ipv4Address)))).build()).build()).build());
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(nodeId);
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setTerminationPoint(Lists.newArrayList(tpBuilder.build()));
final SupportingNode supportingNode = new SupportingNodeBuilder().setKey(new SupportingNodeKey(nodeId, new TopologyId("dummy"))).addAugmentation(SupportingNode1.class, new SupportingNode1Builder().setPathComputationClient(new PathComputationClientBuilder().setControlling(true).build()).build()).build();
nodeBuilder.setSupportingNode(Lists.newArrayList(supportingNode));
return nodeBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1 in project bgpcep by opendaylight.
the class CreateTunnelInstructionExecutor method buildAddressFamily.
private static AddressFamily buildAddressFamily(final TerminationPoint sp, final TerminationPoint dp) {
// We need the IGP augmentation -- it has IP addresses
final TerminationPoint1 sp1 = requireNonNull(sp.getAugmentation(TerminationPoint1.class));
final TerminationPoint1 dp1 = requireNonNull(dp.getAugmentation(TerminationPoint1.class));
// Get the types
final TerminationPointType spt = sp1.getIgpTerminationPointAttributes().getTerminationPointType();
final TerminationPointType dpt = dp1.getIgpTerminationPointAttributes().getTerminationPointType();
// The types have to match
Preconditions.checkArgument(spt.getImplementedInterface().equals(dpt.getImplementedInterface()));
// And they have to actually be Ip
final Ip sips = (Ip) spt;
final Ip dips = (Ip) dpt;
/*
* Now a bit of magic. We need to find 'like' addresses, e.g. both
* IPv4 or both IPv6. We are in IPv6-enabled world now, so let's
* prefer that.
*/
Optional<AddressFamily> ret = findIpv6(sips.getIpAddress(), dips.getIpAddress());
if (!ret.isPresent()) {
ret = findIpv4(sips.getIpAddress(), dips.getIpAddress());
}
// We need to have a ret now
Preconditions.checkArgument(ret != null, "Failed to find like Endpoint addresses");
return ret.get();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1 in project bgpcep by opendaylight.
the class NodeChangedListener method createTP.
private InstanceIdentifier<TerminationPoint> createTP(final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl, final ReadWriteTransaction trans) {
final String url = "ip://" + addr.toString();
final TerminationPointKey tpk = new TerminationPointKey(new TpId(url));
final TerminationPointBuilder tpb = new TerminationPointBuilder();
tpb.setKey(tpk).setTpId(tpk.getTpId());
tpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(new IpBuilder().setIpAddress(Lists.newArrayList(addr)).build()).build()).build());
final NodeKey nk = new NodeKey(new NodeId(url));
final NodeBuilder nb = new NodeBuilder();
nb.setKey(nk).setNodeId(nk.getNodeId());
nb.setTerminationPoint(Lists.newArrayList(tpb.build()));
if (sni != null) {
nb.setSupportingNode(Lists.newArrayList(createSupportingNode(InstanceIdentifier.keyOf(sni).getNodeId(), inControl)));
}
final InstanceIdentifier<Node> nid = this.target.child(Node.class, nb.getKey());
trans.put(LogicalDatastoreType.OPERATIONAL, nid, nb.build());
return nid.child(TerminationPoint.class, tpb.getKey());
}
Aggregations