use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match 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.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match 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.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match in project genius by opendaylight.
the class SrmRpcUtils method callSrmOp.
public static ReinstallOutput callSrmOp(DataBroker broker, ReinstallInput input) {
ReinstallOutputBuilder outputBuilder = new ReinstallOutputBuilder();
if (input.getEntityName() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage("EntityName is null");
return outputBuilder.build();
}
if (input.getEntityType() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
if (!EntityTypeService.class.equals(input.getEntityType())) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType is %s, Reinstall is only for EntityTypeService", input.getEntityType()));
return outputBuilder.build();
}
Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
if (serviceName == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s has no matching service", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
Class<? extends EntityTypeBase> entityType = NAME_TO_TYPE_MAP.get(input.getEntityName());
if (entityType == null || !input.getEntityType().equals(entityType)) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s doesn't match with EntityType %s", input.getEntityName().getSimpleName(), entityType));
return outputBuilder.build();
}
OperationsBuilder opsBuilder = new OperationsBuilder().setEntityName(input.getEntityName()).setEntityType(entityType).setTriggerOperation(ServiceOpReinstall.class);
Operations operation = opsBuilder.build();
InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, opsIid, operation, CREATE_MISSING_PARENT);
try {
tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(e.getMessage());
return outputBuilder.build();
}
outputBuilder.setSuccessful(REINSTALL_SUCCESS).setMessage("Recovery operation successfully triggered");
return outputBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match in project bgpcep by opendaylight.
the class PCEPClassTypeObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (!header.isProcessingRule()) {
LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
return null;
}
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes());
}
final ClassTypeBuilder builder = new ClassTypeBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final short ct = (short) bytes.readUnsignedInt();
builder.setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType(ct));
final Object obj = builder.build();
if (ct < 0 || ct > Byte.SIZE) {
LOG.debug("Invalid class type {}", ct);
return new UnknownObject(PCEPErrors.INVALID_CT, obj);
}
return obj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest method testParseMpUnreachNlri.
@Test
public void testParseMpUnreachNlri() throws BGPParsingException {
final List<Flowspec> fs = new ArrayList<>();
final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
final FlowspecBuilder builder = new FlowspecBuilder();
final FragmentCase fragment = createFragment();
builder.setFlowspecType(fragment);
fs.add(builder.build());
final FlowspecType label = createLabel();
builder.setFlowspecType(label);
fs.add(builder.build());
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv6();
final List<Flowspec> flows = flowspecDst.getFlowspec();
final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
assertEquals(2, flows.size());
assertEquals(ROUTE_DISTINGUISHER, new String(rd.getValue()));
assertEquals(fragment, flows.get(0).getFlowspecType());
assertEquals(label, flows.get(1).getFlowspecType());
mp.setAfi(Ipv6AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setFlowspec(fs).build()).build()).build());
final ByteBuf buffer = Unpooled.buffer();
this.FS_PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to 16777222 or equals to 258 ", this.FS_PARSER.stringNlri(flows));
}
Aggregations