use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createPrefix.
private void createPrefix(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final PrefixCase prefixCase, final Attributes attributes) {
final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {} route {}, skipping it", prefixCase, value);
return;
}
final PrefixBuilder pb = new PrefixBuilder();
final PrefixKey pk = new PrefixKey(ippfx);
pb.setKey(pk);
pb.setPrefix(ippfx);
final PrefixAttributes pa;
// Very defensive lookup
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType != null) {
pa = ((PrefixAttributesCase) attrType).getPrefixAttributes();
} else {
LOG.debug("Missing attribute type in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
pa = null;
}
} else {
LOG.debug("Missing attributes in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
pa = null;
}
if (pa != null) {
pb.setMetric(pa.getPrefixMetric().getValue());
}
ProtocolUtil.augmentProtocolId(value, pa, pb);
final Prefix pfx = pb.build();
LOG.debug("Created prefix {} for {}", pfx, prefixCase);
/*
* All set, but... the hosting node may not exist, we may need to fake it.
*/
final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
NodeHolder nh = this.nodes.get(node);
if (nh == null) {
nh = getNode(node);
nh.addPrefix(pfx);
putNode(trans, nh);
} else {
nh.addPrefix(pfx);
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
final InstanceIdentifier<IgpNodeAttributes> inaId = nid.builder().augmentation(Node1.class).child(IgpNodeAttributes.class).build();
trans.put(LogicalDatastoreType.OPERATIONAL, inaId.child(Prefix.class, pk), pfx);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class TableContext method serializeAttributes.
private ContainerNode serializeAttributes(final Attributes pathAttr) {
Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.addAugmentation(Attributes1.class, null);
a.addAugmentation(Attributes2.class, null);
return (ContainerNode) this.attributesCodec.serialize(a.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class PrefixesBuilder method createAttributes.
private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport, final Ipv4Prefix addressPrefix) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
attBuilder.setExtendedCommunities(createExtComm(extCom));
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
final Ipv4PrefixesBuilder prefixes = new Ipv4PrefixesBuilder().setPrefix(addressPrefix);
if (multiPathSupport) {
prefixes.setPathId(new PathId(5L));
}
attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(prefixes.build())).build()).build()).build()).build()).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project genius by opendaylight.
the class OvsInterfaceStateUpdateHelper method updateState.
public List<ListenableFuture<Void>> updateState(String interfaceName, FlowCapableNodeConnector flowCapableNodeConnectorNew, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
LOG.debug("Updating interface state information for interface: {}", interfaceName);
Interface.OperStatus operStatusNew = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorNew);
MacAddress macAddressNew = flowCapableNodeConnectorNew.getHardwareAddress();
Interface.OperStatus operStatusOld = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorOld);
MacAddress macAddressOld = flowCapableNodeConnectorOld.getHardwareAddress();
boolean opstateModified = !operStatusNew.equals(operStatusOld);
boolean hardwareAddressModified = !macAddressNew.equals(macAddressOld);
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
// For monitoring enabled tunnels, skip opstate update
if (isTunnelInterface(iface) && !modifyTunnelOpState(iface, opstateModified)) {
LOG.debug("skip interface-state updation for monitoring enabled tunnel interface {}", interfaceName);
opstateModified = false;
}
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
if (hardwareAddressModified) {
LOG.debug("Hw-Address Modified for Port: {}", interfaceName);
PhysAddress physAddress = new PhysAddress(macAddressNew.getValue());
ifaceBuilder.setPhysAddress(physAddress);
}
if (opstateModified) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, true, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
// start/stop monitoring based on opState
if (isTunnelInterface(iface)) {
handleTunnelMonitoringUpdates(iface.getAugmentation(IfTunnel.class), iface.getName(), operStatusNew);
}
}));
} else {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, false, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
}));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project genius by opendaylight.
the class HwVTEPInterfaceConfigUpdateHelper method updateBfdMonitoring.
/*
* BFD monitoring interval and enable/disable attributes can be modified
*/
public static List<ListenableFuture<Void>> updateBfdMonitoring(ManagedNewTransactionRunner txRunner, InstanceIdentifier<Node> globalNodeId, InstanceIdentifier<Node> physicalSwitchId, IfTunnel ifTunnel) {
TunnelsBuilder tunnelsBuilder = new TunnelsBuilder();
InstanceIdentifier<TerminationPoint> localTEPInstanceIdentifier = SouthboundUtils.createTEPInstanceIdentifier(globalNodeId, ifTunnel.getTunnelSource());
InstanceIdentifier<TerminationPoint> remoteTEPInstanceIdentifier = SouthboundUtils.createTEPInstanceIdentifier(globalNodeId, ifTunnel.getTunnelDestination());
InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = SouthboundUtils.createTunnelsInstanceIdentifier(physicalSwitchId, localTEPInstanceIdentifier, remoteTEPInstanceIdentifier);
LOG.debug("updating bfd monitoring parameters for the hwvtep {}", tunnelsInstanceIdentifier);
tunnelsBuilder.setKey(new TunnelsKey(new HwvtepPhysicalLocatorRef(localTEPInstanceIdentifier), new HwvtepPhysicalLocatorRef(remoteTEPInstanceIdentifier)));
List<BfdParams> bfdParams = new ArrayList<>();
SouthboundUtils.fillBfdParameters(bfdParams, ifTunnel);
tunnelsBuilder.setBfdParams(bfdParams);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.merge(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier, tunnelsBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS)));
}
Aggregations