Search in sources :

Example 1 with Port

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port in project netvirt by opendaylight.

the class ElanInterfaceManager method setupEntriesForElanInterface.

List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) throws ElanException {
    String elanInstanceName = elanInstance.getElanInstanceName();
    String interfaceName = elanInterface.getName();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    BigInteger dpId = interfaceInfo.getDpId();
    WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction();
    installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx);
    List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
    List<PhysAddress> staticMacAddresses = Lists.newArrayList();
    boolean isInterfaceOperational = isOperational(interfaceInfo);
    if (ElanUtils.isNotEmpty(staticMacEntriesList)) {
        for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
            InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress());
            Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
            if (existingMacEntry.isPresent()) {
                elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanInstanceName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
            } else {
                elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
            }
            if (isInterfaceOperational) {
                // Setting SMAC, DMAC, UDMAC in this DPN and also in other
                // DPNs
                String macAddress = staticMacEntry.getMacAddress().getValue();
                LOG.info("programming smac and dmacs for {} on source and other DPNs for elan {} and interface {}", macAddress, elanInstanceName, interfaceName);
                elanUtils.setupMacFlows(elanInstance, interfaceInfo, ElanConstants.STATIC_MAC_TIMEOUT, staticMacEntry.getMacAddress().getValue(), true, writeFlowGroupTx);
            }
        }
        if (isInterfaceOperational) {
            // on purpose.
            for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
                staticMacAddresses.add(staticMacEntry.getMacAddress());
            }
            elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, staticMacAddresses);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    futures.add(ElanUtils.waitForTransactionToComplete(writeFlowGroupTx));
    if (isInterfaceOperational && !interfaceManager.isExternalInterface(interfaceName)) {
        // At this point, the interface is operational and D/SMAC flows have been configured, mark the port active
        try {
            Port neutronPort = neutronVpnManager.getNeutronPort(interfaceName);
            if (neutronPort != null) {
                NeutronUtils.updatePortStatus(interfaceName, NeutronUtils.PORT_STATUS_ACTIVE, broker);
            }
        } catch (IllegalArgumentException ex) {
            LOG.trace("Interface: {} is not part of Neutron Network", interfaceName);
        }
    }
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 2 with Port

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port in project netvirt by opendaylight.

the class ElanBridgeManager method prepareIntegrationBridge.

private void prepareIntegrationBridge(Node ovsdbNode, Node brIntNode) {
    if (southboundUtils.getBridgeFromConfig(ovsdbNode, INTEGRATION_BRIDGE) == null) {
        LOG.debug("br-int in operational but not config, copying into config");
        copyBridgeToConfig(brIntNode);
    }
    Map<String, String> providerMappings = getOpenvswitchOtherConfigMap(ovsdbNode, PROVIDER_MAPPINGS_KEY);
    for (String value : providerMappings.values()) {
        if (southboundUtils.extractTerminationPointAugmentation(brIntNode, value) != null) {
            LOG.debug("prepareIntegrationBridge: port {} already exists on {}", value, INTEGRATION_BRIDGE);
            continue;
        }
        Node exBridgeNode = southboundUtils.readBridgeNode(ovsdbNode, value);
        if (exBridgeNode != null) {
            LOG.debug("prepareIntegrationBridge: bridge {} found. Patching to {}", value, INTEGRATION_BRIDGE);
            patchBridgeToBrInt(brIntNode, exBridgeNode, value);
        } else {
            LOG.debug("prepareIntegrationBridge: adding interface {} to {}", value, INTEGRATION_BRIDGE);
            if (!addPortToBridge(brIntNode, INTEGRATION_BRIDGE, value)) {
                LOG.error("Failed to add {} port to {}", value, brIntNode);
            }
        }
    }
    if (!addControllerToBridge(ovsdbNode, INTEGRATION_BRIDGE)) {
        LOG.error("Failed to set controller to existing integration bridge {}", brIntNode);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Example 3 with Port

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port in project netvirt by opendaylight.

the class ElanSmacFlowEventListener method onFlowRemoved.

@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
    short tableId = flowRemoved.getTableId();
    if (tableId == NwConstants.ELAN_SMAC_TABLE) {
        BigInteger metadata = flowRemoved.getMatch().getMetadata().getMetadata();
        long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
        ElanTagName elanTagInfo = elanUtils.getElanInfoByElanTag(elanTag);
        if (elanTagInfo == null) {
            return;
        }
        final String srcMacAddress = flowRemoved.getMatch().getEthernetMatch().getEthernetSource().getAddress().getValue().toUpperCase(Locale.getDefault());
        int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
        if (portTag == 0) {
            LOG.debug("Flow removed event on SMAC flow entry. But having port Tag as 0 ");
            return;
        }
        Optional<IfIndexInterface> existingInterfaceInfo = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
        if (!existingInterfaceInfo.isPresent()) {
            LOG.debug("Interface is not available for port Tag {}", portTag);
            return;
        }
        String interfaceName = existingInterfaceInfo.get().getInterfaceName();
        PhysAddress physAddress = new PhysAddress(srcMacAddress);
        if (interfaceName == null) {
            LOG.error("LPort record not found for tag {}", portTag);
            return;
        }
        jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), () -> {
            List<ListenableFuture<Void>> elanFutures = new ArrayList<>();
            MacEntry macEntry = elanUtils.getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
            String elanInstanceName = elanTagInfo.getName();
            LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
            if (macEntry != null && interfaceInfo != null) {
                ListenableFuture<Void> result = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry, tx));
                elanFutures.add(result);
                addCallBack(result, srcMacAddress);
            }
            InstanceIdentifier<MacEntry> macEntryIdForElanInterface = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
            Optional<MacEntry> existingInterfaceMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
            if (existingInterfaceMacEntry.isPresent()) {
                ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
                    tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
                    MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName, physAddress).orNull();
                    if (macEntryInElanInstance != null && macEntryInElanInstance.getInterface().equals(interfaceName)) {
                        InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
                        tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
                    }
                });
                elanFutures.add(future);
                addCallBack(future, srcMacAddress);
            }
            return elanFutures;
        }, ElanConstants.JOB_MAX_RETRIES);
    }
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 4 with Port

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port in project netvirt by opendaylight.

the class VpnManagerImpl method installArpResponderFlowsToExternalNetworkIp.

private void installArpResponderFlowsToExternalNetworkIp(String macAddress, BigInteger dpnId, String extInterfaceName, int lportTag, String fixedIp) {
    // reset the split-horizon bit to allow traffic to be sent back to the
    // provider port
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(BigInteger.ZERO, MetaDataUtil.METADATA_MASK_SH_FLAG).buildInstruction(1));
    instructions.addAll(ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, extInterfaceName, fixedIp, macAddress));
    ArpReponderInputBuilder builder = new ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(extInterfaceName).setSpa(fixedIp).setSha(macAddress).setLportTag(lportTag);
    builder.setInstructions(instructions);
    elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
Also used : ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) ArrayList(java.util.ArrayList) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 5 with Port

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port in project netvirt by opendaylight.

the class SubnetRouteInterfaceStateChangeListener method add.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
    LOG.trace("{} add: Received interface {} up event", LOGGING_PREFIX, intrf);
    try {
        if (L2vlan.class.equals(intrf.getType())) {
            LOG.trace("SubnetRouteInterfaceListener add: Received interface {} up event", intrf);
            if (intrf.getOperStatus().equals(Interface.OperStatus.Up)) {
                List<Uuid> subnetIdList = getSubnetId(intrf);
                if (subnetIdList.isEmpty()) {
                    LOG.trace("SubnetRouteInterfaceListener add: Port {} doesn't exist in configDS", intrf.getName());
                    return;
                }
                for (Uuid subnetId : subnetIdList) {
                    jobCoordinator.enqueueJob("SUBNETROUTE-" + subnetId, () -> {
                        String interfaceName = intrf.getName();
                        BigInteger dpnId = BigInteger.ZERO;
                        LOG.info("{} add: Received port UP event for interface {} subnetId {}", LOGGING_PREFIX, interfaceName, subnetId);
                        try {
                            dpnId = InterfaceUtils.getDpIdFromInterface(intrf);
                        } catch (Exception e) {
                            LOG.error("{} add: Unable to obtain dpnId for interface {} in subnet {}," + " subnetroute inclusion for this interface failed", LOGGING_PREFIX, interfaceName, subnetId, e);
                        }
                        InstanceIdentifier<VpnInterface> id = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
                        Optional<VpnInterface> cfgVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
                        List<ListenableFuture<Void>> futures = new ArrayList<>();
                        if (!cfgVpnInterface.isPresent()) {
                            return futures;
                        }
                        vpnSubnetRouteHandler.onInterfaceUp(dpnId, intrf.getName(), subnetId);
                        return futures;
                    });
                }
            }
        }
        LOG.info("{} add: Processed interface {} up event", LOGGING_PREFIX, intrf.getName());
    } catch (Exception e) {
        LOG.error("{} add: Exception observed in handling addition for VPN Interface {}.", LOGGING_PREFIX, intrf.getName(), e);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Aggregations

ArrayList (java.util.ArrayList)124 Test (org.junit.Test)110 BigInteger (java.math.BigInteger)106 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)104 ByteBuf (io.netty.buffer.ByteBuf)57 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)44 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)44 List (java.util.List)42 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)41 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)41 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)40 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)38 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)37 ExecutionException (java.util.concurrent.ExecutionException)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)32 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)28 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)27