use of org.onosproject.net.behaviour.protection.TransportEndpointDescription 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.behaviour.protection.TransportEndpointDescription in project onos by opennetworkinglab.
the class OplinkSwitchProtection method getProtectedTransportEndpointDescription.
/*
* return the protected endpoint description of this devices
*/
private ProtectedTransportEndpointDescription getProtectedTransportEndpointDescription() {
List<TransportEndpointDescription> teds = new ArrayList<>();
FilteredConnectPoint fcpPrimary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), PortNumber.portNumber(PRIMARY_PORT)));
FilteredConnectPoint fcpSecondary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), PortNumber.portNumber(SECONDARY_PORT)));
TransportEndpointDescription tedPrimary = TransportEndpointDescription.builder().withOutput(fcpPrimary).build();
TransportEndpointDescription tedSecondary = TransportEndpointDescription.builder().withOutput(fcpSecondary).build();
teds.add(tedPrimary);
teds.add(tedSecondary);
return ProtectedTransportEndpointDescription.of(teds, getPeerId(), OPLINK_FINGERPRINT);
}
use of org.onosproject.net.behaviour.protection.TransportEndpointDescription in project onos by opennetworkinglab.
the class OplinkSwitchProtection method getProtectedTransportEndpointState.
/*
* get protected endpoint state
*/
private ProtectedTransportEndpointState getProtectedTransportEndpointState() {
List<TransportEndpointState> tess = new ArrayList<>();
PortNumber portPrimary = PortNumber.portNumber(PRIMARY_PORT);
PortNumber portSecondary = PortNumber.portNumber(SECONDARY_PORT);
FilteredConnectPoint fcpPrimary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), portPrimary));
FilteredConnectPoint fcpSecondary = new FilteredConnectPoint(new ConnectPoint(data().deviceId(), portSecondary));
TransportEndpointDescription tedPrimary = TransportEndpointDescription.builder().withOutput(fcpPrimary).build();
TransportEndpointDescription tedSecondary = TransportEndpointDescription.builder().withOutput(fcpSecondary).build();
TransportEndpointState tesPrimary = TransportEndpointState.builder().withDescription(tedPrimary).withId(TransportEndpointId.of(PRIMARY_ID)).addAttributes(getProtectionStateAttributes(portPrimary)).build();
TransportEndpointState tesSecondary = TransportEndpointState.builder().withDescription(tedSecondary).withId(TransportEndpointId.of(SECONDARY_ID)).addAttributes(getProtectionStateAttributes((portSecondary))).build();
tess.add(tesPrimary);
tess.add(tesSecondary);
return ProtectedTransportEndpointState.builder().withDescription(getProtectedTransportEndpointDescription()).withPathStates(tess).withActivePathIndex(getActiveIndex(tess)).build();
}
use of org.onosproject.net.behaviour.protection.TransportEndpointDescription in project onos by opennetworkinglab.
the class TestProtectionEndpointIntentCommand method doExecute.
@Override
protected void doExecute() {
fingerprint = Optional.ofNullable(fingerprint).orElse(DEFAULT_FINGERPRINT);
intentService = get(IntentService.class);
deviceService = get(DeviceService.class);
DeviceId did = DeviceId.deviceId(deviceIdStr);
DeviceId peer = DeviceId.deviceId(peerStr);
ProtectedTransportEndpointDescription description;
List<TransportEndpointDescription> paths = new ArrayList<>();
paths.add(TransportEndpointDescription.builder().withOutput(output(did, portNumber1Str, vlan1Str)).build());
paths.add(TransportEndpointDescription.builder().withOutput(output(did, portNumber2Str, vlan2Str)).build());
description = ProtectedTransportEndpointDescription.of(paths, peer, fingerprint);
ProtectionEndpointIntent intent;
intent = ProtectionEndpointIntent.builder().key(Key.of(fingerprint, appId())).appId(appId()).deviceId(did).description(description).build();
print("Submitting: %s", intent);
intentService.submit(intent);
}
use of org.onosproject.net.behaviour.protection.TransportEndpointDescription in project onos by opennetworkinglab.
the class ProtectionEndpointIntentInstallerTest method createProtectionIntents.
/**
* Creates protection endpoint Intents by givent output point.
*
* @param output the output point
* @return the protection endpoint Intents
*/
private List<Intent> createProtectionIntents(ConnectPoint output) {
FilteredConnectPoint filteredOutput = new FilteredConnectPoint(output);
TransportEndpointDescription path = TransportEndpointDescription.builder().withOutput(filteredOutput).withEnabled(true).build();
List<TransportEndpointDescription> paths = ImmutableList.of(path);
ProtectedTransportEndpointDescription description = ProtectedTransportEndpointDescription.of(paths, CP2.deviceId(), FINGERPRINT);
ProtectionEndpointIntent intent = ProtectionEndpointIntent.builder().appId(APP_ID).description(description).deviceId(CP1.deviceId()).key(KEY1).resourceGroup(RG1).build();
return ImmutableList.of(intent);
}
Aggregations