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();
}
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;
}
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;
}
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();
}
Aggregations