I still just keep getting:
janne@ubuntu-12:~/dev/rest/daedalus$ python index.py
15d1a574877c4276bd740dfcd4b5470c
{"error":"java.lang.IllegalArgumentException","message":"{ofm:[V_1_0,ERROR,76,780373],BAD_ACTION/BAD_ARGUMENT,#dataBytes=64,OFM-cause:[V_1_0,FLOW_MOD,104,780373]}"} with the code you provided.
One thing to note that I'm not running the very latest SDN controller I think. I'm running SDN Controller Version: 2.0.0.4253, which is the version I got attending Chuck Black's HP SDN VAN training in Grenoble, France, a couple weeks ago. Could this have something to do with it?
Here is my whole index.py:
import requests
import json
payload = {"login":{"user":"sdn","password":"skyline","domain":"sdn" }}
headers = {'content-type': 'application/json'}
r = requests.post('http://127.0.0.1:8080/sdn/v2.0/auth', data=json.dumps(payload), headers=headers)
token = r.json()['record']['token']
print token
headers = {'X-Auth-Token': token}
r = requests.get('http://127.0.0.1:8080/sdn/v2.0/of/stats', headers=headers)
payload1 = {
"flow": {
"priority": 30000,
"idle_timeout": 30,
"hard_timeout": 30,
"match": [
{"ipv4_src": "10.0.0.1"},
{"ipv4_dst": "10.0.0.2"},
{"eth_type": "ipv4"}
],
"actions": [
{"output": 2},
{"set_field": {"ip_dscp":46}},
{"set_field":{"eth_src":"00:00:00:00:00:01"}}
]
}
}
headers = {'content-type': 'application/json', 'X-Auth-Token': token}
r = requests.post('http://127.0.0.1:8080/sdn/v2.0/of/datapaths/00:00:00:00:00:00:00:02/flows', data=json.dumps(payload1), headers=headers)
print r.content EDIT:
Just to narrow the problem down, I tried the following and it works:
payload1 = {
"flow": {
"priority": 30000,
"idle_timeout": 30,
"hard_timeout": 30,
"match": [
{"ipv4_src": "10.0.0.1"},
{"ipv4_dst": "10.0.0.2"},
{"eth_type": "ipv4"}
],
"actions": [
{"output": 2},
{"set_field":{"eth_src":"00:00:00:00:00:01"}}
]
}
}
headers = {'content-type': 'application/json', 'X-Auth-Token': token}
r = requests.post('http://127.0.0.1:8080/sdn/v2.0/of/datapaths/00:00:00:00:00:00:00:02/flows', data=json.dumps(payload1), headers=headers) So, set_field works okay, but it seems my setup (mininet, openvswitch, HP SDN VAN Ctrl...) doesn't like the ip_dscp -field. Any idea if it has been renamed at some point? The oddest part is that I can see ip_dscp field in JSON model as you instruced:
ip_dscp: {
description: "IP DSCP",
type: "integer"
}, Like eth_src:
eth_src: {
description: "Ethernet source address",
$ref: "#/mac"
}, Maybe my mininet/ovs doesn't like the value 46 (expedited forwarding)... I tried others too though without avail.
EDIT2:
A-ha! I got it working. My setup doesn't support that many ip_dscp-values for some reason, but ip_dscp 12 did the trick. After posting the flow, here's the get on that device:
{"version":"1.0.0","flows":[{"duration_sec":17,"duration_nsec":542000000,"priority":30000,"idle_timeout":30,"hard_timeout":30,"cookie":"0x0","packet_count":0,"byte_count":0,"match":[{"eth_type":"ipv4"},{"ipv4_src":"10.0.0.1","mask":"255.255.255.255"},{"ipv4_dst":"10.0.0.2","mask":"255.255.255.255"}],"actions":[{"output":2},{"set_field":{"ip_dscp":12}},{"set_field":{"eth_src":"00:00:00:00:00:01"}}]}]}