sonic config 配置方法介绍
Posted hello-Will
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sonic config 配置方法介绍相关的知识,希望对你有一定的参考价值。
Sonic config 介绍
官网的一些参考如下链接。
https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md
笔记如下
1:source code
sonic-utilitie/config 对应源码都可以在main.py中找到。
举例修改hostname, 代码如下,主要三部操作,1:连接configdb 2:修改db里面对应数据 3:使能配置以及相关
# 'hostname' command
#
@config.command('hostname')
@click.argument('new_hostname', metavar='<new_hostname>', required=True)
def hostname(new_hostname):
"""Change device hostname without impacting the traffic."""
config_db = ConfigDBConnector()
config_db.connect()
config_db.mod_entry('DEVICE_METADATA' , 'localhost', "hostname" : new_hostname)
2: cli show
admin@cel-seastone-01:~$ sudo config ?
Usage: config [OPTIONS] COMMAND [ARGS]...
SONiC command line - 'config' command
Options:
-?, -h, --help Show this message and exit.
Commands:
aaa AAA command line
acl ACL-related configuration tasks
.。。。。。。。。。。。。
3:sonic-cfggen
"""sonic-cfggen
A tool to read SONiC config data from one or more of the following sources:
minigraph file, config DB, json file(s), yaml files(s), command line input,
and write the data into DB, print as json, or render a jinja2 config template.
Examples:
Render template with minigraph:
sonic-cfggen -m -t /usr/share/template/bgpd.conf.j2
Dump config DB content into json file:
sonic-cfggen -d --print-data > db_dump.json
Load content of json file into config DB:
sonic-cfggen -j db_dump.json --write-to-db
See usage string for detail description for arguments.
配置mtu example
1:sudo config interface mtu Ethernet124 4800
2:config db
redis-cli select 4
127.0.0.1:6379[4]> hgetall PORT|Ethernet124
1) "index"
2) "32"
3) "lanes"
4) "125,126,127,128"
5) "description"
6) "etp32"
7) "mtu"
8) "4800"
9) "alias"
10) "etp32"
11) "pfc_asym"
12) "off"
13) "speed"
14) "100000"
15) "fec"
16) "rs"
3: appl db
select 0
127.0.0.1:6379> hgetall PORT_TABLE:Ethernet124
1) "index"
2) "32"
3) "lanes"
4) "125,126,127,128"
5) "description"
6) "etp32"
7) "mtu"
8) "4800"
9) "alias"
10) "etp32"
11) "pfc_asym"
12) "off"
13) "speed"
14) "100000"
15) "fec"
16) "rs"
17) "oper_status"
18) "down"
19) "admin_status"
20) "down"
4: asic db 没找到端口映射关系
(这里oid映射关系oid:0x10000000000021),猜测可能对应bcmsh ceXX, oid从1开始的,对应关系为oid-2=XX
但是还是找到了
127.0.0.1:6379[1]> hgetall "ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x1000000000021"
1) "NULL"
2) "NULL"
3) "SAI_PORT_ATTR_ADMIN_STATE"
4) "false"
5) "SAI_PORT_ATTR_SPEED"
6) "100000"
7) "SAI_PORT_ATTR_MTU"
8) "4822"
9) "SAI_PORT_ATTR_FEC_MODE"
10) "SAI_PORT_FEC_MODE_RS"
5:bcmsh 可以看到有4822有在上次显示的是4800,22这个交换芯片内部处理的时候可以加上的字节数
drivshell>port ce31
port ce31
PORT: Status (* indicates PHY link up)
ce31 (Disabled LS(SW Forced((100GFD) STP(Forward) Lrn(ARL,FWD) UtPri(0) Pfm(FloodNone) IF(KR4) PH(Slave) Max_frame(4822) MDIX(ForcedNormal, Normal) Medium(None) Fault(Local) VLANFILTER(3) Mac driver(CLMAC Driver)
以上是关于sonic config 配置方法介绍的主要内容,如果未能解决你的问题,请参考以下文章