如何用postman控制ODL对queue做限速配置
2016-08-23 本文已影响490人
ljyfree
OVS的QoS配置和queue的配置存储在OVSDB中。利用OpenDaylight提供的OVSDB南向接口,可以对OVSDB配置QoS/Queue策略,并应用到接口上
准备工作
- 安装了postman的Chrome浏览器,用到的URL参考/resources/commons/Qos-and-Queue-Collection.json.postman_collection,下载后可以导入到postman,方便使用
- Mininet(v2.2.1),OVS(v2.4.1),启动后创建bridge:s1,并添加了两个port(s1-eth1,s1-eth2)到s1上
- Opendaylight(Beryllium-SR3),启动后安装
>feature:install odl-ovsdb-southbound-impl-ui
- ODL-VM的IP是10.10.33.239,Mininet的IP是10.10.11.220
实验步骤
Mininet OVSDB连接到ODL
- 可以用OVSDB主动模式或是被动模式,本文使用被动模式,Mininet上打开6640端口监听
# ovs-vsctl set-manager ptcp:6640
ODL上添加node信息
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/
- Action=POST
- Content =
{
"network-topology:node":[
{
"node-id": "ovsdb://10.10.11.220:6640",
"connection-info": {
"ovsdb:remote-port": 6640,
"ovsdb:remote-ip": "10.10.11.220"
}
}
]
}
查看连接状态
- ODL-VM上
# netstat -apn | grep 6640
tcp6 0 0 :::6640 :::* LISTEN 22598/java
tcp6 0 0 10.10.33.239:44982 10.10.11.220:6640 ESTABLISHED 22598/java
- Mininet上
# ovs-vsctl show
32db576f-cfb5-401a-b061-1acb912b997e
Manager "ptcp:6640"
is_connected:true
....
查看获取的bridge的信息
- URL=hhttp://10.10.33.239:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640%2Fbridge%2Fs1
- Action=GET
- 注意URL中node后面的"/"用"%2F"代替
- 获取的内容很多,包括bridge:s1还有s1-eth1/s1-eth2的信息,就不贴了
向queue-entries中添加QUEUE-1
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:queues/QUEUE-1/
- Action=PUT
- Content=
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-1",
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "10"
}
]
}
]
}
类似地再添加QUEUE-2
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:queues/QUEUE-2/
- Action=PUT
- Content=
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-2",
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "20"
}
]
}
]
}
获取分配给两个queue的uuid
- URL=http://10.10.33.239:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:queues/QUEUE-1/
- Action=GET
- return
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-1",
"queues-external-ids": [
{
"queues-external-id-key": "opendaylight-iid",
"queues-external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-1']"
}
],
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "10"
}
],
"queue-uuid": "e7c01279-c27b-4d4a-ae24-bbd61f9b721d"
}
]
}
- 所以QUEUE-1的uuid="e7c01279-c27b-4d4a-ae24-bbd61f9b721d"
- 类似地,获取QUEUE-2的uuid="e6b797c6-6759-454a-bee8-c67d54e23990"
将两条queue的配置加到QoS entry
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:qos-entries/QOS-1/
- Action=PUT
- Content
{
"ovsdb:qos-entries": [
{
"qos-id": "QOS-1",
"queue-list": [
{
"queue-number": "1",
"queue-uuid": "e7c01279-c27b-4d4a-ae24-bbd61f9b721d"
},
{
"queue-number": "2",
"queue-uuid": "e6b797c6-6759-454a-bee8-c67d54e23990"
}
]
}
]
}
- 即queue_1使用QUEUE-1策略,queue_2使用QUEUE-2策略
获取QOS的uuid
- URL=http://10.10.33.239:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:qos-entries/QOS-1/
- Action=GET
- return
{
"ovsdb:qos-entries": [
{
"qos-id": "QOS-1",
"qos-type": "ovsdb:qos-type-base",
"queue-list": [
{
"queue-number": 2,
"queue-uuid": "e6b797c6-6759-454a-bee8-c67d54e23990",
"queue-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-2']"
},
{
"queue-number": 1,
"queue-uuid": "e7c01279-c27b-4d4a-ae24-bbd61f9b721d",
"queue-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:queues[ovsdb:queue-id='QUEUE-1']"
}
],
"qos-uuid": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4",
"qos-external-ids": [
{
"qos-external-id-key": "opendaylight-iid",
"qos-external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:qos-entries[ovsdb:qos-id='QOS-1']"
}
]
}
]
}
- 所以QOS-1的uuid="6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
将QOS-1应用到termination-point s1-eth1上
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640%2Fbridge%2Fs1/termination-point/s1-eth1
- Action=PUT
- Content
{
"network-topology:termination-point": [
{
"ovsdb:name": "s1-eth1",
"tp-id": "s1-eth1",
"qos": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
}
]
}
获取s1-eth1的信息
- URL=http://10.10.33.239:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640%2Fbridge%2Fs1/termination-point/s1-eth1
- Action=GET
- Return
{
"termination-point": [
{
"tp-id": "s1-eth1",
"ovsdb:ingress-policing-burst": 0,
"ovsdb:port-uuid": "3327f25e-d329-41bc-8128-001e4f9222c5",
"ovsdb:name": "s1-eth1",
"ovsdb:interface-uuid": "72bcdcaf-1c64-4b03-b4e0-4d02e49020cd",
"ovsdb:ifindex": 20,
"ovsdb:ofport": 1,
"ovsdb:ingress-policing-rate": 0,
"ovsdb:port-external-ids": [
{
"external-id-key": "opendaylight-iid",
"external-id-value": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640/bridge/s1']/network-topology:termination-point[network-topology:tp-id='s1-eth1']"
}
],
"ovsdb:qos-entry": [
{
"qos-key": 1,
"qos-ref": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://10.10.11.220:6640']/ovsdb:qos-entries[ovsdb:qos-id='QOS-1']"
}
],
"ovsdb:qos": "6d2df68d-7f9d-4ff1-912c-dbac7e6bcec4"
}
]
}
- 可以看到QOS-1已经应用成功
从s1-eth1去掉QOS-1
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640%2Fbridge%2Fs1/termination-point/s1-eth1
- Action=PUT(不是DELETE)
- Content
{
"network-topology:termination-point": [
{
"ovsdb:name": "s1-eth1",
"tp-id": "s1-eth1"
}
]
}
删除queue entry
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:queues/QUEUE-1/
- Action= DELETE
- No content
删除QOS entry
- URL=http://10.10.33.239:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.11.220:6640/ovsdb:qos-entries/QOS-1/
- Action= DELETE
- No content
一些说明
关于queue rate
- 上述操作相当于CLI
ovs-vsctl set port s1-eth1 qos=@newqos -- --id=@newqos create qos \
type=linux-htb queues:1=@newqueue1 queues:2=@newqueue2 \
-- --id=@newqueue1 create queue other-config:max-rate=10 \
-- --id=@newqueue2 create queue other-config:max-rate=20
- 另外可以对qos配置max-rate,就是port shaping
- 也可以对Queue配置min-rate,格式参考max-rate的配置
- 在OpenFlow的Spec中明确定义,min_rate/max_rate配置的数值应该是出口带宽千分之一的倍数
/* Max-Rate queue property description. */
struct ofp_queue_desc_prop_max_rate {
uint16_t type; /* OFPQDPT_MAX_RATE. */
uint16_t length; /* Length is 8. */
uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
uint8_t pad[2]; /* 64-bit alignment */
};
- 但是在实际配置中,还要看系统的具体实现来确定配置的数值
关于queue-get-config命令的说明
- OVS提供了命令queue-get-config来获取指定接口上各个queue的限速配置
- 但是Mininet上始终获取不到具体数值
# ovs-ofctl queue-get-config s1 s1-eth1
OFPT_QUEUE_GET_CONFIG_REPLY (xid=0x4): port=1
#
- 交换机厂商在porting OVS的时候,需要注意完善。
本文首发与SDNLAB http://www.sdnlab.com/17601.html