Search in sources :

Example 1 with Networks

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

the class ElanInterfaceManager method addElanInterface.

List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface, InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
    Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
    Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
    Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");
    String interfaceName = elanInterface.getName();
    String elanInstanceName = elanInterface.getElanInstanceName();
    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    if (elanInfo == null) {
        List<String> elanInterfaces = new ArrayList<>();
        elanInterfaces.add(interfaceName);
        ElanUtils.updateOperationalDataStore(idManager, elanInstance, elanInterfaces, tx);
    } else {
        createElanStateList(elanInstanceName, interfaceName, tx);
    }
    boolean isFirstInterfaceInDpn = false;
    // Specific actions to the DPN where the ElanInterface has been added,
    // for example, programming the
    // External tunnel table if needed or adding the ElanInterface to the
    // DpnInterfaces in the operational DS.
    BigInteger dpId = interfaceInfo.getDpId();
    DpnInterfaces dpnInterfaces = null;
    if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
        InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
        Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
        if (!existingElanDpnInterfaces.isPresent()) {
            isFirstInterfaceInDpn = true;
            // ELAN's 1st ElanInterface added to this DPN
            dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
            // table, but only if Elan has VNI
            if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
                setExternalTunnelTable(dpId, elanInstance);
            }
            elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
        } else {
            List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
            elanInterfaces.add(interfaceName);
            if (elanInterfaces.size() == 1) {
                // 1st dpn interface
                elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
            }
            dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
        }
    }
    // add code to install Local/Remote BC group, unknow DMAC entry,
    // terminating service table flow entry
    // call bindservice of interfacemanager to create ingress table flow
    // enty.
    // Add interface to the ElanInterfaceForwardingEntires Container
    createElanInterfaceTablesList(interfaceName, tx);
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn);
    // for internal vlan networks
    if (ElanUtils.isVlan(elanInstance) && !elanInstance.isExternal()) {
        if (interfaceManager.isExternalInterface(interfaceName)) {
            LOG.debug("adding vlan prv intf {} to elan {} BC group", interfaceName, elanInstanceName);
            handleExternalInterfaceEvent(elanInstance, dpnInterfaces, dpId);
        }
    }
    if (isFirstInterfaceInDpn && isVxlanNetworkOrVxlanSegment(elanInstance)) {
        // update the remote-DPNs remoteBC group entry with Tunnels
        LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance, dpId);
        setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
    }
    String jobKey = ElanUtils.getElanInterfaceJobKey(interfaceName);
    InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(jobKey, elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
    jobCoordinator.enqueueJob(jobKey, addWorker, ElanConstants.JOB_MAX_RETRIES);
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 2 with Networks

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

the class BgpConfigurationManager method addPrefix.

public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, long lbl, long l3vni, long l2vni, String gatewayMac) {
    for (String nh : nhList) {
        Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
        Long label = lbl;
        InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
        NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(BgpConstants.DEFAULT_ETH_TAG);
        buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
        update(iid, networksBuilder.build());
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks) NetworksKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.NetworksKey) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) NetworksBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.NetworksBuilder)

Example 3 with Networks

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

the class BgpConfigurationManager method delPrefix.

public void delPrefix(String rd, String pfx) {
    InstanceIdentifier.InstanceIdentifierBuilder<Networks> iib = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd));
    InstanceIdentifier<Networks> iid = iib.build();
    delete(iid);
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks) NetworksKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.NetworksKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Bgp(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)

Example 4 with Networks

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

the class ExternalNetworksChangeListener method update.

@Override
protected void update(InstanceIdentifier<Networks> identifier, Networks original, Networks update) {
    // Check for VPN disassociation
    Uuid originalVpn = original.getVpnid();
    Uuid updatedVpn = update.getVpnid();
    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + update.getKey(), () -> {
        WriteTransaction writeFlowInvTx = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (originalVpn == null && updatedVpn != null) {
            // external network is dis-associated from L3VPN instance
            associateExternalNetworkWithVPN(update, writeFlowInvTx);
        } else if (originalVpn != null && updatedVpn == null) {
            // external network is associated with vpn
            disassociateExternalNetworkFromVPN(update, originalVpn.getValue());
            // Remove the SNAT entries
            removeSnatEntries(original, original.getId(), writeFlowInvTx);
        }
        futures.add(NatUtil.waitForTransactionToComplete(writeFlowInvTx));
        return futures;
    }, NatConstants.NAT_DJC_MAX_RETRIES);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 5 with Networks

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

the class ExternalNetworksChangeListener method disassociateExternalNetworkFromVPN.

private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) {
    List<Uuid> routerIds = network.getRouterIds();
    for (Uuid routerId : routerIds) {
        InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
        Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
        if (!optRouterPorts.isPresent()) {
            LOG.debug("disassociateExternalNetworkFromVPN : Could not read Router Ports data object with id: {} " + "to handle disassociate ext nw {}", routerId, network.getId());
            continue;
        }
        RouterPorts routerPorts = optRouterPorts.get();
        List<Ports> interfaces = routerPorts.getPorts();
        WriteTransaction removeFlowInvTx = dataBroker.newWriteOnlyTransaction();
        for (Ports port : interfaces) {
            String portName = port.getPortName();
            BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
            if (dpnId.equals(BigInteger.ZERO)) {
                LOG.debug("disassociateExternalNetworkFromVPN : DPN not found for {}," + "skip handling of ext nw {} disassociation", portName, network.getId());
                continue;
            }
            List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
            for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
                floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), intExtPortMap, removeFlowInvTx);
            }
        }
        NatUtil.waitForTransactionToComplete(removeFlowInvTx);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) BigInteger(java.math.BigInteger) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)29 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)12 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)11 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)11 Networks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks)11 NetworksKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey)10 ArrayList (java.util.ArrayList)9 BigInteger (java.math.BigInteger)7 NetworksBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder)6 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)6 Nonnull (javax.annotation.Nonnull)5 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 HashSet (java.util.HashSet)3 ExecutionException (java.util.concurrent.ExecutionException)3 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)3 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)3