Commit 4cf8d36
Add a "fboss2 config interface <name> description <desc>" command. (#760)
Summary:
**Pre-submission checklist**
- [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install`
- [x] `pre-commit run`
Add some helper code to process interface-list arguments.
Note: this change is part of a series, the previous one is #759, the next one is #761.
Pull Request resolved: #760
Test Plan:
Unit tests. New end to end tests for this command are in #783.
## Sample usage
```
[admin@fboss101 benoit]$ ./fboss2-dev show interface | head
+-----------+--------+-------+------+------+------------------------------+----------------------------+
| Interface | Status | Speed | VLAN | MTU | Addresses | Description |
--------------------------------------------------------------------------------------------------------
| eth1/1/1 | down | 800G | 2001 | 1500 | 10.0.0.0/24 | Test port for diff command |
| | | | | | 2400::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
+-----------+--------+-------+------+------+------------------------------+----------------------------+
| eth1/2/1 | down | 200G | 2003 | 9216 | 11.0.0.0/24 | Another test description |
| | | | | | 2401::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
[admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/2/1 description 'This is a test.'
Successfully set description for interface(s) eth1/2/1
[admin@fboss101 benoit]$ ./fboss2-dev config session diff
--- /etc/coop/agent.conf 2025-11-05 12:49:14.497415902 -0800
+++ /home/admin/.fboss2/agent.conf 2025-11-05 12:57:27.123758309 -0800
@@ -2230,7 +2230,7 @@
},
{
"conditionalEntropyRehash": false,
- "description": "Another test description",
+ "description": "This is a test.",
"drainState": 0,
"expectedLLDPValues": {
"2": "eth1/6/1"
[admin@fboss101 benoit]$ ./fboss2-dev config session commit
Config session committed successfully and config reloaded.
[admin@fboss101 benoit]$ ./fboss2-dev show interface | head
+-----------+--------+-------+------+------+------------------------------+----------------------------+
| Interface | Status | Speed | VLAN | MTU | Addresses | Description |
--------------------------------------------------------------------------------------------------------
| eth1/1/1 | down | 800G | 2001 | 1500 | 10.0.0.0/24 | Test port for diff command |
| | | | | | 2400::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
+-----------+--------+-------+------+------+------------------------------+----------------------------+
| eth1/2/1 | down | 200G | 2003 | 9216 | 11.0.0.0/24 | This is a test. |
| | | | | | 2401::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
```
Changing two interfaces (or more) at the same time:
```
[admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/1/1 eth1/2/1 description "two at once"
Successfully set description for interface(s) eth1/1/1, eth1/2/1
[admin@fboss101 benoit]$ ./fboss2-dev config session diff
--- current live config
+++ session config
@@ -2200,7 +2200,7 @@
"ports": [
{
"conditionalEntropyRehash": false,
- "description": "two",
+ "description": "two at once",
"drainState": 0,
"expectedLLDPValues": {
"2": "eth1/5/1"
@@ -2230,7 +2230,7 @@
},
{
"conditionalEntropyRehash": false,
- "description": "two",
+ "description": "two at once",
"drainState": 0,
"expectedLLDPValues": {
"2": "eth1/6/1"
[admin@fboss101 benoit]$ ./fboss2-dev config session commit
Config session committed successfully as ede5a52 and config reloaded.
[admin@fboss101 benoit]$ ./fboss2-dev show interface eth1/1/1 eth1/2/1
+-----------+--------+-------+------+------+------------------------------+-------------+
| Interface | Status | Speed | VLAN | MTU | Addresses | Description |
-----------------------------------------------------------------------------------------
| eth1/1/1 | down | 800G | 2001 | 9000 | 10.0.0.0/24 | two at once |
| | | | | | 2400::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
+-----------+--------+-------+------+------+------------------------------+-------------+
| eth1/2/1 | down | 200G | 2003 | 9216 | 11.0.0.0/24 | two at once |
| | | | | | 2401::/64 | |
| | | | | | fe80::b4db:91ff:fe95:ff07/64 | |
+-----------+--------+-------+------+------+------------------------------+-------------+
```
Referencing an interface that doesn't exist:
```
[admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/9/42 description oopsy
Invalid argument: Port(s) or interface(s) not found in configuration: eth1/9/42. Ports must exist in the hardware platform mapping and be defined in the configuration before they can be configured.
```
Nothing changes when mixing valid and nonexistent interface names:
```
[admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/1/1 eth1/9/42 description oopsy
Invalid argument: Port(s) or interface(s) not found in configuration: eth1/9/42. Ports must exist in the hardware platform mapping and be defined in the configuration before they can be configured.
E0120 14:32:19.177613 42717 CmdHandler.cpp:280] localhost - Error in command execution: Invalid argument: Port(s) or interface(s) not found in configuration: eth1/9/42. Ports must exist in the hardware platform mapping and be defined in the configuration before they can be configured.
[admin@fboss101 benoit]$ ./fboss2-dev config session diff
No differences between current live config and session config.
```
Reviewed By: shiva-menta
Differential Revision: D91058688
Pulled By: joseph5wu
fbshipit-source-id: 0d8cafe136f120a7b1163c3dfdb16fced8a2b6051 parent 5760eba commit 4cf8d36
File tree
15 files changed
+525
-0
lines changed- cmake
- fboss/cli/fboss2
- commands/config/interface
- test
- utils
15 files changed
+525
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
580 | 583 | | |
581 | 584 | | |
582 | 585 | | |
| |||
587 | 590 | | |
588 | 591 | | |
589 | 592 | | |
| 593 | + | |
| 594 | + | |
590 | 595 | | |
591 | 596 | | |
592 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
783 | 783 | | |
784 | 784 | | |
785 | 785 | | |
| 786 | + | |
786 | 787 | | |
787 | 788 | | |
788 | 789 | | |
789 | 790 | | |
| 791 | + | |
790 | 792 | | |
791 | 793 | | |
792 | 794 | | |
793 | 795 | | |
794 | 796 | | |
| 797 | + | |
| 798 | + | |
795 | 799 | | |
796 | 800 | | |
797 | 801 | | |
798 | 802 | | |
| 803 | + | |
799 | 804 | | |
800 | 805 | | |
801 | 806 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
37 | 53 | | |
38 | 54 | | |
39 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments