Search in sources :

Example 11 with IpPrefix

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

the class CoeUtils method createPortIpAdjacencies.

static Adjacencies createPortIpAdjacencies(Pods pod, String interfaceName, String macAddress, Boolean isRouterInterface) {
    List<Adjacency> adjList = new ArrayList<>();
    LOG.trace("create config adjacencies for Port: {}", interfaceName);
    IpAddress ip = pod.getInterface().get(0).getIpAddress();
    String ipValue = ip.getIpv4Address() != null ? ip.getIpv4Address().getValue() : ip.getIpv6Address().getValue();
    String ipPrefix = ip.getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
    String hostIp = new String(pod.getHostIpAddress().getValue());
    UUID subnetId = UUID.nameUUIDFromBytes(hostIp.getBytes(StandardCharsets.UTF_8));
    String gatewayIP = ipValue.replaceFirst("\\d+$", "1");
    Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(macAddress).setAdjacencyType(Adjacency.AdjacencyType.PrimaryAdjacency).setSubnetId(new Uuid(subnetId.toString())).setSubnetGatewayIp(gatewayIP).build();
    if (!adjList.contains(vmAdj)) {
        adjList.add(vmAdj);
    }
    // }
    return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey) ArrayList(java.util.ArrayList) AdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) UUID(java.util.UUID)

Example 12 with IpPrefix

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

the class NeutronvpnManager method createPortIpAdjacencies.

protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, WriteTransaction wrtConfigTxn, Subnetmap sn, VpnInterface vpnIface) {
    List<Adjacency> adjList = new ArrayList<>();
    if (vpnIface != null) {
        adjList = vpnIface.getAugmentation(Adjacencies.class).getAdjacency();
    }
    String infName = port.getUuid().getValue();
    LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
    for (FixedIps ip : port.getFixedIps()) {
        String ipValue = String.valueOf(ip.getIpAddress().getValue());
        String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
        if (sn != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, sn.getSubnetIp(), false)) {
            continue;
        }
        Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
        if (!adjList.contains(vmAdj)) {
            adjList.add(vmAdj);
        }
        Subnetmap snTemp = sn != null ? sn : neutronvpnUtils.getSubnetmap(ip.getSubnetId());
        Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
        Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
        if (vpnId != null) {
            neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
        }
        if (snTemp != null && snTemp.getInternetVpnId() != null) {
            neutronvpnUtils.createVpnPortFixedIpToPort(sn.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
        }
        if (routerId != null) {
            Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
            if (rtr != null && rtr.getRoutes() != null) {
                List<Routes> routeList = rtr.getRoutes();
                // create extraroute Adjacence for each ipValue,
                // because router can have IPv4 and IPv6 subnet ports, or can have
                // more that one IPv4 subnet port or more than one IPv6 subnet port
                List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
                if (!erAdjList.isEmpty()) {
                    adjList.addAll(erAdjList);
                }
            }
        }
    }
    return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Example 13 with IpPrefix

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

the class AbstractPrefixNlriParser method parsePrefixDescriptor.

private static PrefixDescriptors parsePrefixDescriptor(final ByteBuf buffer) {
    final Map<QName, Object> tlvs = SimpleNlriTypeRegistry.getInstance().parseSubTlvs(buffer);
    final PrefixDescriptorsBuilder builder = new PrefixDescriptorsBuilder();
    builder.setMultiTopologyId((TopologyIdentifier) tlvs.get(MultiTopoIdTlvParser.MULTI_TOPOLOGY_ID_QNAME));
    builder.setOspfRouteType((OspfRouteType) tlvs.get(OspfRouteTlvParser.OSPF_ROUTE_TYPE_QNAME));
    builder.setIpReachabilityInformation((IpPrefix) tlvs.get(ReachTlvParser.IP_REACHABILITY_QNAME));
    return builder.build();
}
Also used : PrefixDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.prefix._case.PrefixDescriptorsBuilder) QName(org.opendaylight.yangtools.yang.common.QName)

Example 14 with IpPrefix

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

the class AbstractVpnRIBSupport method createRouteKey.

private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final VpnDestination dests = new VpnDestinationBuilder().setPrefix(extractPrefix(l3vpn, this.prefixTypeNid)).setRouteDistinguisher(extractRouteDistinguisher(l3vpn)).build();
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final VpnDestination dest : Collections.singletonList(dests)) {
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, null, nlriByteBuf);
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
        Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
        LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);
    return new NodeIdentifierWithPredicates(routeQName(), this.routeKey, ByteArray.encodeBase64(buffer));
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) VpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination) ByteBuf(io.netty.buffer.ByteBuf) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) VpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder)

Example 15 with IpPrefix

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

the class AbstractPCEPSessionTest method createEroWithIpPrefixes.

Ero createEroWithIpPrefixes(final List<String> ipPrefixes) {
    final List<Subobject> subobjs = new ArrayList<>(ipPrefixes.size());
    final SubobjectBuilder subobjBuilder = new SubobjectBuilder();
    for (final String ipPrefix : ipPrefixes) {
        subobjBuilder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix(ipPrefix))).build()).build());
        subobjs.add(subobjBuilder.build());
    }
    return new EroBuilder().setSubobject(subobjs).build();
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject) IpPrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder) ArrayList(java.util.ArrayList) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)

Aggregations

IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)96 Test (org.junit.Test)38 ByteBuf (io.netty.buffer.ByteBuf)33 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)28 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)27 ArrayList (java.util.ArrayList)23 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)23 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)23 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)17 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)13 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)12 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)12 BigInteger (java.math.BigInteger)11 InetAddress (java.net.InetAddress)11 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)8 BitArray (org.opendaylight.protocol.util.BitArray)8 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)8 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)8