use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes in project bgpcep by opendaylight.
the class ImportAttributeTestUtil method createInput.
public static Attributes createInput() {
final AttributesBuilder attBuilder = new AttributesBuilder();
// local pref
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
// cluster pref
attBuilder.setClusterId(new ClusterIdBuilder().setCluster(Collections.singletonList(new ClusterIdentifier("40.40.40.40"))).build());
// c-next-hop pref
attBuilder.setCNextHop(createNexHop());
// originator pref
attBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4Address("41.41.41.41")).build());
// origin pref
attBuilder.setOrigin(createOrigin());
// multi-exit-disc pref
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(0L).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes in project bgpcep by opendaylight.
the class BgpConditionsRegistry method matchExportCondition.
@SuppressWarnings("unchecked")
private boolean matchExportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters routeEntryExportParameters, final Attributes attributes, final BgpConditions conditions) {
if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
return false;
}
if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
return false;
}
if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
return false;
}
if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
return false;
}
if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
return false;
}
final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchCond)) {
return false;
}
}
final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
if (matchAsPathSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
return false;
}
}
final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
if (matchExtCommSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchExtCommunitySet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
return false;
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes in project bgpcep by opendaylight.
the class BgpConditionsRegistry method matchImportCondition.
@SuppressWarnings("unchecked")
private boolean matchImportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryImportParameters routeEntryImportParameters, final Attributes attributes, final BgpConditions conditions) {
if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
return false;
}
if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
return false;
}
if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
return false;
}
if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
return false;
}
if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
return false;
}
final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchCond)) {
return false;
}
}
final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
return false;
}
}
final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
if (matchExtCommSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
return false;
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createLink.
private void createLink(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
// defensive lookup
final LinkAttributes la;
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType != null) {
la = ((LinkAttributesCase) attrType).getLinkAttributes();
} else {
LOG.debug("Missing attribute type in link {} route {}, skipping it", linkCase, value);
la = null;
}
} else {
LOG.debug("Missing attributes in link {} route {}, skipping it", linkCase, value);
la = null;
}
final IgpLinkAttributesBuilder ilab = new IgpLinkAttributesBuilder();
if (la != null) {
if (la.getMetric() != null) {
ilab.setMetric(la.getMetric().getValue());
}
ilab.setName(la.getLinkName());
}
ProtocolUtil.augmentProtocolId(value, ilab, la, linkCase.getLinkDescriptors());
final LinkBuilder lb = new LinkBuilder();
lb.setLinkId(buildLinkId(base, linkCase));
lb.addAugmentation(Link1.class, new Link1Builder().setIgpLinkAttributes(ilab.build()).build());
final NodeId srcNode = buildNodeId(base, linkCase.getLocalNodeDescriptors());
LOG.trace("Link {} implies source node {}", linkCase, srcNode);
final NodeId dstNode = buildNodeId(base, linkCase.getRemoteNodeDescriptors());
LOG.trace("Link {} implies destination node {}", linkCase, dstNode);
final TerminationPoint srcTp = buildLocalTp(base, linkCase.getLinkDescriptors());
LOG.trace("Link {} implies source TP {}", linkCase, srcTp);
final TerminationPoint dstTp = buildRemoteTp(base, linkCase.getLinkDescriptors());
LOG.trace("Link {} implies destination TP {}", linkCase, dstTp);
lb.setSource(new SourceBuilder().setSourceNode(srcNode).setSourceTp(srcTp.getTpId()).build());
lb.setDestination(new DestinationBuilder().setDestNode(dstNode).setDestTp(dstTp.getTpId()).build());
LOG.trace("Created TP {} as link source", srcTp);
NodeHolder snh = this.nodes.get(srcNode);
if (snh == null) {
snh = getNode(srcNode);
snh.addTp(srcTp, lb.getLinkId(), false);
putNode(trans, snh);
} else {
snh.addTp(srcTp, lb.getLinkId(), false);
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(snh.getNodeId()));
trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, srcTp.getKey()), srcTp);
}
LOG.debug("Created TP {} as link destination", dstTp);
NodeHolder dnh = this.nodes.get(dstNode);
if (dnh == null) {
dnh = getNode(dstNode);
dnh.addTp(dstTp, lb.getLinkId(), true);
putNode(trans, dnh);
} else {
dnh.addTp(dstTp, lb.getLinkId(), true);
final InstanceIdentifier<Node> nid = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class, new NodeKey(dnh.getNodeId()));
trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, dstTp.getKey()), dstTp);
}
final InstanceIdentifier<Link> lid = buildLinkIdentifier(lb.getLinkId());
final Link link = lb.build();
trans.put(LogicalDatastoreType.OPERATIONAL, lid, link);
LOG.debug("Created link {} at {} for {}", link, lid, linkCase);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createNode.
private void createNode(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final NodeCase nodeCase, final Attributes attributes) {
final NodeAttributes na;
// defensive lookup
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType != null) {
na = ((NodeAttributesCase) attrType).getNodeAttributes();
} else {
LOG.debug("Missing attribute type in node {} route {}, skipping it", nodeCase, value);
na = null;
}
} else {
LOG.debug("Missing attributes in node {} route {}, skipping it", nodeCase, value);
na = null;
}
final IgpNodeAttributesBuilder inab = new IgpNodeAttributesBuilder();
final List<IpAddress> ids = new ArrayList<>();
if (na != null) {
if (na.getIpv4RouterId() != null) {
ids.add(new IpAddress(na.getIpv4RouterId()));
}
if (na.getIpv6RouterId() != null) {
ids.add(new IpAddress(na.getIpv6RouterId()));
}
if (na.getDynamicHostname() != null) {
inab.setName(new DomainName(na.getDynamicHostname()));
}
}
if (!ids.isEmpty()) {
inab.setRouterId(ids);
}
ProtocolUtil.augmentProtocolId(value, inab, na, nodeCase.getNodeDescriptors());
final NodeId nid = buildNodeId(base, nodeCase.getNodeDescriptors());
final NodeHolder nh = getNode(nid);
/*
* Eventhough the the holder creates a dummy structure, we need to duplicate it here,
* as that is the API requirement. The reason for it is the possible presence of supporting
* node -- something which the holder does not track.
*/
final NodeBuilder nb = new NodeBuilder();
nb.setNodeId(nid);
nb.setKey(new NodeKey(nb.getNodeId()));
nh.advertized(nb, inab);
putNode(trans, nh);
}
Aggregations