Search in sources :

Example 41 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class StatisticsImpl method cleanAllElementCounterRequests.

@Override
public ListenableFuture<RpcResult<CleanAllElementCounterRequestsOutput>> cleanAllElementCounterRequests(CleanAllElementCounterRequestsInput input) {
    ReadTransaction tx = db.newReadOnlyTransaction();
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
    try {
        Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
        Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
        if (!iecrcOpt.isPresent() || !eecrcOpt.isPresent()) {
            LOG.warn("Couldn't read element counters config data from DB");
            statisticsCounters.failedReadingCounterDataFromConfig();
            return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>failed().withError(ErrorType.APPLICATION, "Couldn't read element counters config data from DB").buildFuture();
        }
        Set<String> idsToRelease = new HashSet<>();
        if (input.getPortId() != null && !input.getPortId().isEmpty()) {
            idsToRelease.addAll(getAllPortRequestsUniqueIds(input.getPortId(), iecrcOpt.get().getCounterRequests()));
            idsToRelease.addAll(getAllPortRequestsUniqueIds(input.getPortId(), eecrcOpt.get().getCounterRequests()));
            removeAllElementCounterRequestsOnPort(input.getPortId(), iecrcOpt.get().getCounterRequests());
            removeAllElementCounterRequestsOnPort(input.getPortId(), eecrcOpt.get().getCounterRequests());
        } else {
            idsToRelease.addAll(getAllRquestsUniqueIds(iecrcOpt.get().getCounterRequests()));
            idsToRelease.addAll(getAllRquestsUniqueIds(eecrcOpt.get().getCounterRequests()));
            removeAllElementCounterRequests(iecrcOpt.get().getCounterRequests());
            removeAllElementCounterRequests(eecrcOpt.get().getCounterRequests());
        }
        releaseIds(idsToRelease);
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("failed to get counter request data from DB");
        return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>failed().withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
    } finally {
        tx.close();
    }
    return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>success().buildFuture();
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(java.util.Optional) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) CleanAllElementCounterRequestsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.CleanAllElementCounterRequestsOutput) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 42 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class StatisticsImpl method handleInterfaceRemoval.

@Override
public void handleInterfaceRemoval(String interfaceId) {
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc;
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc;
    try (ReadTransaction tx = db.newReadOnlyTransaction()) {
        iecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
        eecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
    }
    try {
        Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
        Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
        if (!iecrcOpt.isPresent() || !eecrcOpt.isPresent()) {
            LOG.warn("Couldn't read element counters config data from DB");
            statisticsCounters.failedReadingCounterDataFromConfig();
            return;
        }
        removeAllElementCounterRequestsOnPort(interfaceId, iecrcOpt.get().getCounterRequests());
        removeAllElementCounterRequestsOnPort(interfaceId, eecrcOpt.get().getCounterRequests());
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("failed to get counter request data from DB");
        statisticsCounters.failedGettingCounterResultsPortRemoval();
        return;
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(java.util.Optional) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) ExecutionException(java.util.concurrent.ExecutionException)

Example 43 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class BgpConfigurationManager method deleteExternalFibRoutes.

/*
     * BGP config remove scenario, Need to remove all the
     * external routes from FIB.
     */
public void deleteExternalFibRoutes() {
    totalExternalRoutes = 0;
    totalExternalMacRoutes = 0;
    try {
        InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
        Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        if (fibEntries.isPresent()) {
            if (fibEntries.get().getVrfTables() == null) {
                LOG.error("deleteExternalFibRoutes::getVrfTables is null");
                return;
            }
            Map<VrfTablesKey, VrfTables> staleVrfTablesMap = fibEntries.get().getVrfTables();
            for (VrfTables vrfTable : staleVrfTablesMap.values()) {
                String rd = vrfTable.getRouteDistinguisher();
                if (vrfTable.getVrfEntry() != null) {
                    for (VrfEntry vrfEntry : vrfTable.getVrfEntry().values()) {
                        if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
                            // route cleanup is only meant for the routes learned through BGP.
                            continue;
                        }
                        totalExternalRoutes++;
                        fibDSWriter.removeFibEntryFromDS(rd, vrfEntry.getDestPrefix());
                    }
                } else if (vrfTable.getMacVrfEntry() != null) {
                    for (MacVrfEntry macEntry : vrfTable.getMacVrfEntry().values()) {
                        if (RouteOrigin.value(macEntry.getOrigin()) != RouteOrigin.BGP) {
                            // route cleanup is only meant for the routes learned through BGP.
                            continue;
                        }
                        totalExternalMacRoutes++;
                        fibDSWriter.removeMacEntryFromDS(rd, macEntry.getMac());
                    }
                }
            }
        } else {
            LOG.error("deleteExternalFibRoutes:: FIBentries.class is not present");
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("deleteExternalFibRoutes:: error ", e);
    }
    LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) ExecutionException(java.util.concurrent.ExecutionException)

Example 44 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class FloatingIPListener method updateOperationalDS.

static void updateOperationalDS(DataBroker dataBroker, String routerId, String interfaceName, Uint32 label, String internalIp, String externalIp) {
    LOG.info("updateOperationalDS : Updating operational DS for floating ip config : {} with label {}", internalIp, label);
    InstanceIdentifier<Ports> portsId = NatUtil.getPortsIdentifier(routerId, interfaceName);
    Optional<Ports> optPorts = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId);
    InternalToExternalPortMap intExtPortMap = new InternalToExternalPortMapBuilder().withKey(new InternalToExternalPortMapKey(internalIp)).setInternalIp(internalIp).setExternalIp(externalIp).setLabel(label).build();
    if (optPorts.isPresent()) {
        LOG.debug("updateOperationalDS : Ports {} entry already present. Updating intExtPortMap for internal ip {}", interfaceName, internalIp);
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId.child(InternalToExternalPortMap.class, new InternalToExternalPortMapKey(internalIp)), intExtPortMap);
    } else {
        LOG.debug("updateOperationalDS : Adding Ports entry {} along with intExtPortMap {}", interfaceName, internalIp);
        List<InternalToExternalPortMap> intExtPortMapList = new ArrayList<>();
        intExtPortMapList.add(intExtPortMap);
        Ports ports = new PortsBuilder().withKey(new PortsKey(interfaceName)).setPortName(interfaceName).setInternalToExternalPortMap(intExtPortMapList).build();
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId, ports);
    }
}
Also used : InternalToExternalPortMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMapKey) ArrayList(java.util.ArrayList) 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) InternalToExternalPortMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMapBuilder) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsBuilder) PortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsKey)

Example 45 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class NaptEventHandler method prepareAndSendPacketOut.

private void prepareAndSendPacketOut(NAPTEntryEvent naptEntryEvent, Uint32 routerId, String sourceIPPortKey) {
    // Send Packetout - tcp or udp packets which got punted to controller.
    Uint64 metadata = naptEntryEvent.getPacketReceived().getMatch().getMetadata().getMetadata();
    byte[] inPayload = naptEntryEvent.getPacketReceived().getPayload();
    Ethernet ethPkt = new Ethernet();
    if (inPayload != null) {
        try {
            ethPkt.deserialize(inPayload, 0, inPayload.length * Byte.SIZE);
        } catch (PacketException e) {
            NaptPacketInHandler.removeIncomingPacketMap(sourceIPPortKey);
            LOG.error("prepareAndSendPacketOut : Failed to decode Packet", e);
            return;
        }
    }
    long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
    LOG.debug("prepareAndSendPacketOut : portTag from incoming packet is {}", portTag);
    List<ActionInfo> actionInfos = new ArrayList<>();
    String interfaceName = getInterfaceNameFromTag(portTag);
    Uint64 dpnID = null;
    int portNum = -1;
    if (interfaceName != null) {
        LOG.debug("prepareAndSendPacketOut : interfaceName fetched from portTag is {}", interfaceName);
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = null;
        int vlanId = 0;
        iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
        if (iface == null) {
            NaptPacketInHandler.removeIncomingPacketMap(sourceIPPortKey);
            LOG.error("prepareAndSendPacketOut : Unable to read interface {} from config DataStore", interfaceName);
            return;
        }
        IfL2vlan ifL2vlan = iface.augmentation(IfL2vlan.class);
        if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
            vlanId = ifL2vlan.getVlanId().getValue() == null ? 0 : ifL2vlan.getVlanId().getValue().toJava();
        }
        InterfaceInfo infInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
        if (infInfo == null) {
            LOG.error("prepareAndSendPacketOut : error in getting interfaceInfo from Operation DS");
            return;
        }
        dpnID = infInfo.getDpId();
        portNum = infInfo.getPortNo();
        if (ethPkt.getEtherType() != (short) NwConstants.ETHTYPE_802_1Q) {
            // VLAN Access port
            LOG.debug("prepareAndSendPacketOut : vlanId is {}", vlanId);
            if (vlanId != 0) {
                // Push vlan
                actionInfos.add(new ActionPushVlan(0));
                actionInfos.add(new ActionSetFieldVlanVid(1, vlanId));
            } else {
                LOG.debug("prepareAndSendPacketOut : No vlanId {}, may be untagged", vlanId);
            }
        } else {
            // VLAN Trunk Port
            LOG.debug("prepareAndSendPacketOut : This is VLAN Trunk port case - need not do VLAN tagging again");
        }
    } else {
        // This case will be hit for packets send from non-napt switch.
        LOG.info("prepareAndSendPacketOut : interfaceName is not available.Retrieve from packet received");
        NodeConnectorId nodeId = naptEntryEvent.getPacketReceived().getMatch().getInPort();
        portNum = Integer.parseInt(nodeId.getValue());
        LOG.debug("prepareAndSendPacketOut : in_port portNum : {}", portNum);
        // List<PathArgument> dpnNodes = naptEntryEvent.getPacketReceived().getIngress().getValue().getPath();
        Iterable<PathArgument> outArgs = naptEntryEvent.getPacketReceived().getIngress().getValue().getPathArguments();
        PathArgument pathArgument = Iterables.get(outArgs, 2);
        LOG.debug("prepareAndSendPacketOut : pathArgument : {}", pathArgument);
        InstanceIdentifier.IdentifiableItem<?, ?> item = Arguments.checkInstanceOf(pathArgument, InstanceIdentifier.IdentifiableItem.class);
        NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
        LOG.info("prepareAndSendPacketOut : NodeConnectorKey key : {}", key.getId().getValue());
        String dpnKey = key.getId().getValue();
        if (dpnKey.contains(NatConstants.COLON_SEPARATOR)) {
            dpnID = Uint64.valueOf(dpnKey.split(NatConstants.COLON_SEPARATOR)[1]).intern();
        }
    }
    byte[] pktOut = buildNaptPacketOut(ethPkt);
    if (pktOut != null) {
        String routerName = NatUtil.getRouterName(dataBroker, routerId);
        Uint64 tunId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, natOverVxlanUtil, elanManager, idManager, routerId, routerName);
        LOG.info("sendNaptPacketOut for ({}:{}) on dpnId {} portNum {} tunId {}", naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber(), dpnID, portNum, tunId);
        sendNaptPacketOut(pktOut, dpnID, portNum, actionInfos, tunId);
    } else {
        LOG.warn("prepareAndSendPacketOut : Unable to send Packet Out");
    }
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ArrayList (java.util.ArrayList)61 ExecutionException (java.util.concurrent.ExecutionException)47 Test (org.junit.Test)46 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)34 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 BigInteger (java.math.BigInteger)25 Logger (org.slf4j.Logger)25 LoggerFactory (org.slf4j.LoggerFactory)25 List (java.util.List)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)24 ByteBuf (io.netty.buffer.ByteBuf)21 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)21 Collections (java.util.Collections)20 Map (java.util.Map)18 Singleton (javax.inject.Singleton)18 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)18 Inject (javax.inject.Inject)17 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)17