diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-09-25 21:02:06 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-09-25 21:02:06 +0200 |
| commit | 9b5110a868ef413fdc1303f834220d99af8ceead (patch) | |
| tree | 82917993a91c7cce8f84d46792913e388ea8dabb /src/services/api | |
| parent | ce4f4c98f13dc039875bd23c51e081a5381917e0 (diff) | |
| download | vyos-1x-9b5110a868ef413fdc1303f834220d99af8ceead.tar.gz vyos-1x-9b5110a868ef413fdc1303f834220d99af8ceead.zip | |
op-mode: T9354: replace "reset connection" with "reconnect interface"
"connect interface" and "disconnect interface" cannot be combined to restart a
dialer interface when the CLI session runs over that very interface, yet the
command which does cover it was filed under an unrelated top-level node and
was hard to find.
It is now "reconnect interface <ifname>", mirroring the existing connect and
disconnect commands. "reset connection" is removed, no alias is kept.
The removed command was reachable through the REST API as a "reset" path. A
dedicated "/reconnect" endpoint takes its place, so the operation stays
available to API consumers.
Diffstat (limited to 'src/services/api')
| -rw-r--r-- | src/services/api/rest/models.py | 14 | ||||
| -rw-r--r-- | src/services/api/rest/routers.py | 23 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/services/api/rest/models.py b/src/services/api/rest/models.py index 8321ad2e3..8762c3bff 100644 --- a/src/services/api/rest/models.py +++ b/src/services/api/rest/models.py @@ -291,6 +291,20 @@ class ResetModel(ApiModel): } +class ReconnectModel(ApiModel): + op: StrictStr + path: List[StrictStr] + + class Config: + json_schema_extra = { + 'example': { + 'key': 'id_key', + 'op': 'reconnect', + 'path': ['op', 'mode', 'path'], + } + } + + class PoweroffModel(ApiModel): op: StrictStr path: List[StrictStr] diff --git a/src/services/api/rest/routers.py b/src/services/api/rest/routers.py index 1808e5a5b..c2aa033bc 100644 --- a/src/services/api/rest/routers.py +++ b/src/services/api/rest/routers.py @@ -74,6 +74,7 @@ from .models import GenerateModel from .models import ShowModel from .models import RebootModel from .models import ResetModel +from .models import ReconnectModel from .models import RenewModel from .models import ImportPkiModel from .models import PingModel @@ -934,6 +935,28 @@ def reset_op(data: ResetModel): return success(res) +@router.post('/reconnect') +def reconnect_op(data: ReconnectModel): + state = SessionState() + session = state.session + + op = data.op + path = data.path + + try: + if op == 'reconnect': + res = session.reconnect(path) + else: + return error(400, f"'{op}' is not a valid operation") + except ConfigSessionError as e: + return error(400, str(e)) + except Exception: + LOG.critical(traceback.format_exc()) + return error(500, 'An internal error occurred. Check the logs for details.') + + return success(res) + + @router.post('/import-pki') def import_pki(data: ImportPkiModel): # pylint: disable=consider-using-with |
