show mgmt-vrf サブコマンド¶
概要¶
show mgmt-vrf は管理 VRF (mgmt) の有効・無効状態、Linux 上の VRF デバイス情報、ルーティングテーブルを表示する。invoke_without_command=True の Click group として実装されており、サブコマンドを指定しなくても本体ロジックが動く特殊な構造になっている1。
コマンド一覧¶
| コマンド | 用途 |
|---|---|
show mgmt-vrf |
管理 VRF の状態 + ip link show を表示 |
show mgmt-vrf routes |
管理 VRF のルーティングテーブル (table 6000) を表示 |
各コマンドの詳細¶
show mgmt-vrf¶
用法:
引数:
routes... 任意。リテラル文字列routesのみ受け付ける(click.Choice(["routes"]))
動作:
is_mgmt_vrf_enabled(ctx)で CONFIG_DB のMGMT_VRF_CONFIGを参照し、mgmtVrfEnabledが false の場合はManagementVRF : Disabledを表示して終了routes引数なしで有効な場合:ManagementVRF : Enabledを表示し、ip -d link show mgmtとip link show vrf mgmtを続けて実行routes引数ありで有効な場合:ip route show table 6000を実行(管理 VRF 専用 routing table の固定 ID)
📋 検証エビデンス: sonic-net/sonic-utilities/show/main.py#L540-L561 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
出典:
sonic-net/sonic-utilities/show/main.py#L540-L561 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
抜粋:
@cli.group('mgmt-vrf', invoke_without_command=True)
@click.argument('routes', required=False, type=click.Choice(["routes"]))
def mgmt_vrf(ctx, routes):
if is_mgmt_vrf_enabled(ctx) is False:
click.echo("\nManagementVRF : Disabled")
return
else:
if routes is None:
click.echo("\nManagementVRF : Enabled")
run_command(['ip', '-d', 'link', 'show', 'mgmt'])
run_command(['ip', 'link', 'show', 'vrf', 'mgmt'])
else:
run_command(['ip', 'route', 'show', 'table', '6000'])
補足¶
- 管理 VRF のルーティングテーブル ID は SONiC で 6000 固定。
ip ruleの優先度で標準テーブル経路と分離されている is_mgmt_vrf_enabledはMGMT_VRF_CONFIG|vrf_globalのmgmtVrfEnabledを参照する- 管理 VRF の有効化・無効化は
config vrf add mgmt/config vrf del mgmt系コマンドで行う(本コマンドは表示のみ)
データフロー (自動生成)¶
flowchart LR
CLI["show mgmt-vrf"]
CDB0[("CONFIG_DB<br/>MGMT_VRF_CONFIG")]
CDB0 --> CLI
凡例
show 系 (CONFIG_DB → CLI) のミニ図。テーブル → daemon 対応は docs/reference/config-db-orch-map.md から機械生成。
関連リファレンス¶
- YANG:
sonic-mgmt-vrf - CONFIG_DB:
MGMT_VRF_CONFIG
引用元¶
関連 CLI コマンド¶
config mgmt trio— config save / load / reload / replace / qos reloadconfig vrf— config vrf サブコマンドconfig dhcp relay— config dhcp_relay / dhcpv4_relay サブコマンドconfig muxcable— config muxcable サブコマンドshow muxcable— show muxcable サブコマンド
関連ページ¶
-
@cli.group('mgmt-vrf', invoke_without_command=True)+@click.argument('routes', required=False)の組み合わせで、show mgmt-vrfもshow mgmt-vrf routesも同じ関数本体に流れる。https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/main.py#L540 ↩