Search in sources :

Example 6 with Networks

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

the class BgpManagerTestImpl method addPrefix.

public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, Uint32 lbl, Uint32 l3vni, Uint32 l2vni, String gatewayMac) throws TransactionCommitFailedException {
    for (String nh : nhList) {
        Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
        Uint32 label = lbl;
        InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(NetworksContainer.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
        NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(Uint32.ZERO);
        buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
        singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, iid, networksBuilder.build());
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks) NetworksKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey) Bgp(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp) Uint32(org.opendaylight.yangtools.yang.common.Uint32) 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.networkscontainer.NetworksBuilder)

Example 7 with Networks

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

the class ElanServiceTest method createElanInstanceAndInterfaceAndAttachEvpn.

public void createElanInstanceAndInterfaceAndAttachEvpn() throws ReadFailedException, TransactionCommitFailedException {
    // Create Elan instance
    createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
    awaitForElanTag(ExpectedObjects.ELAN1);
    // Read Elan Instance
    InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
    ElanInstance elanInstance = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
    // Add Elan interface
    addElanInterface(ExpectedObjects.ELAN1, ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft(), DPN1IP1);
    // Attach EVPN to networks
    evpnTestHelper.attachEvpnToNetwork(elanInstance);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)

Example 8 with Networks

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.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, Uint32 lbl, Uint32 l3vni, Uint32 l2vni, String gatewayMac) {
    for (String nh : nhList) {
        Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
        Uint32 label = lbl;
        InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(NetworksContainer.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.networkscontainer.Networks) NetworksKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey) Bgp(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp) Uint32(org.opendaylight.yangtools.yang.common.Uint32) 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.networkscontainer.NetworksBuilder)

Example 9 with Networks

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

the class ExternalRoutersListener method remove.

@Override
public void remove(InstanceIdentifier<Routers> identifier, Routers router) {
    if (natMode != NatMode.Controller) {
        return;
    }
    LOG.trace("remove : Router delete method");
    if (identifier == null || router == null) {
        LOG.error("remove : returning without processing since routers is null");
        return;
    }
    String routerName = router.getRouterName();
    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + router.key(), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
        LOG.info("remove : Removing default NAT route from FIB on all dpns part of router {} ", routerName);
        Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
        if (routerId == NatConstants.INVALID_ID) {
            LOG.error("remove : Remove external router event - Invalid routerId for routerName {}", routerName);
            return;
        }
        Uint32 bgpVpnId = NatConstants.INVALID_ID;
        Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
        if (bgpVpnUuid != null) {
            bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnUuid.getValue());
        }
        addOrDelDefFibRouteToSNAT(routerName, routerId, bgpVpnId, bgpVpnUuid, false, tx);
        Uuid networkUuid = router.getNetworkId();
        Uint64 primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
        if (primarySwitchId == null || primarySwitchId.equals(Uint64.ZERO)) {
            // No NAPT switch for external router, probably because the router is not attached to
            // any
            // internal networks
            LOG.debug("No NAPT switch for router {}, check if router is attached to any internal " + "network", routerName);
            return;
        } else {
            Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
            final String vpnName = NatUtil.getAssociatedVPN(dataBroker, networkUuid);
            handleDisableSnat(router, networkUuid, externalIps, true, vpnName, primarySwitchId, routerId, tx);
        }
        if (NatUtil.releaseId(idManager, NatConstants.ODL_VNI_POOL_NAME, routerName) == NatConstants.INVALID_ID) {
            LOG.error("remove: Unable to release VNI for router - {}", routerName);
        }
    })), NatConstants.NAT_DJC_MAX_RETRIES);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 10 with Networks

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

the class ExternalNetworksChangeListener method disassociateExternalNetworkFromVPN.

private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) {
    if (network.getRouterIds() != null) {
        for (Uuid routerId : network.getRouterIds()) {
            InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
            Optional<RouterPorts> optRouterPorts = Optional.empty();
            try {
                optRouterPorts = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
            } catch (ExecutionException | InterruptedException e) {
                LOG.error("disassociateExternalNetworkFromVPN: Exception while reading RouterPorts DS for the " + "router {} network {} vpn {}", routerId, network.getId().getValue(), vpnName, e);
            }
            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();
            for (Ports port : routerPorts.nonnullPorts().values()) {
                String portName = port.getPortName();
                Uint64 dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
                if (dpnId.equals(Uint64.ZERO)) {
                    LOG.debug("disassociateExternalNetworkFromVPN : DPN not found for {}," + "skip handling of ext nw {} disassociation", portName, network.getId());
                    continue;
                }
                for (InternalToExternalPortMap intExtPortMap : port.nonnullInternalToExternalPortMap().values()) {
                    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + intExtPortMap.key(), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), intExtPortMap, tx))), NatConstants.NAT_DJC_MAX_RETRIES);
                }
            }
        }
    }
}
Also used : 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) ExecutionException(java.util.concurrent.ExecutionException) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)43 ExecutionException (java.util.concurrent.ExecutionException)19 ArrayList (java.util.ArrayList)16 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)14 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)13 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)13 Networks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks)13 NetworksKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey)11 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)9 BigInteger (java.math.BigInteger)6 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks)6 NetworksKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey)6 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)5 HashSet (java.util.HashSet)4 NonNull (org.eclipse.jdt.annotation.NonNull)4 AcquireResult (org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.AcquireResult)4 NetworksBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder)4 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)4 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)4 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)4