Search in sources :

Example 46 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project netvirt by opendaylight.

the class ElanStatisticsImpl method getElanInterfaceStatistics.

@Override
public Future<RpcResult<GetElanInterfaceStatisticsOutput>> getElanInterfaceStatistics(GetElanInterfaceStatisticsInput input) {
    String interfaceName = input.getInterfaceName();
    LOG.debug("getElanInterfaceStatistics is called for elan interface {}", interfaceName);
    RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder = null;
    if (interfaceName == null) {
        rpcResultBuilder = RpcResultBuilder.failed();
        return getFutureWithAppErrorMessage(rpcResultBuilder, "Interface name is not provided");
    }
    Optional<ElanInterface> elanInterface = elanInterfaceCache.get(interfaceName);
    if (!elanInterface.isPresent()) {
        rpcResultBuilder = RpcResultBuilder.failed();
        return getFutureWithAppErrorMessage(rpcResultBuilder, String.format("Interface %s is not a ELAN interface", interfaceName));
    }
    String elanInstanceName = elanInterface.get().getElanInstanceName();
    InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
    // FIXME [ELANBE] Get this API Later
    short tableId = 0;
    // }
    if (!interfaceInfo.isOperational()) {
        LOG.debug("interface {} is down and returning with no statistics", interfaceName);
        rpcResultBuilder = RpcResultBuilder.success();
        return Futures.immediateFuture(rpcResultBuilder.withResult(new GetElanInterfaceStatisticsOutputBuilder().setStatResult(new StatResultBuilder().setStatResultCode(ResultCode.NotFound).setByteRxCount(0L).setByteTxCount(0L).setPacketRxCount(0L).setPacketTxCount(0L).build()).build()).build());
    }
    rpcResultBuilder = RpcResultBuilder.success();
    return Futures.immediateFuture(rpcResultBuilder.withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
}
Also used : GetElanInterfaceStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutput) GetElanInterfaceStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutputBuilder) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) StatResultBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.get.elan._interface.statistics.output.StatResultBuilder) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 47 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project netvirt by opendaylight.

the class DhcpServiceUtils method bindDhcpService.

public static void bindDhcpService(String interfaceName, short tableId, WriteTransaction tx) {
    int instructionKey = 0;
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(tableId, ++instructionKey));
    short serviceIndex = ServiceIndex.getIndex(NwConstants.DHCP_SERVICE_NAME, NwConstants.DHCP_SERVICE_INDEX);
    BoundServices serviceInfo = getBoundServices(String.format("%s.%s", "dhcp", interfaceName), serviceIndex, DhcpMConstants.DEFAULT_FLOW_PRIORITY, DhcpMConstants.COOKIE_VM_INGRESS_TABLE, instructions);
    tx.put(LogicalDatastoreType.CONFIGURATION, buildServiceId(interfaceName, serviceIndex), serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 48 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project netvirt by opendaylight.

the class CountersServiceUtils method createFlowOnTable.

public static Flow createFlowOnTable(Match match, int priority, short tableId, BigInteger cookie, Integer timeout) {
    FlowBuilder fb = new FlowBuilder();
    if (match != null) {
        fb.setMatch(match);
    }
    FlowId flowId = createFlowId();
    fb.setTableId(tableId);
    fb.setIdleTimeout(0).setHardTimeout(0);
    fb.setId(flowId);
    if (timeout != null) {
        fb.setHardTimeout(timeout);
    }
    if (cookie != null) {
        fb.setCookie(new FlowCookie(cookie));
    }
    fb.setPriority(priority);
    Flow flow = fb.build();
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 49 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method testProgramVpnToScfWithVpnIfacesAlreadyBound.

@Test
public void testProgramVpnToScfWithVpnIfacesAlreadyBound() throws Exception {
    // ///////////////////
    // Basic stubbing //
    // ///////////////////
    String ifaceName = "eth0";
    stubGetRouteDistinguisher(VPN_NAME, RD);
    stubGetVpnInstance(RD, "1.2.3.4", ifaceName);
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder("11.12.13.14", 2000L, DC_GW_IP, RouteOrigin.STATIC, null).build();
    stubGetVrfEntries(RD, Collections.singletonList(vrfEntry));
    stubReadVpnToDpnList(RD, DPN_ID, Collections.singletonList(ifaceName));
    stubScfIsBoundOnIface(SCF_TAG, ifaceName);
    // ///////
    // SUT //
    // ///////
    short tableId = 10;
    vpnsch.programVpnToScfPipeline(VPN_NAME, tableId, SCF_TAG, LPORT_TAG, NwConstants.ADD_FLOW);
    // //////////
    // Verify //
    // //////////
    ArgumentCaptor<FlowEntity> argumentCaptor = ArgumentCaptor.forClass(FlowEntity.class);
    verify(mdsalMgr, times(2)).installFlow(argumentCaptor.capture());
    List<FlowEntity> installedFlowsCaptured = argumentCaptor.getAllValues();
    assert installedFlowsCaptured.size() == 2;
    RoutePaths routePath = vrfEntry.getRoutePaths().get(0);
    FlowEntity expectedLFibFlowEntity = VpnServiceChainUtils.buildLFibVpnPseudoPortFlow(DPN_ID, routePath.getLabel(), routePath.getNexthopAddress(), LPORT_TAG);
    assert new FlowEntityMatcher(expectedLFibFlowEntity).matches(installedFlowsCaptured.get(0));
    FlowEntity expectedLPortDispatcher = VpnServiceChainUtils.buildLportFlowDispForVpnToScf(DPN_ID, LPORT_TAG, SCF_TAG, tableId);
    assert new FlowEntityMatcher(expectedLPortDispatcher).matches(installedFlowsCaptured.get(1));
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) FlowEntityMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) Test(org.junit.Test)

Example 50 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project netvirt by opendaylight.

the class ElanDpnInterfacesListener method remove.

@Override
protected void remove(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
    final String elanName = getElanName(identifier);
    BigInteger removeDpnId = dpnInterfaces.getDpId();
    LOG.debug("ELAN interfaces {} removed from on DPN {} for ELAN {}", dpnInterfaces.getInterfaces(), removeDpnId, elanName);
    Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
    if (elanServiceChainState.isPresent()) {
        List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
        for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
            Long scfTag = elanToPseudoPortData.getScfTag();
            Long elanLportTag = elanToPseudoPortData.getElanLportTag();
            if (scfTag != null && elanLportTag != null) {
                handleUpdate(removeDpnId, elanName, (short) 0, /* tableId, ignored in removals */
                elanLportTag.intValue(), /*21 bit*/
                0, /* scfTag, ignored in removals */
                NwConstants.DEL_FLOW);
            } else {
                LOG.debug("One of scfTag or lPortTag is null for ELAN={}:  scfTag={}  lportTag={}", elanName, scfTag, elanLportTag);
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)

Aggregations

BigInteger (java.math.BigInteger)38 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)26 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)17 ByteBuf (io.netty.buffer.ByteBuf)16 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)16 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)15 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)15 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)14 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)14 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)7 Optional (com.google.common.base.Optional)6 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5