use of org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour in project onos by opennetworkinglab.
the class ProtectionConfigMonitor method updateProtection.
private void updateProtection(DeviceId did, ProtectionConfig before, ProtectionConfig after) {
ProtectedTransportEndpointDescription description = after.asDescription();
log.info("updating protection {}-{}", did, description);
ProtectionConfigBehaviour behaviour = getBehaviour(did);
Optional<ConnectPoint> existing = findFirstVirtualPort(behaviour, after.fingerprint());
if (!existing.isPresent()) {
log.warn("Update requested, but not found, falling back as add");
addProtection(did, after);
return;
}
ConnectPoint vPort = existing.get();
log.info("updating protection virtual Port {} : {}", vPort, description);
behaviour.updateProtectionEndpoint(vPort, description).handle((vPortNew, e) -> {
if (vPort != null) {
log.info("Virtual Port {} updated for {}", vPort, description);
log.debug("{}", deviceService.getPort(vPort));
} else {
log.error("Protection {} -> {} exceptionally failed.", before, after, e);
}
return vPort;
});
}
use of org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour in project onos by opennetworkinglab.
the class ProtectionConfigMonitor method addProtection.
private void addProtection(DeviceId did, ProtectionConfig added) {
ProtectedTransportEndpointDescription description = added.asDescription();
log.info("adding protection {}-{}", did, description);
ProtectionConfigBehaviour behaviour = getBehaviour(did);
CompletableFuture<ConnectPoint> result;
result = behaviour.createProtectionEndpoint(description);
result.handle((vPort, e) -> {
if (vPort != null) {
log.info("Virtual Port {} created for {}", vPort, description);
log.debug("{}", deviceService.getPort(vPort));
} else {
log.error("Protection {} exceptionally failed.", added, e);
}
return vPort;
});
}
use of org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour in project onos by opennetworkinglab.
the class ProtectionConfigMonitor method removeProtection.
private void removeProtection(DeviceId did, ProtectionConfig removed) {
ProtectedTransportEndpointDescription description = removed.asDescription();
log.info("removing protection {}-{}", did, description);
ProtectionConfigBehaviour behaviour = getBehaviour(did);
Optional<ConnectPoint> existing = findFirstVirtualPort(behaviour, removed.fingerprint());
if (!existing.isPresent()) {
log.warn("Remove requested, but not found, ignoring");
return;
}
ConnectPoint vPort = existing.get();
log.info("removing protection virtual port {} : {}", vPort, description);
behaviour.deleteProtectionEndpoint(vPort).handle((result, ex) -> {
if (ex != null) {
log.info("removed protection {} : {}", vPort, result);
} else {
log.warn("removed protection {} failed.", vPort, ex);
}
return result;
});
}
use of org.onosproject.net.behaviour.protection.ProtectionConfigBehaviour 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.ProtectionConfigBehaviour in project onos by opennetworkinglab.
the class RoadmManager method getProtectionSwitchStates.
@Override
public Map<ConnectPoint, ProtectedTransportEndpointState> getProtectionSwitchStates(DeviceId deviceId) {
checkNotNull(deviceId);
ProtectionConfigBehaviour behaviour = getProtectionConfig(deviceId);
if (behaviour == null) {
return ImmutableMap.of();
}
return getProtectionSwitchStates(behaviour);
}
Aggregations