use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project netvirt by opendaylight.
the class GeniusProvider method getIpFromDpnId.
// TODO Should better use the Genius InterfaceManager to avoid duplicate code
// https://bugs.opendaylight.org/show_bug.cgi?id=8127
public Optional<String> getIpFromDpnId(DpnIdType dpnid) {
GetEndpointIpForDpnInputBuilder builder = new GetEndpointIpForDpnInputBuilder();
builder.setDpid(dpnid.getValue());
GetEndpointIpForDpnInput input = builder.build();
if (interfaceManagerRpcService == null) {
LOG.error("getIpFromDpnId({}) failed (service couldn't be retrieved)", input);
return Optional.empty();
}
try {
LOG.debug("getIpFromDpnId: invoking rpc");
RpcResult<GetEndpointIpForDpnOutput> output = interfaceManagerRpcService.getEndpointIpForDpn(input).get();
if (!output.isSuccessful()) {
LOG.error("getIpFromDpnId({}) failed: {}", input, output);
return Optional.empty();
}
LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
List<IpAddress> localIps = output.getResult().getLocalIps();
// TODO need to figure out why it returns a list, using first entry for now
return Optional.ofNullable(localIps).filter(ipAddresses -> !ipAddresses.isEmpty()).map(ipAddresses -> ipAddresses.get(0)).map(IpAddress::getIpv4Address).map(Ipv4Address::getValue);
} catch (InterruptedException | ExecutionException e) {
LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
}
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.
the class MACIpAdvRParser method parseEvpn.
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
buffer.skipBytes(1);
final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
final IpAddress ip = parseIp(buffer);
final MplsLabel label1 = mplsLabelForByteBuf(buffer);
MplsLabel label2;
if (buffer.readableBytes() > 0) {
label2 = mplsLabelForByteBuf(buffer);
} else {
label2 = null;
}
final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMacAddress(mac).setIpAddress(ip).setMplsLabel1(label1).setMplsLabel2(label2);
return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.
the class PCEPPceIdIPv6ObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final PceIdBuilder builder = new PceIdBuilder();
builder.setIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer)));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.
the class PCEPPccIdReqIPv4ObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final PccIdReqBuilder builder = new PccIdReqBuilder();
builder.setIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.
the class FSExtendedCommunitiesTest method testRedirectIpv6NhParser.
@Test
public void testRedirectIpv6NhParser() throws BGPDocumentedException, BGPParsingException {
final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv6Address("2001::1"))).setCopy(false).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV6));
Assert.assertEquals(expected, parsed);
}
Aggregations