use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState in project genius by opendaylight.
the class FlowBasedServicesUtils method buildBoundServicesState.
public static BoundServicesState buildBoundServicesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState, Class<? extends ServiceModeBase> serviceMode) {
NodeConnectorId nodeConnectorId = IfmUtil.getNodeConnectorIdFromInterface(interfaceState);
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
BoundServicesStateKey boundServicesStateKey = new BoundServicesStateKey(interfaceState.getName(), serviceMode);
return new BoundServicesStateBuilder().setDpid(dpId).setIfIndex(interfaceState.getIfIndex()).setInterfaceName(interfaceState.getName()).setInterfaceType(interfaceState.getType()).setPortNo(portNo).setServiceMode(serviceMode).setKey(boundServicesStateKey).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState 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);
}));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState 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);
}));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState in project genius by opendaylight.
the class FlowBasedIngressServicesConfigBindHelper method bindServiceOnTunnel.
private void bindServiceOnTunnel(List<ListenableFuture<Void>> futures, BoundServices boundServiceNew, List<BoundServices> allServices, BoundServicesState boundServiceState) {
long portNo = boundServiceState.getPortNo();
BigInteger dpId = boundServiceState.getDpid();
LOG.info("binding ingress service {} for tunnel port: {}", boundServiceNew.getServiceName(), boundServiceState.getInterfaceName());
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(boundServiceState.getInterfaceName());
if (allServices.size() == 1) {
// If only one service present, install instructions in table 0.
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable(dpId, portNo);
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew, tx, matches, boundServiceState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
return;
}
boolean isCurrentServiceHighestPriority = true;
Map<Short, BoundServices> tmpServicesMap = new ConcurrentHashMap<>();
short highestPriority = 0xFF;
for (BoundServices boundService : allServices) {
if (boundService.getServicePriority() < boundServiceNew.getServicePriority()) {
isCurrentServiceHighestPriority = false;
break;
}
if (!boundService.equals(boundServiceNew)) {
tmpServicesMap.put(boundService.getServicePriority(), boundService);
if (boundService.getServicePriority() < highestPriority) {
highestPriority = boundService.getServicePriority();
}
}
}
if (!isCurrentServiceHighestPriority) {
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundServiceNew, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), boundServiceNew.getServicePriority(), (short) (boundServiceNew.getServicePriority() + 1));
} else {
BoundServices serviceToReplace = tmpServicesMap.get(highestPriority);
FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, serviceToReplace, boundServiceState.getInterfaceName(), tx, boundServiceState.getIfIndex(), serviceToReplace.getServicePriority(), (short) (serviceToReplace.getServicePriority() + 1));
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable(dpId, portNo);
// Separate transactions to remove and install flows
// TODO Should these be sequential?
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(removeFlowTx -> FlowBasedServicesUtils.removeIngressFlow(iface.getName(), serviceToReplace, dpId, removeFlowTx)));
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(installFlowTransaction -> FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew, installFlowTransaction, matches, boundServiceState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE)));
}
}));
}
Aggregations