Search in sources :

Example 1 with TransportEndpointDescription

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;
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) ArrayList(java.util.ArrayList) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) ProtectedTransportIntent(org.onosproject.net.intent.ProtectedTransportIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) NetworkResource(org.onosproject.net.NetworkResource) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) DisjointPath(org.onosproject.net.DisjointPath) VlanId(org.onlab.packet.VlanId)

Example 2 with TransportEndpointDescription

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);
}
Also used : ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 3 with TransportEndpointDescription

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();
}
Also used : ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) TransportEndpointState(org.onosproject.net.behaviour.protection.TransportEndpointState) ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ArrayList(java.util.ArrayList) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 4 with TransportEndpointDescription

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);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) DeviceId(org.onosproject.net.DeviceId) DeviceService(org.onosproject.net.device.DeviceService) ArrayList(java.util.ArrayList) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent)

Example 5 with TransportEndpointDescription

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);
}
Also used : ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) ProtectedTransportEndpointDescription(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

TransportEndpointDescription (org.onosproject.net.behaviour.protection.TransportEndpointDescription)5 ArrayList (java.util.ArrayList)4 ProtectedTransportEndpointDescription (org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription)4 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)3 ProtectionEndpointIntent (org.onosproject.net.intent.ProtectionEndpointIntent)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 VlanId (org.onlab.packet.VlanId)1 DefaultPath (org.onosproject.net.DefaultPath)1 DeviceId (org.onosproject.net.DeviceId)1 DisjointPath (org.onosproject.net.DisjointPath)1 NetworkResource (org.onosproject.net.NetworkResource)1 Path (org.onosproject.net.Path)1 PortNumber (org.onosproject.net.PortNumber)1 ProtectedTransportEndpointState (org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState)1 TransportEndpointState (org.onosproject.net.behaviour.protection.TransportEndpointState)1 DeviceService (org.onosproject.net.device.DeviceService)1 Intent (org.onosproject.net.intent.Intent)1 IntentCompilationException (org.onosproject.net.intent.IntentCompilationException)1 IntentService (org.onosproject.net.intent.IntentService)1 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)1