use of org.onosproject.net.intent.ProtectedTransportIntent in project onos by opennetworkinglab.
the class ProtectedTransportIntentCompiler method createFreshProtectedPaths.
/**
* Creates new protected paths.
*
* @param intent original intention
* @param did1 identifier of first device
* @param did2 identifier of second device
* @return compilation result
* @throws IntentCompilationException when there's no satisfying path.
*/
private List<Intent> createFreshProtectedPaths(ProtectedTransportIntent intent, DeviceId did1, DeviceId did2) {
DisjointPath disjointPath = getDisjointPath(intent, did1, did2);
if (disjointPath == null || disjointPath.backup() == null) {
log.error("Unable to find disjoint path between {}, {}", did1, did2);
throw new IntentCompilationException("Unable to find disjoint paths.");
}
Path primary = disjointPath.primary();
Path secondary = disjointPath.backup();
String fingerprint = intent.key().toString();
// pick and allocate Vlan to use as S-tag
Pair<VlanId, VlanId> vlans = allocateEach(intent, primary, secondary, VlanId.class);
VlanId primaryVlan = vlans.getLeft();
VlanId secondaryVlan = vlans.getRight();
// Build edge Intents for head/tail
// resource for head/tail
Collection<NetworkResource> oneResources = new ArrayList<>();
Collection<NetworkResource> twoResources = new ArrayList<>();
List<TransportEndpointDescription> onePaths = new ArrayList<>();
onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.src(), primaryVlan)).build());
onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.src(), secondaryVlan)).build());
List<TransportEndpointDescription> twoPaths = new ArrayList<>();
twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.dst(), primaryVlan)).build());
twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.dst(), secondaryVlan)).build());
ProtectionEndpointIntent oneIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).priority(intent.priority()).resources(oneResources).deviceId(did1).description(buildDescription(onePaths, did2, fingerprint)).build();
ProtectionEndpointIntent twoIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).resources(twoResources).deviceId(did2).description(buildDescription(twoPaths, did1, fingerprint)).build();
// Build transit intent for primary/secondary path
Collection<NetworkResource> resources1 = ImmutableList.of(marker("protection1"));
Collection<NetworkResource> resources2 = ImmutableList.of(marker("protection2"));
ImmutableList<Intent> result = ImmutableList.<Intent>builder().addAll(createTransitIntent(intent, primary, primaryVlan, resources1)).addAll(createTransitIntent(intent, secondary, secondaryVlan, resources2)).add(oneIntent).add(twoIntent).build();
log.trace("createFreshProtectedPaths result: {}", result);
return result;
}
use of org.onosproject.net.intent.ProtectedTransportIntent in project onos by opennetworkinglab.
the class ProtectedTransportIntentCompiler method compile.
@Override
public List<Intent> compile(ProtectedTransportIntent intent, List<Intent> installable) {
log.trace("compiling {} {}", intent, installable);
// case 0 hop, same device
final DeviceId did1 = intent.one();
final DeviceId did2 = intent.two();
if (Objects.equals(did1, did2)) {
// Doesn't really make sense to create 0 hop protected path, but
// can generate Flow for the device, just to provide connectivity.
// future work.
log.error("0 hop not supported yet.");
throw new IntentCompilationException("0 hop not supported yet.");
}
List<Intent> reusable = Optional.ofNullable(installable).orElse(ImmutableList.of()).stream().filter(this::isIntact).collect(Collectors.toList());
if (reusable.isEmpty() || reusable.stream().allMatch(ProtectionEndpointIntent.class::isInstance)) {
// case re-compilation (total failure -> restoration)
return createFreshProtectedPaths(intent, did1, did2);
} else {
// case re-compilation (partial failure)
log.warn("Re-computing adding new backup path not supported yet. No-Op.");
// TODO do we need to prune broken
return installable;
}
}
Aggregations