Search in sources :

Example 1 with TransportEndpointState

use of org.onosproject.net.behaviour.protection.TransportEndpointState in project onos by opennetworkinglab.

the class OplinkOpticalProtectionSwitchConfig method buildProtectedTransportEndpointState.

private ProtectedTransportEndpointState buildProtectedTransportEndpointState() {
    // First, get active port from device.
    PortNumber activePort = acquireActivePort();
    // Build all endpoint state with port working attribute.
    List<TransportEndpointState> states = new ArrayList<>();
    states.add(buildTransportEndpointState(data().deviceId(), PORT_PRIMARY, activePort));
    states.add(buildTransportEndpointState(data().deviceId(), PORT_SECONDARY, activePort));
    return ProtectedTransportEndpointState.builder().withPathStates(states).withDescription(buildProtectedTransportEndpointDescription()).withActivePathIndex(getActiveIndex(states, activePort)).build();
}
Also used : ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) TransportEndpointState(org.onosproject.net.behaviour.protection.TransportEndpointState) ArrayList(java.util.ArrayList) PortNumber(org.onosproject.net.PortNumber)

Example 2 with TransportEndpointState

use of org.onosproject.net.behaviour.protection.TransportEndpointState in project onos by opennetworkinglab.

the class OplinkSwitchProtection method getActiveIndex.

/*
     * get active path index
     */
private int getActiveIndex(List<TransportEndpointState> pathStates) {
    long activePort = (long) getActivePort();
    int activeIndex = 0;
    for (TransportEndpointState state : pathStates) {
        if (state.description().output().connectPoint().port().toLong() == activePort) {
            return activeIndex;
        }
        ++activeIndex;
    }
    return ProtectedTransportEndpointState.ACTIVE_UNKNOWN;
}
Also used : ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) TransportEndpointState(org.onosproject.net.behaviour.protection.TransportEndpointState) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 3 with TransportEndpointState

use of org.onosproject.net.behaviour.protection.TransportEndpointState in project onos by opennetworkinglab.

the class RoadmManager method getProtectionSwitchPortState.

@Deprecated
@Override
public String getProtectionSwitchPortState(DeviceId deviceId, PortNumber portNumber) {
    checkNotNull(deviceId);
    ProtectionConfigBehaviour behaviour = getProtectionConfig(deviceId);
    if (behaviour == null) {
        return null;
    }
    Map<ConnectPoint, ProtectedTransportEndpointState> map = getProtectionSwitchStates(behaviour);
    if (map == null) {
        log.warn("Failed to get protected transport endpoint state in device {}", deviceId);
        return null;
    }
    for (ProtectedTransportEndpointState state : map.values()) {
        for (TransportEndpointState element : state.pathStates()) {
            if (element.description().output().connectPoint().port().equals(portNumber)) {
                return element.attributes().get(INPUT_PORT_STATUS);
            }
        }
    }
    // Do not need warning here for port polling.
    log.debug("Unable to get port status, device: {}, port: {}", deviceId, portNumber);
    return null;
}
Also used : ProtectionConfigBehaviour(org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour) ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) TransportEndpointState(org.onosproject.net.behaviour.protection.TransportEndpointState) ProtectedTransportEndpointState(org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 4 with TransportEndpointState

use of org.onosproject.net.behaviour.protection.TransportEndpointState 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)

Aggregations

ProtectedTransportEndpointState (org.onosproject.net.behaviour.protection.ProtectedTransportEndpointState)4 TransportEndpointState (org.onosproject.net.behaviour.protection.TransportEndpointState)4 ConnectPoint (org.onosproject.net.ConnectPoint)3 ArrayList (java.util.ArrayList)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)2 PortNumber (org.onosproject.net.PortNumber)2 ProtectedTransportEndpointDescription (org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription)1 ProtectionConfigBehaviour (org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour)1 TransportEndpointDescription (org.onosproject.net.behaviour.protection.TransportEndpointDescription)1