Search in sources :

Example 21 with Config

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.rev170830.Config in project netvirt by opendaylight.

the class StatisticsImpl method cleanAllElementCounterRequests.

@Override
public Future<RpcResult<CleanAllElementCounterRequestsOutput>> cleanAllElementCounterRequests(CleanAllElementCounterRequestsInput input) {
    ReadOnlyTransaction 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");
            StatisticsPluginImplCounters.failed_reading_counter_data_from_config.inc();
            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();
    }
    return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>success().buildFuture();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(com.google.common.base.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) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 22 with Config

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.rev170830.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 (ReadOnlyTransaction 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");
            StatisticsPluginImplCounters.failed_reading_counter_data_from_config.inc();
            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");
        StatisticsPluginImplCounters.failed_getting_counter_results_port_removal.inc();
        return;
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(com.google.common.base.Optional) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 23 with Config

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.rev170830.Config in project netvirt by opendaylight.

the class StatisticsImpl method initializeCountrsConfigDataSrore.

private void initializeCountrsConfigDataSrore() {
    ReadWriteTransaction transaction = db.newReadWriteTransaction();
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
    try {
        Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
        if (!iecrcOpt.isPresent()) {
            creatIngressEelementCountersContainerInConfig(transaction, CountersServiceUtils.IECRC_IDENTIFIER);
        }
        Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
        if (!eecrcOpt.isPresent()) {
            creatEgressEelementCountersContainerInConfig(transaction, CountersServiceUtils.EECRC_IDENTIFIER);
        }
        transaction.submit();
    } catch (InterruptedException | ExecutionException e) {
        StatisticsPluginImplCounters.failed_creating_counters_config.inc();
        LOG.warn("failed creating counters config data structure in DB");
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(com.google.common.base.Optional) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 24 with Config

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.rev170830.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;
            }
            List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
            for (VrfTables vrfTable : staleVrfTables) {
                String rd = vrfTable.getRouteDistinguisher();
                if (vrfTable.getVrfEntry() != null) {
                    for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
                        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()) {
                        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 (ReadFailedException e) {
        LOG.error("deleteExternalFibRoutes:: error ", e);
    }
    LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
}
Also used : 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) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) 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)

Example 25 with Config

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.rev170830.Config in project netvirt by opendaylight.

the class NaptEventHandler method prepareAndSendPacketOut.

private void prepareAndSendPacketOut(NAPTEntryEvent naptEntryEvent, Long routerId) {
    // Send Packetout - tcp or udp packets which got punted to controller.
    BigInteger 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 * NetUtils.NUM_BITS_IN_A_BYTE);
        } catch (PacketException e) {
            LOG.error("prepareAndSendPacketOut : Failed to decode Packet", e);
            return;
        }
    }
    long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
    LOG.debug("prepareAndSendPacketOut : portTag from incoming packet is {}", portTag);
    String interfaceName = getInterfaceNameFromTag(portTag);
    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) {
        LOG.error("prepareAndSendPacketOut : Unable to read interface {} from config DataStore", interfaceName);
        return;
    }
    List<ActionInfo> actionInfos = new ArrayList<>();
    IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
    if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
        vlanId = ifL2vlan.getVlanId().getValue() == null ? 0 : ifL2vlan.getVlanId().getValue();
    }
    InterfaceInfo infInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
    if (infInfo == null) {
        LOG.error("prepareAndSendPacketOut : error in getting interfaceInfo from Operation DS");
        return;
    }
    byte[] pktOut = buildNaptPacketOut(ethPkt);
    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");
    }
    if (pktOut != null) {
        String routerName = NatUtil.getRouterName(dataBroker, routerId);
        long tunId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId, routerName);
        sendNaptPacketOut(pktOut, infInfo, actionInfos, tunId);
    } else {
        LOG.warn("prepareAndSendPacketOut : Unable to send Packet Out");
    }
}
Also used : ArrayList(java.util.ArrayList) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Aggregations

ArrayList (java.util.ArrayList)47 Test (org.junit.Test)46 BigInteger (java.math.BigInteger)29 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)23 ByteBuf (io.netty.buffer.ByteBuf)21 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)21 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)20 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)19 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)16 ExecutionException (java.util.concurrent.ExecutionException)16 Optional (com.google.common.base.Optional)15 List (java.util.List)15 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)14 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)14 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)12 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)12