Commit 603681de authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

opticalcontroller: add the alarm, subscription and recompute resources

Thirteen resources: alarm notification intake and retrieval, the
AlarmSubscribe/Unsubscribe/Subscriptions API and its TAPI
create/delete/get-subscription equivalents, MarkLinkFailed,
RecomputeSubflow, /pathrecomp and TAPI recompute-p2mp.

PathRecomp and TapiRecomputeP2MP live here rather than with the P2MP
resources because recompute-on-failure is part of this feature; the two
hooks the P2MP resources need (revert on a path computed from a
protected device, restore on delete) are added back to them here.

As with P2MP, the classes are bound by register() so OpticalController
only gains an import and one call.
parent a239e25e
Loading
Loading
Loading
Loading
+4 −0
Changes for src/opticalcontroller/OpticalController.py: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -583,5 +583,9 @@ class ComputeOpticalConnectivityCandidates(Resource):
from opticalcontroller import p2mp_routes          # noqa: E402
p2mp_routes.register(api, optical)

# Alarm, subscription and recompute resources.
from opticalcontroller import alarm_routes           # noqa: E402
alarm_routes.register(api, optical)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=10060, debug=True)
+6 −0
Changes for src/opticalcontroller/alarm_engine.py: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ _active_leaf_monitoring : dict = {}
# Last time an alarm was pushed to the end-to-end webhook, per device.
_last_webhook_push_time : dict = {}

# Last alarm actually pushed per device, used to suppress duplicates.
_last_pushed_alarm : dict = {}

# Last notification stored per device, used to detect genuinely new alarms.
_last_stored_notification : dict = {}

tapi_client = TapiClient()

LOGGER = logging.getLogger(__name__)
+970 −0

File added.

Preview size limit exceeded, changes collapsed.

+8 −0
Changes for src/opticalcontroller/p2mp_routes.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -475,6 +475,10 @@ class ComputeP2MP(Resource):
                _register_path_computation(
                    sources, destinations, request_data, flow_id, via="ComputeP2MP"
                )
                # A path computed from a protected device means it is back in
                # service. Imported late: alarm_failover reaches this module.
                from opticalcontroller import alarm_failover
                alarm_failover.maybe_revert_on_source_recompute(sources)
                LOGGER.info("******************************************")
                LOGGER.info("TAPI Path Computation successfully retrieved")
                LOGGER.info(f"TAPI Path Computation Response: {tapi_response}")
@@ -1076,6 +1080,10 @@ class TapiDeleteP2MP(Resource):
            p2mp_state.rsa_pmp.reset(full=True)
            LOGGER.info("TapiDeleteP2MP: performed full RSA state reset (subcarrier groups, slots, optical bands)")

        # A deleted path may have been carrying a backup device.
        from opticalcontroller import alarm_failover
        alarm_failover.restore_after_delete(deleted)

        LOGGER.info("TapiDeleteP2MP: deleted %d path record(s): %s", len(deleted), list(deleted.keys()))