我正在尝试使用 Ansible openvswitch_db 模块创建 Open vSwitch QoS 设置。
Ansible 任务应模拟如下命令:
ovs-vsctl set port vm00-eth1 qos=@newqos -- --id=@newqos create qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000
我尝试了如下所示的 Ansible 任务,但它不会更改任何 QoS 设置。
- openvswitch.openvswitch.openvswitch_db:
table: Port
record: vm00-eth1
col: other_config
key: cir
value: 30000000
Ansible 任务成功运行,但该端口上仍然没有 QoS 设置:
root@host00 ~ # ovs-appctl qos/show vm00-eth1
QoS not configured on vm00-eth1
ovs-vsctl 设置端口 vm00-eth1 qos=@newqos -- --id=@newqos 创建 qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000
当你使用上面的命令时,实际上是在操作两个表。 Port表和QoS表用“--”一起引用。
命令执行的操作:
所以你得了解ovsdb中key、column、table的关系。以及表之间的连接。
将所有数据库操作放在ansible openvswitch_db模块中并不容易。我建议您改用 ansible shell 命令:
- name: setting qos
shell: "{{ item.command }}"
args:
warn: false
with_items:
- { "command": "ovs-vsctl set port vm00-eth1 qos=@newqos -- --id=@newqos create qos type=egress-policer other-config:cir=30000000 other-config:cbs=3000000" }