Search in sources :

Example 16 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.

the class BgpConfigurationManager method addVrf.

// TODO: add LayerType as arg - supports command
public void addVrf(String rd, List<String> irts, List<String> erts, AddressFamily addressFamily) {
    Vrfs vrf = bgpUtil.getVrfFromRd(rd);
    List<AddressFamiliesVrf> adfList = new ArrayList<>(1);
    if (vrf != null) {
        adfList = new ArrayList<AddressFamiliesVrf>(vrf.nonnullAddressFamiliesVrf().values());
    }
    AddressFamiliesVrfBuilder adfBuilder = new AddressFamiliesVrfBuilder();
    if (addressFamily.equals(AddressFamily.IPV4)) {
        adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
        adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
    } else if (addressFamily.equals(AddressFamily.IPV6)) {
        adfBuilder.setAfi((long) af_afi.AFI_IPV6.getValue());
        adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
    } else if (addressFamily.equals(AddressFamily.L2VPN)) {
        adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
        adfBuilder.setSafi((long) af_safi.SAFI_EVPN.getValue());
    }
    AddressFamiliesVrf adf = adfBuilder.build();
    adfList.add(adf);
    InstanceIdentifier.InstanceIdentifierBuilder<Vrfs> iib = InstanceIdentifier.builder(Bgp.class).child(VrfsContainer.class).child(Vrfs.class, new VrfsKey(rd));
    InstanceIdentifier<Vrfs> iid = iib.build();
    Vrfs dto = new VrfsBuilder().setRd(rd).setImportRts(irts).setExportRts(erts).setAddressFamiliesVrf(adfList).build();
    List<AddressFamiliesVrf> listAdFamilies = mapNewAdFamily.get(rd);
    if (listAdFamilies != null) {
        listAdFamilies.add(adf);
    } else {
        mapNewAdFamily.put(rd, adfList);
    }
    try {
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, iid, dto);
    } catch (TransactionCommitFailedException e) {
        LOG.error("Error adding VRF to datastore", e);
        throw new RuntimeException(e);
    }
    // enable multipath by default in all VRFs
    setMultipaths(rd, BgpConstants.BGP_DEFAULT_MULTIPATH);
}
Also used : Vrfs(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.Vrfs) VrfsBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.VrfsBuilder) VrfsKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.VrfsKey) ArrayList(java.util.ArrayList) VrfsContainer(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.VrfsContainer) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) AddressFamiliesVrf(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.vrfs.AddressFamiliesVrf) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) AddressFamiliesVrfBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.vrfs.AddressFamiliesVrfBuilder)

Example 17 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.

the class ConfigureBgpCli method addNeighbor.

protected void addNeighbor() {
    if (!validateAsNumber(asNumber)) {
        printAddNeighborHelp();
        return;
    }
    boolean validIp = validateIp(ip);
    if (!validIp) {
        session.getConsole().println("invalid neighbor ip");
        printAddNeighborHelp();
        return;
    }
    TcpMd5SignaturePasswordType md5secret = null;
    if (md5passwordOption != null) {
        try {
            md5secret = new TcpMd5SignaturePasswordType(md5passwordOption);
        } catch (IllegalArgumentException e) {
            session.getConsole().println(new StringBuilder("invalid MD5 password: ").append(e.getMessage()).toString());
            printAddNeighborHelp();
            return;
        }
    }
    if (sourceIp != null) {
        validIp = validateIp(sourceIp);
        if (!validIp) {
            session.getConsole().println("invalid source ip");
            printAddNeighborHelp();
            return;
        }
    }
    if (ebgpMultihops != null) {
        try {
            long val = Long.parseLong(ebgpMultihops);
            if (val < 1 || val > 255) {
                session.getConsole().println("invalid ebgpMultihops number , valid range [1,255] " + ebgpMultihops);
                printAddNeighborHelp();
                return;
            }
        } catch (NumberFormatException e) {
            session.getConsole().println("invalid ebgpMultihops number, valid range [1-255]" + ebgpMultihops);
            printAddNeighborHelp();
            return;
        }
    }
    if (addressFamily != null) {
        if (!addressFamily.equals("lu") && !addressFamily.equals("vpnv4") && !addressFamily.equals("vpnv6") && !addressFamily.equals("evpn")) {
            session.getConsole().println("error: Address family must be lu/evpn/vpnv4/vpnv6 ");
            return;
        }
        int afi;
        int safi;
        if (addressFamily.equals("vpnv6")) {
            afi = 2;
            safi = 5;
        } else if (addressFamily.equals("evpn")) {
            afi = 3;
            safi = 6;
        } else if (addressFamily.equals("lu")) {
            afi = 1;
            safi = 4;
        } else if (addressFamily.equals("vpnv4")) {
            afi = 1;
            safi = 5;
        } else {
            session.getConsole().println("invalid addressFamily valid values lu/evpn/vpnv4/vpnv6");
            printAddNeighborHelp();
            return;
        }
    }
    if (getAsNumber(ip) != -1) {
        session.getConsole().println("neighbor with ip " + ip + " already exists");
        return;
    }
    bgpConfigurationManager.addNeighbor(ip, Long.parseLong(asNumber), md5secret);
    if (addressFamily != null) {
        bgpConfigurationManager.addAddressFamily(ip, af_afi.AFI_IP.getValue(), af_safi.valueOf(addressFamily).getValue());
    }
    if (ebgpMultihops != null) {
        bgpConfigurationManager.addEbgpMultihop(ip, Integer.parseInt(ebgpMultihops));
    }
    if (sourceIp != null) {
        bgpConfigurationManager.addUpdateSource(ip, sourceIp);
    }
}
Also used : TcpMd5SignaturePasswordType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.TcpMd5SignaturePasswordType)

Example 18 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.

the class FibDSWriter method removeVrfSubFamilyFromDS.

public synchronized void removeVrfSubFamilyFromDS(String rd, AddressFamily addressFamily) {
    if (rd == null) {
        return;
    }
    LOG.debug("removeVrfSubFamilyFromDS : addressFamily {} from vrf rd {}", addressFamily, rd);
    InstanceIdentifier<VrfTables> id = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
    try {
        VrfTables vrfTable = singleTxDB.syncRead(LogicalDatastoreType.CONFIGURATION, id);
        if (vrfTable != null) {
            Map<VrfEntryKey, VrfEntry> keyVrfEntryMap = vrfTable.getVrfEntry();
            if (keyVrfEntryMap == null) {
                LOG.error("removeVrfSubFamilyFromDS : VrfEntry not found for rd {}", rd);
                return;
            }
            for (VrfEntry vrfEntry : keyVrfEntryMap.values()) {
                boolean found = false;
                if (vrfEntry.getEncapType() != null) {
                    if (!vrfEntry.getEncapType().equals(EncapType.Mplsgre) && addressFamily == AddressFamily.L2VPN) {
                        found = true;
                    } else if (vrfEntry.getEncapType().equals(EncapType.Mplsgre)) {
                        if (addressFamily == AddressFamily.IPV4 && FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix())) {
                            found = true;
                        } else if (addressFamily == AddressFamily.IPV6 && FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix())) {
                            found = true;
                        }
                    }
                }
                if (found == false) {
                    continue;
                }
                bgpUtil.removeVrfEntry(rd, vrfEntry);
            }
        }
    } catch (ReadFailedException rfe) {
        LOG.error("removeVrfSubFamilyFromDS : Internal Error rd {}", rd, rfe);
    }
    return;
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Example 19 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.

the class SimpleBGPTableTypeRegistryProvider method registerBGPTableType.

@Override
public synchronized AbstractRegistration registerBGPTableType(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final Class<? extends AfiSafiType> afiSafiType) {
    final BgpTableType tableType = new BgpTableTypeImpl(afi, safi);
    final Class<? extends AfiSafiType> prev = this.tableTypes.putIfAbsent(tableType, afiSafiType);
    Preconditions.checkState(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
    final TablesKey tableKey = new TablesKey(tableType.getAfi(), tableType.getSafi());
    this.tableKeys.put(tableKey, afiSafiType);
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (SimpleBGPTableTypeRegistryProvider.this) {
                SimpleBGPTableTypeRegistryProvider.this.tableTypes.remove(tableType);
                SimpleBGPTableTypeRegistryProvider.this.tableKeys.remove(tableKey);
            }
        }
    };
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 20 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.

the class MldpP2mpLspParser method serialize.

@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
    Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp();
    final ByteBuf opaqueValues = Unpooled.buffer();
    final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily());
    if (!serializeOpaqueList(mldpP2mpLsp.getOpaqueValue(), opaqueValues) || addressFamily == 0) {
        return NO_TUNNEL_INFORMATION_PRESENT;
    }
    final IpAddress rootNode = mldpP2mpLsp.getRootNodeAddress();
    ByteBufWriteUtil.writeUnsignedByte(P2MP_TYPE, buffer);
    ByteBufWriteUtil.writeUnsignedShort(addressFamily, buffer);
    ByteBufWriteUtil.writeUnsignedByte(getAdressFamilyLength(rootNode), buffer);
    serializeIpAddress(rootNode, buffer);
    ByteBufWriteUtil.writeUnsignedShort(opaqueValues.readableBytes(), buffer);
    buffer.writeBytes(opaqueValues);
    return TunnelType.MLDP_P2MP_LSP.getIntValue();
}
Also used : MldpP2mpLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpP2mpLsp) ByteBuf(io.netty.buffer.ByteBuf) PAddressPMulticastGroupUtil.serializeIpAddress(org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.serializeIpAddress) PAddressPMulticastGroupUtil.parseIpAddress(org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.parseIpAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)10 ArrayList (java.util.ArrayList)10 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)6 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.AddressFamily)6 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)6 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)6 Test (org.junit.Test)5 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)4 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiers)3 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)3 Preconditions (com.google.common.base.Preconditions)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)2 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)2 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)2 VrfsContainer (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.VrfsContainer)2 Vrfs (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.Vrfs)2 VrfsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.VrfsKey)2