use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes in project bgpcep by opendaylight.
the class ProtocolUtil method ospfNodeAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1 ospfNodeAttributes(final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder();
final OspfNodeAttributesBuilder ab = new OspfNodeAttributesBuilder();
if (na != null) {
if (na.getIpv4RouterId() != null) {
tb.setTeRouterIdIpv4(na.getIpv4RouterId());
}
if (na.getIpv6RouterId() != null) {
tb.setTeRouterIdIpv6(na.getIpv6RouterId());
}
if (na.getTopologyIdentifier() != null) {
ab.setMultiTopologyId(nodeMultiTopology(na.getTopologyIdentifier()));
}
final CRouterIdentifier ri = node.getCRouterIdentifier();
if (ri instanceof OspfPseudonodeCase) {
final OspfPseudonode pn = ((OspfPseudonodeCase) ri).getOspfPseudonode();
ab.setRouterType(new PseudonodeBuilder().setPseudonode(Boolean.TRUE).build());
ab.setDrInterfaceId(pn.getLanInterface().getValue());
} else if (ri instanceof OspfNodeCase && na.getNodeFlags() != null) {
// TODO: what should we do with in.getOspfRouterId()?
final NodeFlagBits nf = na.getNodeFlags();
if (nf.isAbr() != null) {
ab.setRouterType(new AbrBuilder().setAbr(nf.isAbr()).build());
} else if (nf.isExternal() != null) {
ab.setRouterType(new InternalBuilder().setInternal(!nf.isExternal()).build());
}
}
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1Builder().setOspfNodeAttributes(ab.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes in project bgpcep by opendaylight.
the class ProtocolUtil method isisNodeAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 isisNodeAttributes(final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder();
final IsisNodeAttributesBuilder ab = new IsisNodeAttributesBuilder();
if (na != null) {
if (na.getIpv4RouterId() != null) {
tb.setTeRouterIdIpv4(na.getIpv4RouterId());
}
if (na.getIpv6RouterId() != null) {
tb.setTeRouterIdIpv6(na.getIpv6RouterId());
}
if (na.getTopologyIdentifier() != null) {
ab.setMultiTopologyId(nodeMultiTopology(na.getTopologyIdentifier()));
}
}
final CRouterIdentifier ri = node.getCRouterIdentifier();
if (ri instanceof IsisPseudonodeCase) {
final IsisPseudonode pn = ((IsisPseudonodeCase) ri).getIsisPseudonode();
final IsoBuilder b = new IsoBuilder();
final String systemId = UriBuilder.isoId(pn.getIsIsRouterIdentifier().getIsoSystemId());
b.setIsoSystemId(new IsoSystemId(systemId));
b.setIsoPseudonodeId(new IsoPseudonodeId(BaseEncoding.base16().encode(new byte[] { pn.getPsn().byteValue() })));
ab.setIso(b.build());
if (na != null) {
ab.setNet(toIsoNetIds(na.getIsisAreaId(), systemId));
}
} else if (ri instanceof IsisNodeCase) {
final IsisNode in = ((IsisNodeCase) ri).getIsisNode();
final String systemId = UriBuilder.isoId(in.getIsoSystemId());
ab.setIso(new IsoBuilder().setIsoSystemId(new IsoSystemId(systemId)).build());
if (na != null) {
ab.setNet(toIsoNetIds(na.getIsisAreaId(), systemId));
}
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1Builder().setIsisNodeAttributes(ab.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveNodes.
@Test
public void testPositiveNodes() throws BGPParsingException {
final AttributesBuilder builder = createBuilder(new NodeCaseBuilder().build());
this.parser.parseAttribute(Unpooled.copiedBuffer(NODE_ATTR), builder);
final Attributes1 attrs = builder.getAugmentation(Attributes1.class);
final NodeAttributes ls = ((NodeAttributesCase) attrs.getLinkStateAttribute()).getNodeAttributes();
assertNotNull(ls);
assertEquals(2, ls.getTopologyIdentifier().size());
assertEquals(42, ls.getTopologyIdentifier().get(0).getValue().intValue());
assertTrue(ls.getNodeFlags().isOverload());
assertFalse(ls.getNodeFlags().isAttached());
assertTrue(ls.getNodeFlags().isExternal());
assertTrue(ls.getNodeFlags().isAbr());
assertTrue(ls.getNodeFlags().isRouter());
assertTrue(ls.getNodeFlags().isV6());
assertEquals("12K-2", ls.getDynamicHostname());
assertEquals(2, ls.getIsisAreaId().size());
assertEquals("41.41.41.41", ls.getIpv4RouterId().getValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
assertArrayEquals(NODE_ATTR_S, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes in project bgpcep by opendaylight.
the class NodeAttributesParser method serializeNodeAttributes.
static void serializeNodeAttributes(final NodeAttributesCase nodeAttributesCase, final ByteBuf byteAggregator) {
LOG.trace("Started serializing Node Attributes");
final NodeAttributes nodeAttributes = nodeAttributesCase.getNodeAttributes();
serializeTopologyId(nodeAttributes.getTopologyIdentifier(), byteAggregator);
serializeNodeFlagBits(nodeAttributes.getNodeFlags(), byteAggregator);
if (nodeAttributes.getDynamicHostname() != null) {
TlvUtil.writeTLV(DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode(nodeAttributes.getDynamicHostname())), byteAggregator);
}
final List<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
if (isisList != null) {
for (final IsisAreaIdentifier isisAreaIdentifier : isisList) {
TlvUtil.writeTLV(ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()), byteAggregator);
}
}
if (nodeAttributes.getIpv4RouterId() != null) {
TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress(nodeAttributes.getIpv4RouterId()), byteAggregator);
}
if (nodeAttributes.getIpv6RouterId() != null) {
TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress(nodeAttributes.getIpv6RouterId()), byteAggregator);
}
if (nodeAttributes.getSrCapabilities() != null) {
final ByteBuf capBuffer = Unpooled.buffer();
SrNodeAttributesParser.serializeSrCapabilities(nodeAttributes.getSrCapabilities(), capBuffer);
TlvUtil.writeTLV(SR_CAPABILITIES, capBuffer, byteAggregator);
}
if (nodeAttributes.getSrAlgorithm() != null) {
final ByteBuf capBuffer = Unpooled.buffer();
SrNodeAttributesParser.serializeSrAlgorithms(nodeAttributes.getSrAlgorithm(), capBuffer);
TlvUtil.writeTLV(SR_ALGORITHMS, capBuffer, byteAggregator);
}
LOG.trace("Finished serializing Node Attributes");
}
Aggregations