use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PathComputationImpl method getSourceVertexKey.
private VertexKey getSourceVertexKey(final EndpointsObj endPoints) {
IpAddress address = null;
if (endPoints.getAddressFamily() instanceof Ipv4Case) {
address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getSourceIpv4Address());
}
if (endPoints.getAddressFamily() instanceof Ipv6Case) {
address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getSourceIpv6Address());
}
if (address == null) {
return null;
}
ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
LOG.debug("Compute path from Source {}", vertex != null ? vertex : "Unknown");
return vertex != null ? vertex.getVertex().key() : null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PathComputationImpl method computeEro.
@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
VertexKey source = getSourceVertexKey(endpoints);
VertexKey destination = getDestinationVertexKey(endpoints);
if (source == null) {
return null;
}
if (destination == null) {
return null;
}
/* Create new Constraints Object from the request */
PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
/* Determine Path Computation Algorithm according to parameters */
AlgorithmType algoType;
if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
algoType = AlgorithmType.Spf;
} else if (cts.getDelay() == null) {
algoType = AlgorithmType.Cspf;
} else {
algoType = AlgorithmType.Samcra;
}
PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
if (algo == null) {
return null;
}
/*
* Request Path Computation for given source, destination and
* constraints
*/
final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
LOG.info("Computed ERO: {}", cpath.getPathDescription());
/* Check if we got a valid Path and return appropriate ERO */
if (cpath.getStatus() == ComputationStatus.Completed) {
return MessagesUtil.getEro(cpath.getPathDescription());
} else {
return null;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getRequests.
protected List<Requests> getRequests(final Queue<Object> objects, final List<Message> errors) {
final List<Requests> requests = new ArrayList<>();
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (!(obj instanceof Rp)) {
// if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
return null;
}
final RequestsBuilder rBuilder = new RequestsBuilder();
final Rp rpObj = (Rp) obj;
objects.remove();
if (rpObj.getProcessingRule()) {
rBuilder.setRp(rpObj);
} else {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
if (rpObj.getPathKey()) {
// FIXME: this can fail on malformed messages (i.e. objects.isEmpty()), add an explicit check/error
obj = objects.element();
if (obj instanceof PathKey) {
// FIXME: shouldn't we be also removing the object?
rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) obj).build());
}
}
obj = objects.peek();
if (!(obj instanceof EndpointsObj)) {
errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
return null;
}
if (!rpObj.getP2mp()) {
// p2p
// FIXME: explicit check for empty/type?
final EndpointsObj ep = (EndpointsObj) objects.remove();
final P2pBuilder p2pBuilder = new P2pBuilder();
if (!ep.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
} else {
p2pBuilder.setEndpointsObj(ep);
}
final SegmentComputation segm = getP2PSegmentComputation(p2pBuilder, objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
} else {
// p2mp
final SegmentComputation segm = getP2MPSegmentComputation(objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
}
requests.add(rBuilder.build());
}
return requests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method insertP2MPObject.
private static P2MPState insertP2MPObject(final P2MPState p2MPState, final Queue<Object> objects, final P2mpBuilder builder, final List<EndpointRroPair> epRros, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.Metric> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.element();
switch(p2MPState) {
case RP:
if (obj instanceof EndpointsObj) {
final EndpointRroPairBuilder rroPairBuilder = new EndpointRroPairBuilder();
if (obj.getProcessingRule()) {
rroPairBuilder.setEndpointsObj((EndpointsObj) obj);
} else {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
}
epRros.add(rroPairBuilder.setRros(new ArrayList<>()).build());
return P2MPState.ENDPOINT;
}
// fallthrough
case ENDPOINT:
if (obj instanceof Rro || obj instanceof Srro) {
if (obj.getProcessingRule()) {
final int lastIndex = epRros.size() - 1;
final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
List<Rros> rros = endpointRroPair.getRros();
if (rros == null) {
rros = new ArrayList<>();
}
if (obj instanceof Rro) {
rros.add(new RrosBuilder().setRouteObject(new ReportedRouteObjectCaseBuilder().setRro((Rro) obj).build()).build());
} else {
rros.add(new RrosBuilder().setRouteObject(new SecondaryReportedRouteObjectCaseBuilder().setSrro((Srro) obj).build()).build());
}
epRros.remove(lastIndex);
epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setRros(rros).build());
}
return P2MPState.ENDPOINT;
}
// fallthrough
case RRO_SRRO:
if (obj instanceof ReoptimizationBandwidth) {
final int lastIndex = epRros.size() - 1;
final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
epRros.remove(lastIndex);
epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setReoptimizationBandwidth((ReoptimizationBandwidth) obj).build());
return P2MPState.BANDWIDTH;
}
// fallthrough
case BANDWIDTH:
if (obj instanceof EndpointsObj) {
return P2MPState.RP;
}
if (obj instanceof Of) {
builder.setOf((Of) obj);
return P2MPState.OF_IN;
}
// fallthrough
case OF_IN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return P2MPState.LSPA_IN;
}
// fallthrough
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return P2MPState.BANDWIDTH_IN;
}
// fallthrough
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricBuilder().setMetric((Metric) obj).build());
return P2MPState.BANDWIDTH_IN;
}
// fallthrough
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIroBncChoice(new IroCaseBuilder().setIro((Iro) obj).build());
return P2MPState.IRO_BNC_IN;
}
if (obj instanceof BranchNodeList) {
builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new BranchNodeCaseBuilder().setBranchNodeList((BranchNodeList) obj).build()).build());
return P2MPState.IRO_BNC_IN;
}
if (obj instanceof NonBranchNodeList) {
builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new NonBranchNodeCaseBuilder().setNonBranchNodeList((NonBranchNodeList) obj).build()).build());
return P2MPState.IRO_BNC_IN;
}
// fallthrough
case IRO_BNC_IN:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return P2MPState.LOAD_BIN;
}
// fallthrough
case LOAD_BIN:
case END:
default:
return P2MPState.END;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseObject.
@Test
public void testParseObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4AddressNoZone(IP1)));
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4AddressNoZone(IP2)));
final EndpointsObj output = (EndpointsObj) new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
assertEquals(IP1, ((Ipv4Case) output.getAddressFamily()).getIpv4().getSourceIpv4Address().getValue());
assertEquals(IP2, ((Ipv4Case) output.getAddressFamily()).getIpv4().getDestinationIpv4Address().getValue());
assertFalse(output.getIgnore());
assertFalse(output.getProcessingRule());
}
Aggregations