Search in sources :

Example 56 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method checkVlanApis.

private void checkVlanApis() throws Exception {
    // 1. Test port-no corresponding to interface
    long portNo = interfaceManager.getPortForInterface(INTERFACE_NAME);
    Assert.assertEquals(PORT_NO_1, portNo);
    // 2. fetch interface config from datastore API
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = interfaceManager.getInterfaceInfoFromConfigDataStore(INTERFACE_NAME);
    // FIXME change this once augmentation sorting fix lands
    assertEqualBeans(INTERFACE_NAME, interfaceInfo.getName());
    assertEqualBeans(PARENT_INTERFACE, interfaceInfo.getAugmentation(ParentRefs.class).getParentInterface());
    // 3. fetch dpn-id corresponding to an interface
    BigInteger dpnId = interfaceManager.getDpnForInterface(INTERFACE_NAME);
    Assert.assertEquals(DPN_ID_1, dpnId);
    // 4. fetch parent-interface corresponding to an interface
    Assert.assertEquals(PARENT_INTERFACE, interfaceManager.getParentRefNameForInterface(INTERFACE_NAME));
    // 5. get interface information
    assertEqualBeans(ExpectedInterfaceInfo.newVlanInterfaceInfo(), interfaceManager.getInterfaceInfo(INTERFACE_NAME));
    Assert.assertEquals(org.opendaylight.genius.interfacemanager.globals.IfmConstants.VXLAN_GROUPID_MIN + 1, interfaceManager.getLogicalTunnelSelectGroupId(1));
    // 6. Test bind ingress service
    BoundServices serviceInfo = InterfaceManagerTestUtil.buildServicesInfo("ELAN", NwConstants.ELAN_SERVICE_INDEX);
    interfaceManager.bindService(INTERFACE_NAME, ServiceModeIngress.class, serviceInfo);
    waitTillOperationCompletes("test bind ingress service api", coordinatorEventsWaiter, 1, asyncEventsWaiter);
    String lportDispatcherFlowRef = String.valueOf(dpnId) + NwConstants.FLOWID_SEPARATOR + NwConstants.LPORT_DISPATCHER_TABLE + NwConstants.FLOWID_SEPARATOR + INTERFACE_NAME + NwConstants.FLOWID_SEPARATOR + NwConstants.DEFAULT_SERVICE_INDEX;
    FlowKey lportDispatcherFlowKey = new FlowKey(new FlowId(lportDispatcherFlowRef));
    Node nodeDpn = InterfaceManagerTestUtil.buildInventoryDpnNode(dpnId);
    InstanceIdentifier<Flow> lportDispatcherFlowId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.LPORT_DISPATCHER_TABLE)).child(Flow.class, lportDispatcherFlowKey).build();
    flowAssertTestUtils.assertFlowsInAnyOrder(ExpectedFlowEntries.newLportDispatcherFlow(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, lportDispatcherFlowId).checkedGet().get());
    // check whether service-binding state cache is populated
    assertEqualBeans(ExpectedBoundServiceState.newBoundServiceState(), FlowBasedServicesUtils.getBoundServicesState(dataBroker.newReadOnlyTransaction(), INTERFACE_NAME, ServiceModeIngress.class));
    // 7. test check whether service is bound on ingress
    Assert.assertTrue(interfaceManager.isServiceBoundOnInterfaceForIngress(NwConstants.ELAN_SERVICE_INDEX, INTERFACE_NAME));
    // 8. test unbind ingress service
    interfaceManager.unbindService(INTERFACE_NAME, ServiceModeIngress.class, serviceInfo);
    waitTillOperationCompletes("test unbind ingress service api", coordinatorEventsWaiter, 2, asyncEventsWaiter);
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, lportDispatcherFlowId).get());
    // check service-state cache is cleaned up
    // 9. Test bind egress service
    short egressACLIndex = ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX);
    serviceInfo = InterfaceManagerTestUtil.buildServicesInfo("EGRESS_ACL", egressACLIndex);
    interfaceManager.bindService(INTERFACE_NAME, ServiceModeEgress.class, serviceInfo);
    waitTillOperationCompletes("test bind egress service api", coordinatorEventsWaiter, 1, asyncEventsWaiter);
    String egressDispatcherFlowRef = String.valueOf(dpnId) + NwConstants.FLOWID_SEPARATOR + NwConstants.EGRESS_LPORT_DISPATCHER_TABLE + NwConstants.FLOWID_SEPARATOR + INTERFACE_NAME + NwConstants.FLOWID_SEPARATOR + NwConstants.DEFAULT_EGRESS_SERVICE_INDEX;
    FlowKey egressDispatcherFlowKey = new FlowKey(new FlowId(egressDispatcherFlowRef));
    InstanceIdentifier<Flow> egressDispatcherFlowId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE)).child(Flow.class, egressDispatcherFlowKey).build();
    // FIXME the extend file getting generated had some import issues, will revist  later
    // assertEqualBeans(null,
    // dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).checkedGet().get());
    Assert.assertNotNull(dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).checkedGet().get());
    // 10. test check whether service is bound on egress
    Assert.assertTrue(interfaceManager.isServiceBoundOnInterfaceForEgress(NwConstants.EGRESS_ACL_SERVICE_INDEX, INTERFACE_NAME));
    // 11. Test unbinding of egress service
    interfaceManager.unbindService(INTERFACE_NAME, ServiceModeEgress.class, serviceInfo);
    waitTillOperationCompletes("test unbind egress service api", coordinatorEventsWaiter, 2, asyncEventsWaiter);
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).get());
    // 12. Test fetching child interfaces of an interface
    // FIXME change the below assert once sorted augmentation fix lands
    assertEqualBeans(INTERFACE_NAME, interfaceManager.getChildInterfaces(PARENT_INTERFACE).get(0).getName());
    // 13. Test fetching interface-info from operational DS
    assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, PARENT_INTERFACE, null), interfaceManager.getInterfaceInfoFromOperationalDataStore(INTERFACE_NAME));
    // 14. Test fetching of interface-info from oper DS, given interface-type
    assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, INTERFACE_NAME, InterfaceInfo.InterfaceType.VLAN_INTERFACE), interfaceManager.getInterfaceInfoFromOperationalDataStore(INTERFACE_NAME, InterfaceInfo.InterfaceType.VLAN_INTERFACE));
    // 15.Test fetching of interface-info from cache
    assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, PARENT_INTERFACE, null), interfaceManager.getInterfaceInfoFromOperationalDSCache(INTERFACE_NAME));
    // 16. Test creation of VLAN interface
    // FIXME Make IInterfaceManager truly async
    interfaceManager.createVLANInterface(INTERFACE_NAME_1, PARENT_INTERFACE_1, null, INTERFACE_NAME_1, IfL2vlan.L2vlanMode.Trunk);
    // waitTillOperationCompletes(coordinatorEventsWaiter, 1, asyncEventsWaiter);
    // assertEqualBeans(ExpectedInterfaceConfig.newVlanInterfaceConfig(INTERFACE_NAME_1, null),
    // dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(
    // INTERFACE_NAME_1)).checkedGet().get());
    // 17. Update Parent Refs for VLAN interface
    // FIXME Make IInterfaceManager truly async
    // interfaceManager.updateInterfaceParentRef(INTERFACE_NAME_1, PARENT_INTERFACE_1);
    waitTillOperationCompletes("create vlan interface api", coordinatorEventsWaiter, 4, asyncEventsWaiter);
    assertEqualBeans(ExpectedInterfaceConfig.newVlanInterfaceConfig(INTERFACE_NAME_1, PARENT_INTERFACE_1), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(INTERFACE_NAME_1)).checkedGet().get());
    // 18. Test creation of external l2vlan interfaces
    // FIXME Make IInterfaceManager truly async
    interfaceManager.createVLANInterface(INTERFACE_NAME_2, PARENT_INTERFACE_2, null, INTERFACE_NAME_2, IfL2vlan.L2vlanMode.Trunk, true);
    // waitTillOperationCompletes(coordinatorEventsWaiter, 1, asyncEventsWaiter);
    // FIXME need to wait for https://git.opendaylight.org/gerrit/#/c/54811/ this to land
    // to do proper assertion
    // Assert.assertNotNull(dataBroker
    // .newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil
    // .buildId(INTERFACE_NAME_2)).checkedGet().get().getAugmentation(IfExternal.class));
    // 19. update parent-refs
    // interfaceManager.updateInterfaceParentRef(INTERFACE_NAME_2, PARENT_INTERFACE_2, true);
    waitTillOperationCompletes("create external vlan interface api", coordinatorEventsWaiter, 4, asyncEventsWaiter);
    Assert.assertEquals(PARENT_INTERFACE_2, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(INTERFACE_NAME_2)).checkedGet().get().getAugmentation(ParentRefs.class).getParentInterface());
    // 20. get list of vlan interfaces
    // FIXME need to wait for https://git.opendaylight.org/gerrit/#/c/54811/ this to land
    // to do proper assertion
    assertEqualBeans(3, interfaceManager.getVlanInterfaces().size());
    // 21. check if an interface is external interface
    Assert.assertTrue(interfaceManager.isExternalInterface(INTERFACE_NAME_2));
    // 22. check port name for an interface, given dpn-id and interface-name
    assertEqualBeans(PARENT_INTERFACE, interfaceManager.getPortNameForInterface(DPN_ID_1.toString(), PARENT_INTERFACE));
    // 23. check port name for an interface, given nodeconnectorid
    assertEqualBeans(PARENT_INTERFACE, interfaceManager.getPortNameForInterface(new NodeConnectorId("openflow:1:2"), PARENT_INTERFACE));
    // 24. get termination-points from cache
    Assert.assertNotNull(interfaceManager.getTerminationPointCache().get(INTERFACE_NAME));
    // 25. fetch termination point for interface
    assertEqualBeans(ExpectedTerminationPoint.newOvsdbTerminationPointAugmentation(), interfaceManager.getTerminationPointForInterface(INTERFACE_NAME));
    // 26. fetch ovsdb bridge corresponding to an interface
    assertEqualBeans(ExpectedOvsdbBridge.newOvsdbBridge(), interfaceManager.getOvsdbBridgeForInterface(INTERFACE_NAME));
    // 27. fetch ovsdb bridge corresponding to nodeIid
    assertEqualBeans(ExpectedOvsdbBridge.newOvsdbBridge(), interfaceManager.getOvsdbBridgeForNodeIid(OvsdbSouthboundTestUtil.createInstanceIdentifier("192.168.56.101", 6640, "s2")));
}
Also used : FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) BigInteger(java.math.BigInteger)

Example 57 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project genius by opendaylight.

the class ItmManagerRpcService method createTerminatingServiceActions.

@Override
public Future<RpcResult<java.lang.Void>> createTerminatingServiceActions(final CreateTerminatingServiceActionsInput input) {
    LOG.info("create terminatingServiceAction on DpnId = {} for service id {} and instructions {}", input.getDpnId(), input.getServiceId(), input.getInstruction());
    final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
    int serviceId = input.getServiceId();
    final List<MatchInfo> mkMatches = getTunnelMatchesForServiceId(serviceId);
    Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, serviceId), 5, String.format("%s:%d", "ITM Flow Entry ", serviceId), 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(serviceId)), mkMatches, input.getInstruction());
    ListenableFuture<Void> installFlowResult = mdsalManager.installFlow(input.getDpnId(), terminatingServiceTableFlow);
    Futures.addCallback(installFlowResult, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void voidInstance) {
            result.set(RpcResultBuilder.<Void>success().build());
        }

        @Override
        public void onFailure(Throwable error) {
            String msg = String.format("Unable to install terminating service flow for %s", input.getDpnId());
            LOG.error("create terminating service actions failed. {}", msg, error);
            result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
        }
    }, MoreExecutors.directExecutor());
    // result.set(RpcResultBuilder.<Void>success().build());
    return result;
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 58 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project genius by opendaylight.

the class AlivenessMonitor method createIdPool.

private void createIdPool() {
    CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(AlivenessMonitorConstants.MONITOR_IDPOOL_NAME).setLow(AlivenessMonitorConstants.MONITOR_IDPOOL_START).setHigh(AlivenessMonitorConstants.MONITOR_IDPOOL_SIZE).build();
    Future<RpcResult<Void>> resultFuture = idManager.createIdPool(createPool);
    Futures.addCallback(JdkFutureAdapters.listenInPoolThread(resultFuture), new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onFailure(Throwable error) {
            LOG.error("Failed to create idPool for Aliveness Monitor Service", error);
        }

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.debug("Created IdPool for Aliveness Monitor Service");
            } else {
                LOG.error("RPC to create Idpool failed {}", result.getErrors());
            }
        }
    }, callbackExecutorService);
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)

Example 59 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project genius by opendaylight.

the class FlowBasedEgressServicesConfigBindHelper method bindServiceOnInterface.

@Override
protected void bindServiceOnInterface(List<ListenableFuture<Void>> futures, BoundServices boundServiceNew, List<BoundServices> allServices, BoundServicesState boundServiceState) {
    BigInteger dpId = boundServiceState.getDpid();
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(boundServiceState.getInterfaceName());
        LOG.info("binding egress service {} for interface: {}", boundServiceNew.getServiceName(), boundServiceState.getInterfaceName());
        if (allServices.size() == 1) {
            // calling LportDispatcherTableForService with current service index
            // as 0 and next service index as
            // some value since this is the only service bound.
            FlowBasedServicesUtils.installEgressDispatcherFlows(dpId, boundServiceNew, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, (short) (boundServiceNew.getServicePriority() + 1), iface);
            return;
        }
        allServices.remove(boundServiceNew);
        BoundServices[] highLowPriorityService = FlowBasedServicesUtils.getHighAndLowPriorityService(allServices, boundServiceNew);
        BoundServices low = highLowPriorityService[0];
        BoundServices high = highLowPriorityService[1];
        BoundServices highest = FlowBasedServicesUtils.getHighestPriorityService(allServices);
        short currentServiceIndex = NwConstants.DEFAULT_SERVICE_INDEX;
        short nextServiceIndex = ServiceIndex.getIndex(NwConstants.DEFAULT_EGRESS_SERVICE_NAME, // dummy service
        NwConstants.DEFAULT_EGRESS_SERVICE_INDEX);
        // index
        if (low != null) {
            nextServiceIndex = low.getServicePriority();
            if (low.equals(highest)) {
                // In this case the match criteria of existing service should be
                // changed.
                BoundServices lower = FlowBasedServicesUtils.getHighAndLowPriorityService(allServices, low)[0];
                short lowerServiceIndex = (short) (lower != null ? lower.getServicePriority() : low.getServicePriority() + 1);
                LOG.trace("Installing egress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", low, low.getServicePriority(), lowerServiceIndex);
                FlowBasedServicesUtils.installEgressDispatcherFlows(dpId, low, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), low.getServicePriority(), lowerServiceIndex, iface);
            } else {
                currentServiceIndex = boundServiceNew.getServicePriority();
            }
        }
        if (high != null) {
            currentServiceIndex = boundServiceNew.getServicePriority();
            if (high.equals(highest)) {
                LOG.trace("Installing egress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", high, NwConstants.DEFAULT_SERVICE_INDEX, currentServiceIndex);
                FlowBasedServicesUtils.installEgressDispatcherFlows(dpId, high, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, currentServiceIndex, iface);
            } else {
                LOG.trace("Installing egress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", high, high.getServicePriority(), currentServiceIndex);
                FlowBasedServicesUtils.installEgressDispatcherFlows(dpId, high, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), high.getServicePriority(), currentServiceIndex, iface);
            }
        }
        LOG.trace("Installing egress dispatcher table entry " + "for new service match on service index {} update with service index {}", currentServiceIndex, nextServiceIndex);
        FlowBasedServicesUtils.installEgressDispatcherFlows(dpId, boundServiceNew, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), currentServiceIndex, nextServiceIndex, iface);
    }));
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) ServiceIndex(org.opendaylight.genius.utils.ServiceIndex) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BoundServicesState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) FlowBasedServicesUtils(org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 60 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project genius by opendaylight.

the class FlowBasedIngressServicesConfigBindHelper method bindServiceOnVlan.

private void bindServiceOnVlan(List<ListenableFuture<Void>> futures, BoundServices boundServiceNew, List<BoundServices> allServices, BoundServicesState boundServiceState) {
    BigInteger dpId = boundServiceState.getDpid();
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        LOG.info("binding ingress service {} for vlan port: {}", boundServiceNew.getServiceName(), boundServiceState.getInterfaceName());
        if (allServices.size() == 1) {
            // calling LportDispatcherTableForService with current service index
            // as 0 and next service index as some value since this is the only
            // service bound.
            FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundServiceNew, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, (short) (boundServiceNew.getServicePriority() + 1));
            return;
        }
        allServices.remove(boundServiceNew);
        BoundServices[] highLowPriorityService = FlowBasedServicesUtils.getHighAndLowPriorityService(allServices, boundServiceNew);
        BoundServices low = highLowPriorityService[0];
        BoundServices high = highLowPriorityService[1];
        BoundServices highest = FlowBasedServicesUtils.getHighestPriorityService(allServices);
        short currentServiceIndex = NwConstants.DEFAULT_SERVICE_INDEX;
        // dummy
        short nextServiceIndex = (short) (boundServiceNew.getServicePriority() + 1);
        // index
        if (low != null) {
            nextServiceIndex = low.getServicePriority();
            if (low.equals(highest)) {
                // In this case the match criteria of existing service should be
                // changed.
                BoundServices lower = FlowBasedServicesUtils.getHighAndLowPriorityService(allServices, low)[0];
                short lowerServiceIndex = (short) (lower != null ? lower.getServicePriority() : low.getServicePriority() + 1);
                LOG.trace("Installing ingress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", low, low.getServicePriority(), lowerServiceIndex);
                FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, low, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), low.getServicePriority(), lowerServiceIndex);
            } else {
                currentServiceIndex = boundServiceNew.getServicePriority();
            }
        }
        if (high != null) {
            currentServiceIndex = boundServiceNew.getServicePriority();
            if (high.equals(highest)) {
                LOG.trace("Installing ingress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", high, NwConstants.DEFAULT_SERVICE_INDEX, currentServiceIndex);
                FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, high, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, currentServiceIndex);
            } else {
                LOG.trace("Installing ingress dispatcher table entry for existing service {} service match on " + "service index {} update with service index {}", high, high.getServicePriority(), currentServiceIndex);
                FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, high, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), high.getServicePriority(), currentServiceIndex);
            }
        }
        LOG.trace("Installing ingress dispatcher table entry for new service match on service index {} update with " + "service index {}", currentServiceIndex, nextServiceIndex);
        FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundServiceNew, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), currentServiceIndex, nextServiceIndex);
    }));
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) List(java.util.List) Map(java.util.Map) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) BoundServicesState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) FlowBasedServicesUtils(org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) BigInteger(java.math.BigInteger)

Aggregations

ArrayList (java.util.ArrayList)36 BigInteger (java.math.BigInteger)33 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 ExecutionException (java.util.concurrent.ExecutionException)19 CoreException (org.eclipse.core.runtime.CoreException)18 List (java.util.List)15 Test (org.junit.Test)15 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)15 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 BoundServices (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)12 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)9