Search in sources :

Example 51 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project lispflowmapping by opendaylight.

the class MappingDataListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(Collection<DataTreeModification<Mapping>> changes) {
    for (DataTreeModification<Mapping> change : changes) {
        final DataObjectModification<Mapping> mod = change.getRootNode();
        if (ModificationType.DELETE == mod.getModificationType()) {
            // Process deleted mappings
            final Mapping mapping = mod.getDataBefore();
            // before being persisted, except for cluster slaves
            if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
                continue;
            }
            LOG.trace("Received deleted data");
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", mapping);
            final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
            mapSystem.removeMapping(convertedMapping.getOrigin(), convertedMapping.getMappingRecord().getEid());
        } else if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType() || ModificationType.WRITE == mod.getModificationType()) {
            final Mapping mapping = mod.getDataAfter();
            // SB notifications
            if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
                continue;
            }
            final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
            Eid convertedEid = convertedMapping.getMappingRecord().getEid();
            if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
                LOG.trace("Received update data");
                LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
                LOG.trace("Value: {}", mapping);
                mapSystem.updateMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
            } else {
                LOG.trace("Received write data");
                LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
                LOG.trace("Value: {}", mapping);
                mapSystem.addMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
            }
        } else {
            LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)

Example 52 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.

the class TransportZoneListener method remove.

@Override
public void remove(@Nonnull TransportZone transportZone) {
    LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
    boolean allowTunnelDeletion;
    // due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
    if (transportZone.getZoneName().equalsIgnoreCase(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
        // Get TunnelTypeBase object for tunnel-type configured in config file
        Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
        if (!itmConfig.isDefTzEnabled() || !transportZone.getTunnelType().equals(tunType)) {
            allowTunnelDeletion = true;
        } else {
            // this is case when def-tz removal request is from Northbound.
            allowTunnelDeletion = false;
            LOG.error("Deletion of {} is an incorrect usage", ITMConstants.DEFAULT_TRANSPORT_ZONE);
        }
    } else {
        allowTunnelDeletion = true;
    }
    if (allowTunnelDeletion) {
        // TODO : DPList code can be refactor with new specific class
        // which implement TransportZoneValidator
        List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
        List<HwVtep> hwVtepList = createhWVteps(transportZone);
        LOG.trace("Delete: Invoking deleteTunnels in ItmManager with DpnList {}", opDpnList);
        if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
            LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
            jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 53 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.

the class VtepConfigSchemaListener method update.

@Override
public void update(@Nonnull VtepConfigSchema original, @Nonnull VtepConfigSchema updated) {
    LOG.error("Received DCN for updating VTEP Original schema: {}. Updated schema: {}", original, updated);
    VtepConfigSchema originalSchema = ItmUtils.validateVtepConfigSchema(original);
    VtepConfigSchema updatedSchema = ItmUtils.validateVtepConfigSchema(updated);
    if (doesDeleteAndAddSchemaRequired(original, updated)) {
        LOG.error("Failed to handle DCN for updating VTEP schema. Original schema: {}. Updated schema: {}", original, updated);
        // TODO: handle updates
        return;
    }
    handleUpdateOfDpnIds(originalSchema, updatedSchema);
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 54 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.

the class ArpUtilImpl method sendArpResponse.

@Override
public Future<RpcResult<Void>> sendArpResponse(SendArpResponseInput input) {
    LOG.trace("sendArpResponse rpc invoked");
    BigInteger dpnId;
    byte[] payload;
    byte[] srcMac;
    try {
        String interfaceName = input.getInterface();
        GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
        checkNotNull(portResult);
        dpnId = portResult.getDpid();
        Long portid = portResult.getPortno();
        NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
        checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId), ArpConstants.DPN_NOT_FOUND_ERROR, interfaceName);
        checkNotNull(ref, ArpConstants.NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
        LOG.trace("sendArpRequest received dpnId {} out interface {}", dpnId, interfaceName);
        byte[] srcIpBytes = getIpAddressBytes(input.getSrcIpaddress());
        byte[] dstIpBytes = getIpAddressBytes(input.getDstIpaddress());
        if (input.getSrcMacaddress() == null) {
            srcMac = portResult.getPhyAddress().getBytes("UTF-8");
        } else {
            String macAddr = input.getSrcMacaddress().getValue();
            srcMac = HexEncode.bytesFromHexString(macAddr);
        }
        byte[] dstMac = NWUtil.parseMacAddress(input.getDstMacaddress().getValue());
        checkNotNull(srcIpBytes, ArpConstants.FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
        payload = ArpPacketUtil.getPayload(ArpConstants.ARP_RESPONSE_OP, srcMac, srcIpBytes, dstMac, dstIpBytes);
        List<Action> actions = getEgressAction(interfaceName);
        sendPacketOutWithActions(dpnId, payload, ref, actions);
        LOG.debug("Sent ARP response for IP {}, from source MAC {} to target MAC {} and target IP {} via dpnId {}", input.getSrcIpaddress().getIpv4Address().getValue(), HexEncode.bytesToHexStringFormat(srcMac), HexEncode.bytesToHexStringFormat(dstMac), input.getDstIpaddress().getIpv4Address().getValue(), dpnId);
    } catch (UnknownHostException | PacketException | InterruptedException | UnsupportedEncodingException | ExecutionException e) {
        LOG.error("failed to send arp response for {}: ", input.getSrcIpaddress(), e);
        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, e.getMessage(), e).buildFuture();
    }
    RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.success();
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) UnknownHostException(java.net.UnknownHostException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) BigInteger(java.math.BigInteger) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 55 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project genius by opendaylight.

the class ArpUtilImpl method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived packetReceived) {
    Class<? extends PacketInReason> pktInReason = packetReceived.getPacketInReason();
    LOG.trace("Packet Received {}", packetReceived);
    if (pktInReason == SendToController.class) {
        try {
            int tableId = packetReceived.getTableId().getValue();
            byte[] data = packetReceived.getPayload();
            Ethernet ethernet = new Ethernet();
            ethernet.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
            if (ethernet.getEtherType() != ArpConstants.ETH_TYPE_ARP) {
                return;
            }
            Packet pkt = ethernet.getPayload();
            ARP arp = (ARP) pkt;
            InetAddress srcInetAddr = InetAddress.getByAddress(arp.getSenderProtocolAddress());
            InetAddress dstInetAddr = InetAddress.getByAddress(arp.getTargetProtocolAddress());
            byte[] srcMac = ethernet.getSourceMACAddress();
            byte[] dstMac = ethernet.getDestinationMACAddress();
            Metadata metadata = packetReceived.getMatch().getMetadata();
            String interfaceName = getInterfaceName(metadata);
            checkAndFireMacChangedNotification(interfaceName, srcInetAddr, srcMac);
            macsDB.put(interfaceName + "-" + srcInetAddr.getHostAddress(), NWUtil.toStringMacAddress(srcMac));
            if (arp.getOpCode() == ArpConstants.ARP_REQUEST_OP) {
                fireArpReqRecvdNotification(interfaceName, srcInetAddr, srcMac, dstInetAddr, tableId, metadata.getMetadata());
            } else {
                fireArpRespRecvdNotification(interfaceName, srcInetAddr, srcMac, tableId, metadata.getMetadata(), dstInetAddr, dstMac);
            }
            if (macAddrs.get(srcInetAddr.getHostAddress()) != null) {
                threadPool.execute(new MacResponderTask(arp));
            }
        } catch (PacketException | UnknownHostException | InterruptedException | ExecutionException e) {
            LOG.trace("Failed to decode packet", e);
        }
    }
}
Also used : Packet(org.opendaylight.openflowplugin.libraries.liblldp.Packet) UnknownHostException(java.net.UnknownHostException) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) ExecutionException(java.util.concurrent.ExecutionException) InetAddress(java.net.InetAddress) ARP(org.opendaylight.genius.mdsalutil.packet.ARP)

Aggregations

BigInteger (java.math.BigInteger)26 ArrayList (java.util.ArrayList)20 ExecutionException (java.util.concurrent.ExecutionException)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 List (java.util.List)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 UnknownHostException (java.net.UnknownHostException)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)8 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)8 Optional (com.google.common.base.Optional)7 Test (org.junit.Test)7 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)7 Collections (java.util.Collections)6 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)6 FutureCallback (com.google.common.util.concurrent.FutureCallback)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)5