Search in sources :

Example 86 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanUtils method buildRemoteDmacFlowEntry.

/**
 * Builds a Flow to be programmed in a remote DPN's DMAC table. This flow
 * consists in: Match: + elanTag in packet's metadata + packet going to a
 * MAC known to be located in another DPN Actions: + set_tunnel_id
 * + output ITM internal tunnel interface with the other DPN
 *
 * @param srcDpId
 *            the src Dpn Id
 * @param destDpId
 *            dest Dp Id
 * @param lportTagOrVni
 *            lportTag or network VNI
 * @param elanTag
 *            elan Tag
 * @param macAddress
 *            macAddress
 * @param displayName
 *            display Name
 * @param elanInstance
 *            elanInstance
 * @return the flow remote Dmac
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildRemoteDmacFlowEntry(BigInteger srcDpId, BigInteger destDpId, long lportTagOrVni, long elanTag, String macAddress, String displayName, ElanInstance elanInstance) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
    List<Instruction> mkInstructions = new ArrayList<>();
    // List of Action for the provided Source and Destination DPIDs
    try {
        List<Action> actions = null;
        if (isVlan(elanInstance) || isFlat(elanInstance)) {
            String interfaceName = getExternalElanInterface(elanInstance.getElanInstanceName(), srcDpId);
            if (null == interfaceName) {
                LOG.info("buildRemoteDmacFlowEntry: Could not find interfaceName for {} {}", srcDpId, elanInstance);
            }
            actions = getEgressActionsForInterface(interfaceName, null);
        } else if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
            actions = elanItmUtils.getInternalTunnelItmEgressAction(srcDpId, destDpId, lportTagOrVni);
        }
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get egress actions to add to flow for srcDpId {}, destDpId {}, lportTag/VNI {}", srcDpId, destDpId, lportTagOrVni, e);
    }
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcDpId, destDpId, macAddress, elanTag), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
    return flow;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Example 87 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanServiceProvider method updateExternalElanNetworks.

@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
    if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
        return;
    }
    List<ElanInstance> elanInstances = getElanInstances();
    if (elanInstances == null || elanInstances.isEmpty()) {
        LOG.trace("No ELAN instances found");
        return;
    }
    LOG.debug("updateExternalElanNetworks, orig bridge {} . updated bridge {}", origNode, updatedNode);
    Map<String, String> origProviderMappping = getMapFromOtherConfig(origNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
    Map<String, String> updatedProviderMappping = getMapFromOtherConfig(updatedNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
    boolean hasDatapathIdOnOrigNode = bridgeMgr.hasDatapathID(origNode);
    boolean hasDatapathIdOnUpdatedNode = bridgeMgr.hasDatapathID(updatedNode);
    BigInteger origDpnID = bridgeMgr.getDatapathId(origNode);
    for (ElanInstance elanInstance : elanInstances) {
        String physicalNetworkName = elanInstance.getPhysicalNetworkName();
        boolean createExternalElanNw = true;
        if (physicalNetworkName != null) {
            String origPortName = origProviderMappping.get(physicalNetworkName);
            String updatedPortName = updatedProviderMappping.get(physicalNetworkName);
            /**
             * for internal vlan network, vlan provider interface creation should be
             * triggered only if there is existing vlan provider intf indicating presence
             * of VM ports on the DPN
             */
            if (hasDatapathIdOnOrigNode && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
                String externalIntf = getExternalElanInterface(elanInstance.getElanInstanceName(), origDpnID);
                if (externalIntf == null) {
                    createExternalElanNw = false;
                }
            }
            if (hasPortNameRemoved(origPortName, updatedPortName)) {
                deleteExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(origNode, physicalNetworkName));
            }
            if (createExternalElanNw && (hasPortNameUpdated(origPortName, updatedPortName) || hasDatapathIdAdded(hasDatapathIdOnOrigNode, hasDatapathIdOnUpdatedNode))) {
                createExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(updatedNode, physicalNetworkName));
            }
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) BigInteger(java.math.BigInteger)

Example 88 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanServiceProvider method createIetfInterfaces.

/**
 * Create ietf-interfaces based on the ELAN segment type.<br>
 * For segment type flat - create transparent interface pointing to the
 * patch-port attached to the physnet port.<br>
 * For segment type vlan - create trunk interface pointing to the patch-port
 * attached to the physnet port + trunk-member interface pointing to the
 * trunk interface.
 *
 * @param elanInstance
 *            ELAN instance
 * @param parentRef
 *            parent interface name
 * @return the name of the interface to be added to the ELAN instance i.e.
 *         trunk-member name for vlan network and transparent for flat
 *         network or null otherwise
 */
private String createIetfInterfaces(ElanInstance elanInstance, String parentRef) {
    String interfaceName = null;
    try {
        String trunkName = getTrunkInterfaceName(parentRef);
        // trunk interface may have been created by other vlan network
        Interface trunkInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(trunkName);
        if (trunkInterface == null) {
            interfaceManager.createVLANInterface(trunkName, parentRef, null, null, IfL2vlan.L2vlanMode.Trunk, true);
        }
        if (ElanUtils.isFlat(elanInstance)) {
            interfaceName = trunkName;
        } else if (ElanUtils.isVlan(elanInstance)) {
            Long segmentationId = elanInstance.getSegmentationId();
            interfaceName = parentRef + IfmConstants.OF_URI_SEPARATOR + segmentationId;
            interfaceManager.createVLANInterface(interfaceName, trunkName, segmentationId.intValue(), null, IfL2vlan.L2vlanMode.TrunkMember, true);
        }
    } catch (InterfaceAlreadyExistsException e) {
        LOG.trace("Interface {} was already created", interfaceName);
    }
    return interfaceName;
}
Also used : InterfaceAlreadyExistsException(org.opendaylight.genius.interfacemanager.exceptions.InterfaceAlreadyExistsException) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 89 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class VpnInterfaceManager method processExternalVpnInterface.

private void processExternalVpnInterface(String interfaceName, String vpnName, long vpnId, BigInteger dpId, int lportTag, WriteTransaction writeInvTxn, int addOrRemove) {
    Uuid extNetworkId;
    try {
        // vpn instance of ext-net interface is the network-id
        extNetworkId = new Uuid(vpnName);
    } catch (IllegalArgumentException e) {
        LOG.error("processExternalVpnInterface: VPN instance {} is not Uuid. Processing external vpn interface {}" + " on dpn {} failed", vpnName, interfaceName, dpId);
        return;
    }
    List<Uuid> routerIds = VpnUtil.getExternalNetworkRouterIds(dataBroker, extNetworkId);
    if (routerIds == null || routerIds.isEmpty()) {
        LOG.info("processExternalVpnInterface: No router is associated with {}." + " Bailing out of processing external vpn interface {} on dpn {} for vpn {}", extNetworkId.getValue(), interfaceName, dpId, vpnName);
        return;
    }
    LOG.info("processExternalVpnInterface: Router-ids {} associated with exernal vpn-interface {} on dpn {}" + " for vpn {}", routerIds, interfaceName, dpId, vpnName);
    for (Uuid routerId : routerIds) {
        String routerName = routerId.getValue();
        BigInteger primarySwitch = VpnUtil.getPrimarySwitchForRouter(dataBroker, routerName);
        if (Objects.equals(primarySwitch, dpId)) {
            Routers router = VpnUtil.getExternalRouter(dataBroker, routerName);
            if (router != null) {
                if (addOrRemove == NwConstants.ADD_FLOW) {
                    vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), router.getExtGwMacAddress(), dpId, interfaceName, lportTag, writeInvTxn);
                } else {
                    vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), dpId, interfaceName, lportTag);
                }
            } else {
                LOG.error("processExternalVpnInterface: No external-router found for router-id {}. Bailing out of" + " processing external vpn-interface {} on dpn {} for vpn {}", routerName, interfaceName, dpId, vpnName);
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) BigInteger(java.math.BigInteger)

Example 90 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class VpnManagerImpl method setupRouterGwMacFlow.

private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx, RouterGwMacFlowSetupMethod consumer, String operation) {
    if (routerGwMac == null) {
        LOG.warn("Failed to handle router GW flow in GW-MAC table. MAC address is missing for router-id {}", routerName);
        return;
    }
    if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
        LOG.info("setupRouterGwMacFlow: DPN id is missing for router-id {}", routerName);
        return;
    }
    Uuid vpnId = VpnUtil.getExternalNetworkVpnId(dataBroker, extNetworkId);
    if (vpnId == null) {
        LOG.warn("Network {} is not associated with VPN", extNetworkId.getValue());
        return;
    }
    LOG.info("{} router GW MAC flow for router-id {} on switch {}", operation, routerName, dpnId);
    if (writeTx == null) {
        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> consumer.process(vpnId.getValue(), tx)), LOG, "Commit transaction");
    } else {
        consumer.process(vpnId.getValue(), writeTx);
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) LoggerFactory(org.slf4j.LoggerFactory) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Future(java.util.concurrent.Future) InterVpnLinkCache(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) Optional(com.google.common.base.Optional) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) NxMatchRegister(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister) IVpnLinkService(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.IVpnLinkService) L3vpnRegistry(org.opendaylight.netvirt.vpnmanager.populator.registry.L3vpnRegistry) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Collection(java.util.Collection) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) PostConstruct(javax.annotation.PostConstruct) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) VpnInstances(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite) ArpResponderUtil(org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput) Logger(org.slf4j.Logger) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ExecutionException(java.util.concurrent.ExecutionException) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) UpgradeState(org.opendaylight.genius.mdsalutil.UpgradeState) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)93 ArrayList (java.util.ArrayList)46 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)33 BigInteger (java.math.BigInteger)31 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)31 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)26 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)19 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)19 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)19 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)17 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)15 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)11 ExecutionException (java.util.concurrent.ExecutionException)10 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)10 Networks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks)10 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)10 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)9 HashSet (java.util.HashSet)8 Nonnull (javax.annotation.Nonnull)8