Software Defined Networking
1753536 Members
6031 Online
108795 Solutions
New Discussion

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

 
jmikola
Member

OpenFlow 1.0 network, HP SDN VAN controller and REST API

Hi,

 

I'm working with mininet and by default I'm pretty sure it doesn't support OpenFlow versions higher than 1.0. I've tried to do some "hacking" there (like upgrading the OpenvSwitch with no avail. That's not the problem for this time though.

 

So I'm restricted in working with OF1.0 and I don't see that as a bad thing right now. It should work too. I've had some problems having my HP SDN VAN Ctrlr REST API queries succeeding, though.

 

What I'm trying to achieve: changing the ip_dscp header of a dataflow based on source and destination IP's.

 

When my code looks like this (Python code, some parts omitted before this):

 

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": [
            {"set_field":{"ip_dscp": 46 }},
            {"output": 2 }
            ]
        
    }
}

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:04/flows', data=json.dumps(payload1), headers=headers)

 Which is pretty close to something I got working with only having "output" as the only action... I get the following:

 

{"error":"java.lang.IllegalArgumentException","message":"{ofm:[V_1_0,ERROR,76,50844],BAD_ACTION/BAD_ARGUMENT,#dataBytes=64,OFM-cause:[V_1_0,FLOW_MOD,88,50844]}"}

If I change it to the style I think would work with OF1.3, which would be:

 

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"}
        ],
        "instructions": [{
            "apply_actions": [
            {"set_field":{"ip_dscp": 46 }},
            {"output": 2 }
            ]
        }]
        
    }
}

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:04/flows', data=json.dumps(payload1), headers=headers)

 I get the following:

 

{"error":"com.hp.of.lib.VersionMismatchException","message":"Not supported before version 1.1"}

 So my question really is: how to change ip_dscp field with HP SDN VAN's REST API and OpenFlow 1.0 enabled only?

 


Just to be clear about that first error, this does work (doesn't set the ip_dscp but output yes):

 

payload1 = {
	"flow": {
		"priority": 30000,
		"idle_timeout": 60,
		"match": [
			{"ipv4_src": "10.0.0.1"},
			{"ipv4_dst": "10.0.0.2"},
			{"eth_type": "ipv4"}
		],
		"actions": [{"output": 2}]
		}
	}

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:04/flows', data=json.dumps(payload1), headers=headers)

 

6 REPLIES 6
Gerhard Roets
Esteemed Contributor

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

Hi Jmikola

 

You are very close. The key is the set_field is of type array

 

{"set_field":{"ip_dscp": 46 }},

 

should be

{"set_field":[{"ip_dscp": 46 }]},

 

Look at this post for the help of what the REST JSON schema look like

http://h30499.www3.hp.com/t5/SDN-Knowledge-Base/Viewing-the-JSON-schema-for-the-REST-API/ta-p/6258781

 

 

//Addendum to reply which I go into down below

This was slightly incorrect it is very important to read the difference between singular and plural

"set_field": {
                        "$ref": "#/flow_match_field",
                        "description": "Set the given header field"

 

Note the above is not the plural versions that matches to the array. My mistake

 

HTH

Gerhard Roets

HP SDN Team

 

 

jmikola
Member

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

This doesn't quite solve it either yet.

 

The code:

 

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}]}	
		]
	}
}

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:04/flows', data=json.dumps(payload1), headers=headers)

 Gives me a very ugly looking stacktrace error:

 

<html><head><title>Apache Tomcat/7.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.ClassCastException: com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode
	com.hp.of.json.ActionCodec.decodeSetField(ActionCodec.java:286)
	com.hp.of.json.ActionCodec.decode(ActionCodec.java:238)
	com.hp.of.json.OfmFlowModCodec.decodeActions(OfmFlowModCodec.java:235)
	com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:186)
	com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:46)
	com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:59)
	com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:42)
	com.hp.util.json.JSON.fromJson(JSON.java:68)
	com.hp.sdn.rs.FlowProvider.create(FlowProvider.java:73)
	com.hp.sdn.rs.DatapathsResource.createFlow(DatapathsResource.java:355)
	sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:606)
	com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
	com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
	com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
	com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
	com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
	com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
	com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
	com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
	com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	com.hp.util.rs.SecurityFilter.doFilter(SecurityFilter.java:94)
	com.hp.util.rs.auth.AbstractTokenAuthFilter.doFilter(AbstractTokenAuthFilter.java:106)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.35</h3></body></html>

 Also the code:

 

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"}
		],
		"instructions": [{		
			"apply_actions": [
				{"output": 2},
				{"set_field":[{"ip_dscp": 46}]}	
			]
		}]
	}
}

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:04/flows', data=json.dumps(payload1), headers=headers)

 Gives me pretty much the same.

 

<html><head><title>Apache Tomcat/7.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.ClassCastException: com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode
	com.hp.of.json.ActionCodec.decodeSetField(ActionCodec.java:286)
	com.hp.of.json.ActionCodec.decode(ActionCodec.java:238)
	com.hp.of.json.InstructionCodec.decodeActions(InstructionCodec.java:211)
	com.hp.of.json.InstructionCodec.decode(InstructionCodec.java:173)
	com.hp.of.json.OfmFlowModCodec.decodeInstructions(OfmFlowModCodec.java:223)
	com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:181)
	com.hp.of.json.OfmFlowModCodec.decode(OfmFlowModCodec.java:46)
	com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:59)
	com.hp.of.json.OfJsonCodec.decode(OfJsonCodec.java:42)
	com.hp.util.json.JSON.fromJson(JSON.java:68)
	com.hp.sdn.rs.FlowProvider.create(FlowProvider.java:73)
	com.hp.sdn.rs.DatapathsResource.createFlow(DatapathsResource.java:355)
	sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:606)
	com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
	com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
	com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
	com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
	com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
	com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
	com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
	com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
	com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	com.hp.util.rs.SecurityFilter.doFilter(SecurityFilter.java:94)
	com.hp.util.rs.auth.AbstractTokenAuthFilter.doFilter(AbstractTokenAuthFilter.java:106)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.35</h3></body></html>

 

Gerhard Roets
Esteemed Contributor

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

Hi

 

Here is what worked for me in a normal REST call with OF.1.0 on mininet using the HP VAN SDN Controller

 

{
        "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}}

                ]
        }
}

 

 Here is the flow queried

gpr@hpvansdn:~$ curl --noproxy 10.128.10.1 --header "X-Auth-Token:$tok" --header "Content-Type:application/json" --fail -ksS --request GET --url https://10.128.10.1:8443/sdn/v2.0/of/datapaths/00:00:00:00:00:00:00:01/flows/ -d  "@ff" | python -mjson.tool
{
    "flows": [
        {
            "actions": [
                {
                    "output": 2
                },
                {
                    "set_field": {
                        "ip_dscp": 46
                    }
                }
            ],
            "byte_count": "0",
            "cookie": "0x0",
            "duration_nsec": "145000000",
            "duration_sec": 6,
            "hard_timeout": 30,
            "idle_timeout": 30,
            "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"
                }
            ],
            "packet_count": "0",
            "priority": 30000,
            "table_id": "n/a"
        },
....

 HTH

Gerhard

HP VAN SDN Team

 

Gerhard Roets
Esteemed Contributor

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

Just one more note lets say you want to do 2 set_fields here is an example just in case this is my json

 

{
        "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"}}

                ]
        }
}

 

Here is the output from the flow query aginst my mininet dpid

 

gpr@hpvansdn:~$ curl --noproxy 10.128.10.1 --header "X-Auth-Token:$tok" --header "   Content-Type:application/json" --fail -ksS --request GET --url https://10.128.10   .1:8443/sdn/v2.0/of/datapaths/00:00:00:00:00:00:00:01/flows/ | python    -mjson.tool
{
    "flows": [
        {
            "actions": [
                {
                    "output": 2
                },
                {
                    "set_field": {
                        "ip_dscp": 46
                    }
                },
                {
                    "set_field": {
                        "eth_src": "00:00:00:00:00:01"
                    }
                }
            ],
            "byte_count": "0",
            "cookie": "0x0",
            "duration_nsec": "118000000",
            "duration_sec": 4,
            "hard_timeout": 30,
            "idle_timeout": 30,
            "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"
                }
            ],
            "packet_count": "0",
            "priority": 30000,
            "table_id": "n/a"
        },

 

HTH

Gerhard

HP SDN Team

jmikola
Member

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

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"}}]}]}

 

sdnindia
Trusted Contributor

Re: OpenFlow 1.0 network, HP SDN VAN controller and REST API

Hello jmikola,

 

We are glad that your problem is solved.
Please do let us know if you need further assistance.

Please feel free to reply in case you have more questions around the same topic or open a new thread if new topic.

 

Thanks
HP SDN Team