diff --git a/config/main.py b/config/main.py index f7cf8e32fc..8114cb3313 100644 --- a/config/main.py +++ b/config/main.py @@ -84,6 +84,18 @@ PORT_MTU = "mtu" PORT_SPEED = "speed" +ALLOWED_PORT_SPEED_LIST = [1000, # 1G + 2500, # 2.5G + 5000, # 5G + 10000, # 10G + 25000, # 25G + 40000, # 40G + 50000, # 50G + 100000, # 100G + 200000, # 200G + 400000] # 400G + + asic_type = None # @@ -2389,13 +2401,16 @@ def shutdown(ctx, interface_name): @interface.command() @click.pass_context @click.argument('interface_name', metavar='', required=True) -@click.argument('interface_speed', metavar='', required=True) +@click.argument('interface_speed', metavar='', required=True, type=click.IntRange(1000, 400000)) @click.option('-v', '--verbose', is_flag=True, help="Enable verbose output") def speed(ctx, interface_name, interface_speed, verbose): """Set interface speed""" # Get the config_db connector config_db = ctx.obj['config_db'] + if interface_speed not in ALLOWED_PORT_SPEED_LIST: + ctx.fail(f"The speed {interface_speed} is not allowed. Allowed values: {ALLOWED_PORT_SPEED_LIST}") + if clicommon.get_interface_naming_mode() == "alias": interface_name = interface_alias_to_name(config_db, interface_name) if interface_name is None: