-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Port Configuration Utility High Level Design
[DRAFT - under development]
Design document of the port parameters configuration utility in SONiC
Configure port parameters.
Currently only speed set is covered in this design
- Like many other SONiC CLI utilities implemented in Python.
- Return code: 0 if succeeded, not 0 otherwise.
- Set parameters as a value of an appropriate command line option.
E.g. '-s' for speed ('-m' for MTU, '-a' for auto negotiation, etc)
It is mandatory to specify [at least one] option. If no options specified, help is printed and return code is not 0.
portconfig <portname> <options>
Options:
-s <speed> - set port speed. Speed should be specified in gigabits
-h - display this help and exit
portconfig Ethernet4 -s 40 # Set speed 40G for port Ethernet4
Utility parses and validates input arguments. If no error field speed
in table PORT_TABLE:<portname>
is updated with the provided value. In the future utility will rely on the validation implemented in the trigger activated by write to database. The database speed is written to is CONF_DB.
argparse
module can be used to parse utility input arguments. It is easy to utilize and provides auto generated program help(usage) message.
Initialization example:
import argparse
...
parser = argparse.ArgumentParser(description='Set SONiC port parameters',
version='1.0.0',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-s', '--speed', type='str', help='port speed value', default=None)
swsssdk
is the SONiC python module which unifies access to the SONiC Redis DB.
An example how to set speed 56G ton port Ethernet0:
import swsssdk
db = swsssdk.SonicV2Connector(host="127.0.0.1")
db.connect(db.APPL_DB)
db.set(db.CONF_DB, "PORT_TABLE:Ethernet0", "speed", "56000")
Utility config
(sonic-buildimage/src/sonic-utilities/config/main.py
) needs to be updated in order to provide unified system configuration.
New command is added under existing group interface
. New command name is speed
. It will invoke the portconfig
utility to set speed.
Port speed change via config
utility syntax is:
config interface speed Ethernet0 100
-
For Users
-
For Developers
-
Subgroups/Working Groups
-
Presentations
-
Join Us