Skip to content

[Nexthop][fboss2-dev] Create VLANs on the fly in "config vlan" and "switchport access vlan" - #1407

Open
benoit-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:vlan-create
Open

[Nexthop][fboss2-dev] Create VLANs on the fly in "config vlan" and "switchport access vlan"#1407
benoit-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:vlan-create

Conversation

@benoit-nexthop

Copy link
Copy Markdown
Contributor

Summary

"config vlan 4005" with no subcommand used to fail with "Incomplete command, please use one of the subcommands", and "config interface switchport access vlan " refused to run when the VLAN didn't exist. Both now create the VLAN (and its barebone interface) via VlanManager::createVlan() in the config session:

  • config vlan : creates the VLAN, or reports "already exists". Implementation moved from the inline stub in CmdConfigVlan.h to CmdConfigVlan.cpp.
  • config interface switchport access vlan : auto-creates a missing VLAN and notes "(VLAN created)" in the output.

Add CmdConfigVlanTest.cpp covering creation (including persistence of the session config to disk) and idempotency, and rewrite the switchport access vlan "throws when VLAN missing" test to verify the new auto-create behavior.

Test Plan

Add a new unit test / update existing unit test.

Tested on wedge800bnhp: "config vlan 4005" and "switchport access vlan 4021" both create the VLAN + fbossNNNN interface, visible in "config session diff"; re-running reports the VLAN already exists.

# Summary

"config vlan 4005" with no subcommand used to fail with "Incomplete
command, please use one of the subcommands", and "config interface
<port> switchport access vlan <id>" refused to run when the VLAN didn't
exist. Both now create the VLAN (and its barebone interface) via
VlanManager::createVlan() in the config session:

- config vlan <id>: creates the VLAN, or reports "already exists".
Implementation moved from the inline stub in CmdConfigVlan.h to
CmdConfigVlan.cpp.
- config interface <port> switchport access vlan <id>: auto-creates a
missing VLAN and notes "(VLAN <id> created)" in the output.

Add CmdConfigVlanTest.cpp covering creation (including persistence of
the session config to disk) and idempotency, and rewrite the switchport
access vlan "throws when VLAN missing" test to verify the new
auto-create behavior.

# Test Plan

Add a new unit test / update existing unit test.

Tested on wedge800bnhp: "config vlan 4005" and "switchport access vlan 4021"
both create the VLAN + fbossNNNN interface, visible in "config session
diff"; re-running reports the VLAN already exists.
@benoit-nexthop
benoit-nexthop requested review from a team as code owners July 23, 2026 03:32
@meta-cla meta-cla Bot added the CLA Signed label Jul 23, 2026
@joseph5wu

Copy link
Copy Markdown
Contributor

@benoit-nexthop this PR failed the GHA build fboss2 cli job, can you fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants