Restart modem: pause Smart Power auto power-cycle until the modem is back
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m5s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m13s
Lint / Python (flake8) (pull_request) Successful in 1m14s
Test / Python Tests (pytest) (push) Successful in 1m51s
Security / Python Security (bandit) (pull_request) Successful in 1m25s
Lint / JS (eslint) (pull_request) Successful in 19s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Test / Python Tests (pytest) (pull_request) Successful in 1m32s
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m5s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m13s
Lint / Python (flake8) (pull_request) Successful in 1m14s
Test / Python Tests (pytest) (push) Successful in 1m51s
Security / Python Security (bandit) (pull_request) Successful in 1m25s
Lint / JS (eslint) (pull_request) Successful in 19s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Test / Python Tests (pytest) (pull_request) Successful in 1m32s
UniFi Smart Power on the RPDU's modem outlet saw the internet down while the modem rebooted and cut its power mid-boot: once during the 11-20 restart and twice after the 11-24 AT&T-app reboot. UniFi only exposes auto power-cycle as on or off, so the button now turns it off for every outlet that has it on, and the monitor turns it back on when the restart ends (back, or after 30 minutes). - UnifiClient.auto_power_cycle_outlets / set_auto_power_cycle: sends the device's outlet_overrides back with only cycle_enabled changed, then reads them again to confirm. The only UniFi setting Gandalf changes. - A failed pause doesn't stop the restart; a failed restart turns it back on. A failed restore is retried every cycle and shown as broken in Needs attention until it works. - The panel note and confirm text mention the pause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7792063ba
commit
a5d4fc3156
9 files changed
+304
-19
No files matched your search
@@ -30,7 +30,7 @@ import diagnose
|
||||
import kuma
|
||||
import modem as modem_api
|
||||
import topology
|
||||
from monitor import PulseClient, UnifiClient
|
||||
from monitor import PulseClient, UnifiClient, pause_smart_power, restore_smart_power
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -605,10 +605,24 @@ def api_modem_restart():
|
||||
|
||||
sup_id = db.create_suppression('all', '', '', 'Modem restart from Gandalf', user,
|
||||
MODEM_RESTART_SILENCE_MIN)
|
||||
# Smart Power would see the internet down while the modem boots and cut its power
|
||||
# mid-boot, so auto power-cycle is off until the modem is back. A failure here doesn't
|
||||
# stop the restart: it just means Smart Power may cycle it once more, as it used to.
|
||||
unifi = UnifiClient(cfg['unifi']) if cfg.get('unifi') else None
|
||||
paused, sp_error = pause_smart_power(unifi) if unifi else ([], None)
|
||||
if sp_error:
|
||||
logger.warning(f'Smart Power auto power-cycle could not be paused: {sp_error}')
|
||||
try:
|
||||
result = modem_api.ModemAdmin(modem_cfg).restart()
|
||||
except (modem_api.ModemUnreachable, modem_api.ModemDataInvalid, modem_api.ModemLoginFailed) as e:
|
||||
logger.error(f'Modem restart failed: {e}')
|
||||
if paused:
|
||||
err = restore_smart_power(unifi, paused)
|
||||
if err:
|
||||
logger.error(f'Smart Power auto power-cycle could not be turned back on: {err}')
|
||||
db.set_state('modem_restart', {'at': time.time(), 'by': user, 'result': 'failed',
|
||||
'finished_at': time.time(), 'back': False,
|
||||
'smart_power_paused': paused, 'smart_power_error': err})
|
||||
db.deactivate_suppression(sup_id)
|
||||
if kuma_on:
|
||||
try:
|
||||
@@ -618,10 +632,13 @@ def api_modem_restart():
|
||||
return jsonify({'error': f'The modem did not restart: {e}'}), 502
|
||||
|
||||
db.set_state('modem_restart', {'at': time.time(), 'by': user, 'result': result,
|
||||
'suppression_id': sup_id, 'kuma': kuma_on, 'finished_at': None})
|
||||
'suppression_id': sup_id, 'kuma': kuma_on, 'finished_at': None,
|
||||
'smart_power_paused': paused, 'smart_power_error': sp_error})
|
||||
logger.warning(f'Modem restart requested by {user} ({result}); Kuma maintenance '
|
||||
f'{"on" if kuma_on else "not set"}, suppression #{sup_id}')
|
||||
return jsonify({'ok': True, 'result': result, 'kuma': kuma_on, 'suppression_id': sup_id})
|
||||
f'{"on" if kuma_on else "not set"}, suppression #{sup_id}, Smart Power paused on '
|
||||
f'{len(paused)} outlet(s)')
|
||||
return jsonify({'ok': True, 'result': result, 'kuma': kuma_on, 'suppression_id': sup_id,
|
||||
'smart_power_paused': len(paused), 'smart_power_error': sp_error})
|
||||
|
||||
|
||||
@app.route('/api/devices')
|
||||
@@ -1425,7 +1442,8 @@ def _attention() -> dict:
|
||||
sheet = {'items': (view or {}).get('items') or [], 'cables': (view or {}).get('cables') or []}
|
||||
power = _topology_graph(events, sheet, feeds).get('power') or []
|
||||
return attention.build(events, power, view, racks, _state_json('wan_quality'),
|
||||
modem_checks=_state_json('modem_checks'))
|
||||
modem_checks=_state_json('modem_checks'),
|
||||
modem_restart=_state_json('modem_restart'))
|
||||
|
||||
|
||||
def _topology_graph(events: list, sheet: dict, feeds: list) -> dict:
|
||||
|
||||
Reference in new issue
Block a user