Search in sources :

Example 1 with Ipv4AddressNoZone

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone in project lispflowmapping by opendaylight.

the class VppNodeReader method readIpAddressFromInterface.

private Optional<Ipv4Address> readIpAddressFromInterface(Interface intf, KeyedInstanceIdentifier iiToVpp) {
    Interface2 augIntf = intf.getAugmentation(Interface2.class);
    if (augIntf == null) {
        LOG.debug("Cannot get Interface2 augmentation for intf {}");
        return Optional.absent();
    }
    Ipv4 ipv4 = augIntf.getIpv4();
    if (ipv4 == null) {
        LOG.debug("Ipv4 address for interface {} on node {} is null!", augIntf, InfoUtil.node(iiToVpp));
        return Optional.absent();
    }
    final List<Address> addresses = ipv4.getAddress();
    if (addresses == null || addresses.isEmpty()) {
        LOG.debug("Ipv4 addresses list is empty for interface {} on node {}", augIntf, InfoUtil.node(iiToVpp));
        return Optional.absent();
    }
    final Ipv4AddressNoZone ip = addresses.iterator().next().getIp();
    if (ip == null) {
        LOG.debug("Ipv4AddressNoZone is null for node {}", InfoUtil.node(iiToVpp));
        return Optional.absent();
    }
    LOG.debug("Got ip address {} from interface {} on node {}", ip.getValue(), intf.getName(), InfoUtil.node(iiToVpp));
    return Optional.of(ip);
}
Also used : Interface2(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4)

Aggregations

Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 Interface2 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2)1 Ipv4 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4)1 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Address)1