Add explicit Huawei hop system-view option and startup column safety-net.

Some hops only accept stelnet in system-view; make it a saved yes/no setting (default off) instead of auto-retry, and always ALTER the new column on API boot when Alembic skips legacy DDL.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-28 23:58:05 +08:00
parent 0a550abcb0
commit b36174bfa4
20 changed files with 242 additions and 10 deletions

View file

@ -13,6 +13,7 @@ import netx_api.models # noqa: F401
from netx_api.schema_patches import (
apply_auth_schema_patches,
apply_domain_schema_patches,
apply_hop_schema_safety_net,
apply_topology_schema_safety_net,
)
@ -60,6 +61,37 @@ class SchemaPatchesTests(unittest.TestCase):
self.assertIn("a_ifname", cols)
self.assertIn("z_ifname", cols)
def test_hop_safety_net_adds_enter_system_view(self) -> None:
with self.engine.begin() as conn:
conn.execute(text("DROP TABLE IF EXISTS managed_ne"))
conn.execute(
text(
"""
CREATE TABLE managed_ne (
id VARCHAR(64) PRIMARY KEY,
hop_enabled BOOLEAN DEFAULT 0
)
"""
)
)
conn.execute(text("DROP TABLE IF EXISTS cli_connect_profile"))
conn.execute(
text(
"""
CREATE TABLE cli_connect_profile (
id VARCHAR(64) PRIMARY KEY,
hop_enabled BOOLEAN DEFAULT 0
)
"""
)
)
apply_hop_schema_safety_net(conn)
apply_hop_schema_safety_net(conn)
ne_cols = {c["name"] for c in inspect(self.engine).get_columns("managed_ne")}
profile_cols = {c["name"] for c in inspect(self.engine).get_columns("cli_connect_profile")}
self.assertIn("hop_enter_system_view", ne_cols)
self.assertIn("hop_enter_system_view", profile_cols)
def test_domain_patches_do_not_raise(self) -> None:
with self.engine.begin() as conn:
apply_domain_schema_patches(conn)