use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project netvirt by opendaylight.
the class IngressAclServiceImpl method bindService.
/**
* Bind service.
*
* @param aclInterface the acl interface
*/
@Override
public void bindService(AclInterface aclInterface) {
String interfaceName = aclInterface.getInterfaceId();
jobCoordinator.enqueueJob(interfaceName, () -> {
int instructionKey = 0;
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_ACL_DUMMY_TABLE, ++instructionKey));
int flowPriority = NwConstants.EGRESS_ACL_SERVICE_INDEX;
short serviceIndex = ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX);
BoundServices serviceInfo = AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "egressacl", interfaceName), serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName, ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX), serviceMode);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS)));
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project netvirt by opendaylight.
the class GeniusProvider method bindService.
private void bindService(InstanceIdentifier<BoundServices> id, short serviceId, String serviceName, int servicePriority, short serviceDestTable, BigInteger serviceTableCookie, List<Action> extraActions) {
InstructionsBuilder isb = extraActions.isEmpty() ? new InstructionsBuilder() : OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(extraActions);
isb = OpenFlow13Utils.appendGotoTableInstruction(isb, serviceDestTable);
StypeOpenflow stypeOpenflow = new StypeOpenflowBuilder().setFlowCookie(serviceTableCookie).setFlowPriority(servicePriority).setInstruction(isb.build().getInstruction()).build();
BoundServices boundServices = new BoundServicesBuilder().setServiceName(serviceName).setServicePriority(serviceId).setServiceType(ServiceTypeFlowBased.class).addAugmentation(StypeOpenflow.class, stypeOpenflow).build();
LOG.info("Binding Service ID [{}] name [{}] priority [{}] table [{}] cookie [{}] extraActions [{}]", serviceId, serviceName, servicePriority, serviceDestTable, serviceTableCookie, extraActions);
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, id, boundServices);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.
the class FlowBasedIngressServicesStateBindHelper method bindServiceOnVlan.
private void bindServiceOnVlan(WriteTransaction tx, List<BoundServices> allServices, Interface ifState) {
LOG.info("bind all ingress services for vlan port: {}", ifState.getName());
NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(ifState);
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
allServices.sort(Comparator.comparing(BoundServices::getServicePriority));
BoundServices highestPriority = allServices.remove(0);
short nextServiceIndex = (short) (allServices.size() > 0 ? allServices.get(0).getServicePriority() : highestPriority.getServicePriority() + 1);
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, highestPriority, ifState.getName(), tx, ifState.getIfIndex(), NwConstants.DEFAULT_SERVICE_INDEX, nextServiceIndex);
BoundServices prev = null;
for (BoundServices boundService : allServices) {
if (prev != null) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, prev, ifState.getName(), tx, ifState.getIfIndex(), prev.getServicePriority(), boundService.getServicePriority());
}
prev = boundService;
}
if (prev != null) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, prev, ifState.getName(), tx, ifState.getIfIndex(), prev.getServicePriority(), (short) (prev.getServicePriority() + 1));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.
the class FlowBasedIngressServicesStateBindHelper method bindServiceOnTunnel.
private void bindServiceOnTunnel(WriteTransaction tx, List<BoundServices> allServices, Interface ifState) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(ifState.getName());
NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(ifState);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable(dpId, portNo);
BoundServices highestPriorityBoundService = FlowBasedServicesUtils.getHighestPriorityService(allServices);
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, highestPriorityBoundService, tx, matches, ifState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
for (BoundServices boundService : allServices) {
if (!boundService.equals(highestPriorityBoundService)) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundService, ifState.getName(), tx, ifState.getIfIndex(), boundService.getServicePriority(), (short) (boundService.getServicePriority() + 1));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices in project genius by opendaylight.
the class FlowBasedServicesUtils method getHighAndLowPriorityService.
/**
* This utility method returns an array of ServiceInfo in which index 0 will
* have the immediate lower priority service and index 1 will have the
* immediate higher priority service among the list of existing
* serviceInfos.
*
* @param serviceInfos
* list of services bound
* @param currentServiceInfo
* current service bound
* @return array bound services
*/
public static BoundServices[] getHighAndLowPriorityService(List<BoundServices> serviceInfos, BoundServices currentServiceInfo) {
if (serviceInfos == null || serviceInfos.isEmpty()) {
return new BoundServices[] { null, null };
}
// This will be used to hold the immediate higher service priority with respect to the currentServiceInfo
BoundServices higher = null;
// This will be used to hold the immediate lower service priority with respect to the currentServiceInfo
BoundServices lower = null;
List<BoundServices> availableServiceInfos = new ArrayList<>(serviceInfos);
availableServiceInfos.sort(Comparator.comparing(BoundServices::getServicePriority));
for (BoundServices availableServiceInfo : availableServiceInfos) {
if (currentServiceInfo.getServicePriority() < availableServiceInfo.getServicePriority()) {
lower = availableServiceInfo;
break;
} else {
higher = availableServiceInfo;
}
}
return new BoundServices[] { lower, higher };
}
Aggregations